SUBROUTINE PROPOR(X,N,XMIN,XMAX,IWRITE,XPROP) C C PURPOSE--THIS SUBROUTINE COMPUTES THE C THE SAMPLE PROPORTION WHICH IS THE C PROPORTION OF DATA BETWEEN XMIN AND XMAX (INCLUSIVELY) C IN THE INPUT VECTOR X. C THE SAMPLE PROPORTION = (THE NUMBER OF OBSERVATIONS C IN THE SAMPLE BETWEEN XMIN AND XMAX, INCLUSIVELY) / N. C THE SAMPLE PROPORTION WILL BE A SINGLE PRECISION C VALUE BETWEEN 0.0 AND 1.0 (INCLUSIVELY). C INPUT ARGUMENTS--X = THE SINGLE PRECISION VECTOR OF C (UNSORTED OR SORTED) OBSERVATIONS. C --N = THE INTEGER NUMBER OF OBSERVATIONS C IN THE VECTOR X. C --XMIN = THE SINGLE PRECISION VALUE C WHICH DEFINES THE LOWER LIMIT C (INCLUSIVELY) OF THE REGION C OF INTEREST. C --XMAX = THE SINGLE PRECISION VALUE C WHICH DEFINES THE UPPER LIMIT C (INCLUSIVELY) OF THE REGION C OF INTEREST. C --IWRITE = AN INTEGER FLAG CODE WHICH C (IF SET TO 0) WILL SUPPRESS C THE PRINTING OF THE C SAMPLE PROPORTION C AS IT IS COMPUTED; C OR (IF SET TO SOME INTEGER C VALUE NOT EQUAL TO 0), C LIKE, SAY, 1) WILL CAUSE C THE PRINTING OF THE C SAMPLE PROPORTION C AT THE TIME IT IS COMPUTED. C OUTPUT ARGUMENTS--XPROP = THE SINGLE PRECISION VALUE OF THE C COMPUTED SAMPLE PROPORTION. C THIS WILL BE A VALUE BETWEEN C 0.0 AND 1.0 (INCLUSIVELY). C OUTPUT--THE COMPUTED SINGLE PRECISION VALUE OF THE C SAMPLE PROPORTION. C PRINTING--NONE, UNLESS IWRITE HAS BEEN SET TO A NON-ZERO C INTEGER, OR UNLESS AN INPUT ARGUMENT ERROR C CONDITION EXISTS. C RESTRICTIONS--THERE IS NO RESTRICTION ON THE MAXIMUM VALUE C OF N FOR THIS SUBROUTINE. C OTHER DATAPAC SUBROUTINES NEEDED--NONE. C FORTRAN LIBRARY SUBROUTINES NEEDED--NONE. C MODE OF INTERNAL OPERATIONS--SINGLE PRECISION. C LANGUAGE--ANSI FORTRAN. C REFERENCES--SNEDECOR AND COCHRAN, STATISTICAL METHODS, C EDITION 6, 1967, PAGES 207-213. C --DIXON AND MASSEY, INTRODUCTION TO STATISTICAL C ANALYSIS, EDITION 2, 1957, PAGES 81-82, 228-231. C WRITTEN BY--JAMES J. FILLIBEN C STATISTICAL ENGINEERING LABORATORY (205.03) C NATIONAL BUREAU OF STANDARDS C WASHINGTON, D. C. 20234 C PHONE: 301-921-2315 C ORIGINAL VERSION--JUNE 1974. C UPDATED --SEPTEMBER 1975. C UPDATED --NOVEMBER 1975. C C--------------------------------------------------------------------- C DIMENSION X(1) C IPR=6 C C CHECK THE INPUT ARGUMENTS FOR ERRORS C IF(N.LT.1)GOTO50 IF(N.EQ.1)GOTO55 IF(XMIN.EQ.XMAX)GOTO80 HOLD=X(1) DO60I=2,N IF(X(I).NE.HOLD)GOTO90 60 CONTINUE WRITE(IPR, 9)HOLD XPROP=0.0 RETURN 50 WRITE(IPR,15) WRITE(IPR,47)N RETURN 55 WRITE(IPR,18) XPROP=0.0 RETURN 80 WRITE(IPR,26) WRITE(IPR,49)XMIN XPROP=0.0 RETURN 90 CONTINUE 9 FORMAT(1H ,108H***** NON-FATAL DIAGNOSTIC--THE FIRST INPUT ARGUME 1NT (A VECTOR) TO THE PROPOR SUBROUTINE HAS ALL ELEMENTS = ,E15.8,6 1H *****) 15 FORMAT(1H , 91H***** FATAL ERROR--THE SECOND INPUT ARGUMENT TO THE 1 PROPOR SUBROUTINE IS NON-POSITIVE *****) 18 FORMAT(1H ,100H***** NON-FATAL DIAGNOSTIC--THE SECOND INPUT ARGUME 1NT TO THE PROPOR SUBROUTINE HAS THE VALUE 1 *****) 26 FORMAT(1H ,46H***** FATAL ERROR--THE THIRD AND FOURTH INPUT , 1 48HARGUMENTS TO THE PROPOR SUBROUTINE ARE IDENTICAL) 47 FORMAT(1H , 35H***** THE VALUE OF THE ARGUMENT IS ,I8 ,6H *****) 49 FORMAT(1H , 37H***** THE VALUE OF THE ARGUMENTS ARE ,E15.7 ,6H * 1****) C C-----START POINT----------------------------------------------------- C AN=N XPROP=0.0 ISUM=0 DO100I=1,N IF(X(I).LT.XMIN.OR.XMAX.LT.X(I))GOTO100 ISUM=ISUM+1 100 CONTINUE SUM=ISUM XPROP=SUM/AN C 101 IF(IWRITE.EQ.0)RETURN WRITE(IPR,999) WRITE(IPR,105)N,XMIN,XMAX,XPROP 105 FORMAT(1H ,22HTHE PROPORTION OF THE ,I6,30H OBSERVATIONS IN THE IN 1TERVAL ,E15.7,4H TO ,E15.7,4H IS ,E15.7) 999 FORMAT(1H ) RETURN END