      SUBROUTINE SCALE(X,N)
C
C     PURPOSE--THIS SUBROUTINE COMPUTES 4 ESTIMATES OF THE
C              SCALE (VARIATION, SCATTER, DISPERSION)
C              OF THE DATA IN THE INPUT VECTOR X. 
C              THE 4 ESTIMATORS EMPLOYED ARE--
C              1) THE SAMPLE RANGE;
C              2) THE SAMPLE STANDARD DEVIATION;
C              3) THE SAMPLE RELATIVE STANDARD DEVIATION; AND
C              4) THE SAMPLE VARIANCE.
C              NOTE THAT N-1 (RATHER THAN N)
C              IS USED IN THE DIVISOR IN THE
C              COMPUTATION OF THE SAMPLE STANDARD 
C              DEVIATION, THE SAMPLE RELATIVE
C              STANDARD DEVIATION, AND THE
C              SAMPLE VARIANCE.
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     OUTPUT--1/4 PAGE OF AUTOMATIC OUTPUT
C             CONSISTING OF THE FOLLOWING 4
C             ESTIMATES OF SCALE
C             FOR THE DATA IN THE INPUT VECTOR X--
C             1) THE SAMPLE RANGE;
C             2) THE SAMPLE STANDARD DEVIATION;
C             3) THE SAMPLE RELATIVE STANDARD DEVIATION; AND
C             4) THE SAMPLE VARIANCE.
C     PRINTING--YES.
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--SQRT.
C     MODE OF INTERNAL OPERATIONS--SINGLE PRECISION.
C     LANGUAGE--ANSI FORTRAN. 
C     COMMENT--THE SAMPLE RELATIVE STANDARD DEVIATION
C              IS THE SAMPLE STANDARD DEVIATION RELATIVE
C              TO THE MAGNITUDE OF THE SAMPLE MEAN.
C              THE RELATIVE SAMPLE STANDARD DEVIATION
C              IS EXPRESSED AS A PERCENT.
C              THE RELATIVE SAMPLE STANDARD DEVIATION
C              IS EQUIVALENTLY CALLED THE
C              SAMPLE COEFFICIENT OF VARIATION.
C     REFERENCES--DIXON AND MASSEY, PAGES 19 AND 21
C               --SNEDECOR AND COCHRAN, PAGE 62
C               --DIXON AND MASSEY, PAGES 14, 70, AND 71
C               --CROW, JOURNAL OF THE AMERICAN STATISTICAL ASSOCIATION,
C                 PAGES 357 AND 387
C               --KENDALL AND STUART, THE ADVANCED THEORY OF
C                 STATISTICS, VOLUME 1, EDITION 2, 1963, PAGE 8.
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      1972. 
C     UPDATED         --NOVEMBER  1975. 
C
C---------------------------------------------------------------------
C
      DIMENSION X(1)
C
      IPR=6
C
C     CHECK THE INPUT ARGUMENTS FOR ERRORS
C
      XRANGE=0.0
      XSD=0.0
      XRELSD=0.0
      XVAR=0.0
      IF(N.LT.1)GOTO50
      IF(N.EQ.1)GOTO55
      HOLD=X(1)
      DO60I=2,N
      IF(X(I).NE.HOLD)GOTO90
   60 CONTINUE
      WRITE(IPR, 9)HOLD
      GOTO90
   50 WRITE(IPR,15) 
      WRITE(IPR,47)N
      RETURN
   55 WRITE(IPR,18) 
      XRANGE=0.0
      XSD=0.0
      XRELSD=0.0
      GOTO301
   90 CONTINUE
    9 FORMAT(1H ,109H***** NON-FATAL DIAGNOSTIC--THE FIRST  INPUT ARGUME
     1NT (A VECTOR) TO THE SCALE  SUBROUTINE HAS ALL ELEMENTS = ,E15.8,6
     1H *****)
   15 FORMAT(1H , 91H***** FATAL ERROR--THE SECOND INPUT ARGUMENT TO THE
     1 SCALE  SUBROUTINE IS NON-POSITIVE *****)
   18 FORMAT(1H ,100H***** NON-FATAL DIAGNOSTIC--THE SECOND INPUT ARGUME
     1NT TO THE SCALE  SUBROUTINE HAS THE VALUE 1 *****)
   47 FORMAT(1H , 35H***** THE VALUE OF THE ARGUMENT IS ,I8   ,6H *****)
C
C-----START POINT-----------------------------------------------------
C
      AN=N
C
C     DETERMINE THE SAMPLE MINIMUM AND THE SAMPLE MAXIMUM,
C     THEN COMPUTE THE SAMPLE RANGE.
C
      XMIN=X(1)
      XMAX=X(1)
      DO100I=1,N
      IF(X(I).LT.XMIN)XMIN=X(I)
      IF(X(I).GT.XMAX)XMAX=X(I)
  100 CONTINUE
      XRANGE=XMAX-XMIN
C
C     COMPUTE THE SAMPLE VARIANCE,
C     AND THEN THE SAMPLE STANDARDD DEVIATION.
C
      SUM=0.0
      DO150I=1,N
      SUM=SUM+X(I)
  150 CONTINUE
      XMEAN=SUM/AN
      SUM=0.0
      DO200I=1,N
      SUM=SUM+(X(I)-XMEAN)**2 
  200 CONTINUE
      XVAR=SUM/(AN-1.0)
      XSD=SQRT(XVAR)
C
C     COMPUTE THE SAMPLE RELATIVE STANDARD DEVIATION;
C     THAT IS, THE SAMPLE STANDARD DEVIATION RELATIVE
C     TO THE MAGNITUDE OF THE SAMPLE MEAN.
C     THE RESULTING SAMPLE STANDARD DEVIATION IS EXPRESSED
C     AS A PERCENT. 
C
      XRELSD=100.0*XSD/XMEAN
      IF(XRELSD.LT.0.0)XRELSD=-XRELSD
C
C     WRITE EVERYTHING OUT
C
  301 DO300I=1,5
      WRITE(IPR,999)
  300 CONTINUE
      WRITE(IPR,305)
      WRITE(IPR,999)
      WRITE(IPR,310)N
      WRITE(IPR,999)
      WRITE(IPR,999)
      WRITE(IPR,315)XRANGE
      WRITE(IPR,320)XSD
      WRITE(IPR,325)XVAR
      WRITE(IPR,330)XRELSD
C
  305 FORMAT(1H ,30X,32HESTIMATES OF THE SCALE PARAMETER)
  310 FORMAT(1H ,34X,21H(THE SAMPLE SIZE N = ,I5,1H))
  315 FORMAT(1H ,42HTHE SAMPLE RANGE IS                       ,E15.8) 
  320 FORMAT(1H ,42HTHE SAMPLE STANDARD DEVIATION IS          ,E15.8) 
  325 FORMAT(1H ,42HTHE SAMPLE VARIANCE IS                    ,E15.8) 
  330 FORMAT(1H ,42HTHE SAMPLE RELATIVE STANDARD DEVIATION IS ,E15.8,8H
     1PERCENT)
  999 FORMAT(1H )
C
      RETURN
      END 
