PROGRAM BT5_9 PARAMETER (NMAX=100,MMAX=12) DIMENSION X(NMAX*MMAX),Y(NMAX*MMAX),XX(NMAX),YY(NMAX) CHARACTER ANSWER*30 DATA ALFA /0.05/ OPEN(1,FILE='C:\MASTER\G_TR\BaiTap~1\New\BANG14-H.TXT') READ(1,*) READ(1,*) READ(1,*) N,M DO I=1,N L=(M-1)*N+I READ(1,*) TMP, (X(J),J=I,L,N) ENDDO CLOSE(1) OPEN(1,FILE='C:\MASTER\G_TR\BaiTap~1\New\BANG14-P.TXT') READ(1,*) READ(1,*) READ(1,*) N,M DO I=1,N L=(M-1)*N+I READ(1,*) TMP, (Y(J),J=I,L,N) ENDDO FALFA=FINV(ALFA,1.0,REAL(N-2)) DO K=1,M L=(K-1)*N+1 DO I=1,N ENDDO CALL HQTT_1(X(L),Y(L),N,A0,A1,R,Q,U,S,F) 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 - THANG ",I2)'),K WRITE(*,*)' Y=A0+A1*X (Y: TRAM PB; X: TRAM HG)' 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 PAUSE ENDDO 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