PROGRAM BT5_8 PARAMETER (NMAX=100) DIMENSION X(NMAX),Y(NMAX) CHARACTER ANSWER*30 DATA ALFA /0.05/ OPEN(1,FILE='C:\MASTER\G_TR\BAITAP~1\NEW\BANG2.TXT') READ(1,*) READ(1,*) READ(1,*) N DO I=1,N READ(1,*) TMP,TMP,X(I),TMP,TMP,Y(I) ENDDO CALL HQTT_1(X,Y,N,A0,A1,R,Q,U,S,F) FALFA=FINV(ALFA,1.0,REAL(N-2)) IF (F.GT.FALFA) THEN ANSWER='P.TRINH HOI QUI DUNG DUOC' ELSE ANSWER='P.TRINH HOI QUI KHONG DUNG DUOC' ENDIF WRITE(*,*)' HOI QUI TUYEN TINH MOT BIEN' WRITE(*,'("DUNG LUONG MAU: ",I10)') N WRITE(*,'("TONG SO BAC TU DO: ",I10)') N-1 WRITE(*,'("HE SO A0: ",F10.3)') A0 WRITE(*,'("HE SO A1: ",F10.3)') A1 WRITE(*,'("HE SO TUONG QUAN R: ",F10.3)') R WRITE(*,'("SAI SO CHUAN S: ",F10.3)') S WRITE(*,'("TONG BP BIEN SAI HQ:",F10.3)') U WRITE(*,'("TONG BP BIEN SAI TD:",F10.3)') Q WRITE(*,'("TRI SO BIEN F: ",F10.3)') F WRITE(*,'("KET QUA KIEM NGHIEM:",A30)') ANSWER END !++++++++++++++++++++++++++++ SUBROUTINE HQTT_1(X,Y,N,A0,A1,R,Q,U,S,F) DIMENSION X(N),Y(N) TBX=0.0 TBY=0.0 DO I=1,N TBX=TBX+X(I) TBY=TBY+Y(I) ENDDO TBX=TBX/REAL(N) TBY=TBY/REAL(N) XY=0.0 XX=0.0 YY=0.0 DO I=1,N TX=X(I)-TBX TY=Y(I)-TBY XY=XY+TX*TY XX=XX+TX*TX YY=YY+TY*TY ENDDO A1=XY/XX A0=TBY-A1*TBX U=A1*XY Q=YY-U R=SQRT(U/YY) S=SQRT(Q/REAL(N-2)) F=U*REAL(N-2)/Q RETURN 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