PROGRAM BT3_1 PARAMETER (NMAX=100) DIMENSION X(NMAX),X1(0:NMAX),PX(0:NMAX),FX(0:NMAX) INTEGER N,N1,I,J, NAM(NMAX) OPEN(1,FILE='C:\MASTER\G_TR\BAITAP~1\NEW\BANG1.TXT') READ(1,*) READ(1,*) READ(1,*)N READ(1,*)((NAM(I),X(I)), I=1,N) ! TINH TRUNG BINH NHIEU NAM (TB) TB=AMMGOC(X,N,1) ! XAC DINH SO NAM CO X VUOT QUA TB K=0 DO I=1,N IF (X(I).GE.TB) K=K+1 ENDDO ! TINH UOC LUONG XAC SUAT (TAN SUAT) P P=REAL(K)/REAL(N) N1=10 ! THAM SO N CUA PHAN BO CALL BINOMD(N1,P,X1,PX,FX) WRITE(*,*)' HAM MAT DO VA HAM PHAN BO NHI THUC' WRITE(*,'(" P = ",F8.4," N = ",I4)') P,N1 WRITE(*,'(" x ",15F5.0)') (X1(I),I=0,N1) WRITE(*,'(" f(x) ",15F5.2)') (PX(I),I=0,N1) WRITE(*,'(" F(x) ",15F5.2)') (FX(I),I=0,N1) END FUNCTION BERN(N,K,P) ! HAM NAY TINH XAC SUAT DE TRONG N LAN THI NGHIEM SU KIEN A XUAT ! HIEN K LAN, VOI P=P(A) BERN=COMBIN(N,K)*P**K*(1-P)**(N-K) RETURN END SUBROUTINE BINOMD(N,P,X,PX,FX) ! CHUONG TRINH NAY TINH PHAN BO NHI THUC ! INPUT: + N SO LAN THI NGHIEM ! + P=P(A) XAC SUAT SU KIEN A ! 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