PROGRAM BT4_14 PARAMETER (NMAX=100,MMAX=6) DIMENSION X(NMAX,MMAX), F(MMAX,MMAX) DIMENSION DX(MMAX) DIMENSION XX(NMAX*MMAX) REAL ALFA, FALFA CHARACTER *12, H0,H1, ANSWER(MMAX,MMAX) DATA ALFA /0.05/ DATA H0,H1 /'CHAP NHAN H0','BAC BO H0'/ OPEN(1,FILE='C:\MASTER\G_TR\BAITAP~1\NEW\BANG8.TXT') READ(1,*) READ(1,*) READ(1,*) N,M DO I=1,N READ(1,*) TMP, (X(I,J),J=1,M) ENDDO DO J=1,M DO I=1,N XX(I)=X(I,J) ENDDO DX(J)=AMMTAM(XX,N,2) ENDDO FALFA=FINV(ALFA,REAL(N-1),REAL(N-1)) DO J=1,M-1 DO K=J+1,M F(J,K)=DX(J)/DX(K) IF (F(J,K).LT.1.0) F(J,K)=1.0/F(J,K) IF (ABS(F(J,K)).LT.FALFA) THEN ANSWER(J,K)=H0 ELSE ANSWER(J,K)=H1 ENDIF ENDDO ENDDO DO J=1,M-1 DO K=J+1,M WRITE(*,'(" KET QUA KIEM NGHIEM F - H0: D(",I1,")=D(", & I1,")")')J,K WRITE(*,'(" F = ",F10.3)') F(J,K) WRITE(*,'(" N1 = ",I10)') N WRITE(*,'(" N2 = ",I10)') N WRITE(*,'(" ALFA = ",F10.3)') ALFA WRITE(*,'(" FALFA = ",F10.3)') FALFA WRITE(*,'(" KET LUAN: ",A15)') ANSWER(J,K) PAUSE ENDDO ENDDO 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