PROGRAM BT3_3 PARAMETER (NMAX=100) DIMENSION X(NMAX),X1(0:NMAX),PX(0:NMAX),FX(0:NMAX) DIMENSION P(0:NMAX),F(0:NMAX) ! CHUA PHAN BO THUC NGHIEM INTEGER N,N1,I,J, NAM(NMAX) REAL LAMDA OPEN(1,FILE='C:\MASTER\G_TR\BAITAP~1\NEW\BANG9.TXT') READ(1,*) READ(1,*) READ(1,*)N READ(1,*)((NAM(I),X(I)), I=1,N) ! TINH TRUNG BINH SO LAN XUAT HIEN (LAMDA) LAMDA=AMMGOC(X,N,1) N1=12 ! THAM SO N CUA PHAN BO ! TINH MAT DO VA PHAN BO THUC NGHIEM DO J=0,N1 P(J)=0.0 DO I=1,N IF (X(I).EQ.J) P(J)=P(J)+1.0 ENDDO P(J)=P(J)/REAL(N) ENDDO DO J=0,N1 F(J)=0.0 DO I=0,J F(J)=F(J)+P(I) ENDDO ENDDO CALL POSSD(N1,LAMDA,X1,PX,FX) WRITE(*,*)' HAM MAT DO VA HAM PHAN BO POSSION' WRITE(*,'(" LAMDA = ",F8.4," N = ",I4)') LAMDA,N1 WRITE(*,'(" x ",15F5.0)') (X1(I),I=0,N1) WRITE(*,'(" f(x) ",15F5.2)') (PX(I),I=0,N1) WRITE(*,'("fn(x) ",15F5.2)') (P(I),I=0,N1) WRITE(*,'(" F(x) ",15F5.2)') (FX(I),I=0,N1) WRITE(*,'("Fn(x) ",15F5.2)') (F(I),I=0,N1) END FUNCTION POSSION(LAMDA,K) REAL LAMDA ! HAM NAY TINH XAC SUAT SU KIEN XUAT HIEN K LAN THEO POSSION POSSION=EXP(-LAMDA)*LAMDA**K/FAC(K) RETURN END SUBROUTINE POSSD(N,LAMDA,X,PX,FX) ! CHUONG TRINH NAY TINH PHAN BO POSSION ! INPUT: + N SO LAN THI NGHIEM ! + LAMDA TRUNG BINH SO LAN XUAT HIEN ! OUTPUT: + X MANG DO DAI N+1 (TU 0..N) CHUA GIA TRI CUA X ! + PX MANG DO DAI N+1 (TU 0..N) CHUA XAC SUAT ! DE X NHAN CAC GIA TRI 0..N ! + FX MANG DO DAI N+1 (TU 0..N) CHUA XAC SUAT TICH ! LUY CUA X (FX(K)=P(X