PROGRAM BT3_12 REAL N, ALFA, X0, N1 WRITE(*,'(A\)')' CHO MUC Y NGHIA ALPHA: ' READ(*,*) ALFA WRITE(*,'(A\)')' CHO SO BAC TU DO N1 : ' READ(*,*) N WRITE(*,'(A\)')' CHO SO BAC TU DO N2 : ' READ(*,*) N1 ! X0=TINV(ALFA,N) X0=FINV(ALFA,N,N1) WRITE(*,'(" GIA TRI X0 = ",F12.4)') X0 END FUNCTION FINV(P,N1,N2) ! HAM NAY TINH GIA TRI X0 CUA BIEN NGAU NHIEN X PHAN BO ! FISHER (F) VOI N1 VA N2 BAC TU DO THOA MAN DIEU KIEN ! P(X>X0)=P. ! INPUT: + P XAC SUAT DE X>X0 (P(X>X0)=P) ! + N1 VA N2 LA SO BAC TU DO, PHAI LA NHUNG SO THUC ! OUTPUT: X0 ! SUBROUTINE/FUNCTION DUOC GOI TOI: FDIST PARAMETER (EPS=1.0E-6) REAL P,AP,N1,N2, A,B,C,P0,SS,SS1 IF (P.LT.0.0.OR.P.GT.1.0) THEN WRITE(*,*)' INVALID NUMERIC INPUT IN FINV FUNCTION' STOP ENDIF IF (P.EQ.0.0) THEN WRITE(*,*)' THE P VALUE TOO SMALL IN FINV FUNCTION' STOP ELSE IF (P.EQ.1) THEN FINV=0.0 RETURN ENDIF ! A=0.0 B=9999999.0 C=A AP=P 10 P0=FDIST(B,N1,N2) 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 GOTO 10 ELSE IF (AP.LT.P0) THEN B=(C+B)/2.0 GOTO 10 ENDIF ENDIF A=(C+B)/2.0 FINV=A RETURN END FUNCTION FDIST(X0,N1,N2) ! HAM NAY TINH XAC SUAT DE BIEN NGAU NHIEN X CO PHAN BO FISHER ! VOI N1 VA N2 BAC TU DO NHAN GIA TRI >X0: ! P=P(X>X0)=1-P(X