PROGRAM BT4_10 ! KIEM NGHIEM T TRUONG HOP I PARAMETER (NMAX=100,MMAX=12) DIMENSION X(NMAX,MMAX),TB(NMAX) REAL MUY,MUY0,XICMA2, ALFA,T,TALFA,ALFA1,TALFA1,SX INTEGER N,M,I,J CHARACTER*15 H0,H1,ANSWER1,ANSWER2 ! MUY0: HANG SO ! XICMA2: PHUONG SAI CUA X ! ALFA, ALFA1: CAC XAC SUAT PHAM SAI LAM LOAI I DATA MUY0,XICMA2,ALFA,ALFA1 /23.5,0.1,0.05,0.01/ DATA H0,H1 /'CHAP NHAN H0','BAC BO H0'/ OPEN(1,FILE='C:\MASTER\G_TR\BAITAP~1\NEW\BANG10.TXT') READ(1,*) READ(1,*) READ(1,*) N,M DO I=1,N READ(1,*) TMP, (X(I,J),J=1,M) ENDDO ! TINH TRUNG BINH SO HOC VA DO LECH CHUAN ! MANG TB CHUA TRUNG BINH NAM CUA TUNG NAM ! MUY VA SX LA TRUNG BINH VA DO LECH CHUAN ! CUA CAC TRUNG BINH NAM, MUY=0.0 SX=0.0 DO I=1,N TB(I)=0.0 DO J=1,M TB(I)=TB(I)+X(I,J) ENDDO TB(I)=TB(I)/REAL(M) ENDDO MUY=AMMGOC(TB,N,1) SX=AMMTAM(TB,N,2) SX=SQRT(SX) ! TINH T VA CAC TALFA T=(MUY-MUY0)/SX*SQRT(REAL(N)) TALFA=TINV(ALFA,REAL(N-1)) TALFA1=TINV(ALFA1,REAL(N-1)) IF (ABS(T).LT.TALFA) THEN ANSWER1=H0 ELSE ANSWER1=H1 ENDIF IF (ABS(T).LT.TALFA1) THEN ANSWER2=H0 ELSE ANSWER2=H1 ENDIF WRITE(*,*)' KET QUA KIEM NGHIEM T' WRITE(*,'(" MUY = ",F10.3)') MUY WRITE(*,'(" MUY0 = ",F10.3)') MUY0 WRITE(*,'(" N = ",I10)') N WRITE(*,'(" T = ",F10.3)') T WRITE(*,'(" ALFA1 = ",F10.3)') ALFA WRITE(*,'(" TALFA1 = ",F10.3)') TALFA WRITE(*,'(" KET LUAN1: ",A15)') ANSWER1 WRITE(*,*) WRITE(*,'(" ALFA2 = ",F10.3)') ALFA1 WRITE(*,'(" TALFA2 = ",F10.3)') TALFA1 WRITE(*,'(" KET LUAN2: ",A15)') ANSWER2 WRITE(*,*) IF (ANSWER1.EQ.ANSWER2) THEN WRITE(*,*)' KHONG THAY DOI' ELSE WRITE(*,*)' THAY DOI' ENDIF END FUNCTION TINV(P,N) ! HAM NAY TINH GIA TRI X0 CUA BIEN NGAU NHIEN X PHAN BO ! STUDENT VOI N BAC TU DO THOA MAN DIEU KIEN ! P(|X|>X0)=P. ! INPUT: + P XAC SUAT DE |X|>X0 (P(|X|>X0)=P) ! + N SO BAC TU DO, PHAI LA MOT SO THUC ! OUTPUT: X0 ! SUBROUTINE/FUNCTION DUOC GOI TOI: TDIST PARAMETER (EPS=1.0E-6) REAL P,AP,N, A,B,C,P0 IF (P.LT.0.0.OR.P.GT.1.0) THEN WRITE(*,*)' INVALID NUMERIC INPUT IN AKBPINV FUNCTION' STOP ENDIF IF (P.EQ.0.0) THEN WRITE(*,*)' THE P VALUE TOO SMALL IN AKBPINV FUNCTION' STOP ELSE IF (P.EQ.1) THEN WRITE(*,*)' THE P VALUE TOO BIG IN AKBPINV FUNCTION' STOP ENDIF ! A=0.0 B=99999.0 ! C=A AP=P 10 P0=TDIST(B,N) SS=ABS((P0-AP)/AP) SS1=ABS((B-C)/B) IF (SS.GE.EPS.AND.SS1.GE.EPS) THEN IF (AP.GT.P0) THEN C=B B=(A+B)/2.0 ! PRINT*,'1- B=',B,' C=',C GOTO 10 ELSE IF (AP.LT.P0) THEN B=(C+B)/2.0 ! PRINT*,'2- B=',B,' C=',C GOTO 10 ENDIF ENDIF A=(C+B)/2.0 TINV=A RETURN END FUNCTION TDIST(X0,N) ! HAM NAY TINH XAC SUAT DE BIEN NGAU NHIEN X CO PHAN BO STUDENT ! VOI N BAC TU DO NHAN GIA TRI NGOAI KHOANG (-X0;X0): ! P=P(|X|>X0)=1-P(|X|