PROGRAM BT3_11 REAL N, ALFA, X0 WRITE(*,'(A\)')' CHO MUC Y NGHIA ALPHA: ' READ(*,*) ALFA WRITE(*,'(A\)')' CHO SO BAC TU DO N : ' READ(*,*) N X0=TINV(ALFA,N) WRITE(*,'(" GIA TRI X0 = ",F12.4)') X0 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 PRINT*,P,A,B,C 10 P0=TDIST(B,N) SS=ABS((P0-AP)/AP) SS1=ABS((B-C)/B) PRINT*,'P0=',P0,' SS=',SS,' B=',B,' C=',C 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|