C
C     ..................................................................
C
C        SUBROUTINE SMIRN
C
C        PURPOSE
C           COMPUTES VALUES OF THE LIMITING DISTRIBUTION FUNCTION FOR
C           THE KOLMOGOROV-SMIRNOV STATISTIC.
C
C        USAGE
C           CALL SMIRN(X,Y)
C
C        DESCRIPTION OF PARAMETERS
C           X    - THE ARGUMENT OF THE SMIRN FUNCTION
C           Y    - THE RESULTANT SMIRN FUNCTION VALUE
C
C        REMARKS
C           Y IS SET TO ZERO IF X IS NOT GREATER THAN 0.27, AND IS SET
C           TO ONE IF X IS NOT LESS THAN 3.1.  ACCURACY TESTS WERE MADE
C           REFERRING TO THE TABLE GIVEN IN THE REFERENCE BELOW.
C           TWO ARGUMENTS, X= 0.62, AND X = 1.87 GAVE RESULTS WHICH
C           DIFFER FROM THE SMIRNOV TABLES BY 2.9 AND 1.9 IN THE 5TH
C           DECIMAL PLACE.  ALL OTHER RESULTS SHOWED SMALLER ERRORS,
C           AND ERROR SPECIFICATIONS ARE GIVEN IN THE ACCURACY TABLES
C           IN THIS MANUAL.  IN DOUBLE PRECISION MODE, THESE SAME
C           ARGUMENTS RESULTED IN DIFFERENCES FROM TABLED VALUES BY 3
C           AND 2 IN THE 5TH  DECIMAL PLACE.  IT IS NOTED IN
C           LINDGREN (REFERENCE BELOW) THAT FOR HIGH SIGNIFICANCE LEVELS
C           (SAY, .01 AND .05) ASYMPTOTIC FORMULAS GIVE VALUES WHICH ARE
C           TOO HIGH ( BY 1.5 PER CENT WHEN N = 80).  THAT IS, AT HIGH
C           SIGNIFICANCE LEVELS, THE HYPOTHESIS OF NO DIFFERENCE WILL BE
C           REJECTED TOO SELDOM USING ASYMPTOTIC FORMULAS.
C
C        SUBROUTINES AND FUNCTION SUBPROGRAMS REQUIRED
C           NONE
C
C        METHOD
C           THE METHOD IS DESCRIBED BY W. FELLER-ON THE KOLMOGOROV-
C           SMIRNOV LIMIT THEOREMS FOR EMPIRICAL DISTRIBUTIONS- ANNALS
C           OF MATH. STAT., 19, 1948, 177-189, BY N. SMIRNOV--TABLE
C           FOR ESTIMATING THE GOODNESS OF FIT OF EMPIRICAL
C           DISTRIBUTIONS- ANNALS OF MATH. STAT., 19, 1948, 279-281,
C           AND GIVEN IN LINDGREN, STATISTICAL THEORY, THE MACMILLAN
C           COMPANY, N. Y., 1962.
C
C     ..................................................................
C
      SUBROUTINE SMIRN(X,Y)
C     DOUBLE PRECISION X,Q1,Q2,Q4,Q8,Y
C
C        IF A DOUBLE PRECISION VERSION OF THIS ROUTINE IS DESIRED, THE C
C        IN COLUMN ONE OF THE DOUBLE PRECISION CARD ABOVE SHOULD BE
C        REMOVED, AND THE C IN COLUMN ONE OF THE STATEMENTS NUMBERED
C        C   3, C   5, AND C   8 SHOULD BE REMOVED, AND THESE CARDS
C        SHOULD REPLACE THE STATEMENTS NUMBERED 3, 5, AND 8,
C        RESPECTIVELY.  ALL ROUTINES CALLING THIS ROUTINE MUST ALSO
C        PROVIDE DOUBLE PRECISION ARGUMENTS TO THIS ROUTINE.
C
C     ..................................................................
C
      IF(X-.27)1,1,2
    1 Y=0.0
      GO TO 9
    2 IF(X-1.0)3,6,6
    3 Q1=EXP(-1.233701/X**2)
C   3 Q1=DEXP(-1.233700550136170/X**2)
      Q2=Q1*Q1
      Q4=Q2*Q2
      Q8=Q4*Q4
      IF(Q8-1.0E-25)4,5,5
    4 Q8=0.0
    5 Y=(2.506628/X)*Q1*(1.0+Q8*(1.0+Q8*Q8))
C   5 Y=(2.506628274631001/X)*Q1*(1.0D0+Q8*(1.0D0+Q8*Q8))
      GO TO 9
    6 IF(X-3.1)8,7,7
    7 Y=1.0
      GO TO 9
    8 Q1=EXP(-2.0*X*X)
C   8 Q1=DEXP(-2.0D0*X*X)
      Q2=Q1*Q1
      Q4=Q2*Q2
      Q8=Q4*Q4
      Y=1.0-2.0*(Q1-Q4+Q8*(Q1-Q8))
    9 RETURN
      END
