AKS1DF
This function evaluates the cumulative distribution function of the one‑sided Kolmogorov‑Smirnov goodness of fit D+ or D− test statistic based on continuous data for one sample.
Function Return Value
AKS1DF — The probability of a smaller D. (Output)
Required Arguments
NOBS — The total number of observations in the sample. (Input)
D — The D+ or D− test statistic. (Input)
D is the maximum positive difference of the empirical cumulative distribution function (CDF) minus the hypothetical CDF or the maximum positive difference of the hypothetical CDF minus the empirical CDF.
FORTRAN 90 Interface
Generic: AKS1DF (NOBS, D)
Specific: The specific interface names are S_AKS1DF and D_AKS1DF.
FORTRAN 77 Interface
Single: AKS1DF (NOBS, D)
Double: The double precision name is DKS1DF.
Description
Routine AKS1DF computes the cumulative distribution function (CDF) for the one‑sided Kolmogorov‑Smirnov one‑sample
D+ or D-
statistic when the theoretical CDF is strictly continuous. Let
F(x)
denote the theoretical distribution function, and let
denote the empirical distribution function obtained from a sample of size NOBS. Then, the
D+
statistic is computed as
while the one‑sided
D-
statistic is computed as
Exact probabilities are computed according to a method given by Conover (1980, page 350) for sample sizes of 80 or less. For sample sizes greater than 80, Smirnov’s asymptotic result is used, that is, the value of the CDF is taken as , where d is D+ or D− (Kendall and Stuart, 1979, page 482). This asymptotic expression is conservative (the value returned by AKS1DF is smaller than the exact value, when the sample size exceeds 80).
Comments
1. Workspace may be explicitly provided, if desired, by use of AK21DF/DK21DF. The reference is:
AK2DF (NOBS, D, WK)
The additional argument is:
WK — Work vector of length 3 * NOBS + 3 if NOBS ≤ 80. WK is not used if NOBS is greater than 80.
2. Informational errors
Type |
Code |
Description |
1 |
2 |
Since the D test statistic is less than zero, the distribution function is zero at D. |
1 |
3 |
Since the D test statistic is greater than one, the distribution function is one at D. |
3. If NOBS ≤ 80, then exact one‑sided probabilities are computed. In this case, on the order of NOBS2 operations are required. For NOBS > 80, approximate one‑sided probabilities are computed. These approximate probabilities require very few computations.
4. An approximate two‑sided probability for the D = max (D+, D−) statistic can be computed as twice the AKS1DF probability for D (minus one, if the probability from AKS1DF is greater than 0.5).
Programming Notes
Routine AKS1DF requires on the order of NOBS2 operations to compute the exact probabilities, where an operation consists of taking ten or so logarithms. Because so much computation is occurring within each “operation,” AKS1DF is much slower than its two‑sample counterpart, function AKS2DF.
Example
In this example, the exact one‑sided probabilities for the tabled values of D+ or D−, given, for example, in Conover (1980, page 462), are computed. Tabled values at the 10% level of significance are used as input to AKS1DF for sample sizes of 5 to 50 in increments of 5 (the last two tabled values are obtained using the asymptotic critical values of
The resulting probabilities should all be close to 0.90.
USE UMACH_INT
USE AKS1DF_INT
IMPLICIT NONE
INTEGER I, NOBS, NOUT
REAL D(10)
!
DATA D/0.447, 0.323, 0.266, 0.232, 0.208, 0.190, 0.177, 0.165, &
0.160, 0.151/
!
CALL UMACH (2, NOUT)
!
DO 10 I=1, 10
NOBS = 5*I
!
WRITE (NOUT,99999) D(I), NOBS, AKS1DF(NOBS,D(I))
!
99999 FORMAT (' One-sided Probability for D = ', F8.3, ' with NOBS ' &
, '= ', I2, ' is ', F8.4)
10 CONTINUE
END
Output
One-sided Probability for D = 0.447 with NOBS = 5 is 0.9000
One-sided Probability for D = 0.323 with NOBS = 10 is 0.9006
One-sided Probability for D = 0.266 with NOBS = 15 is 0.9002
One-sided Probability for D = 0.232 with NOBS = 20 is 0.9009
One-sided Probability for D = 0.208 with NOBS = 25 is 0.9002
One-sided Probability for D = 0.190 with NOBS = 30 is 0.8992
One-sided Probability for D = 0.177 with NOBS = 35 is 0.9011
One-sided Probability for D = 0.165 with NOBS = 40 is 0.8987
One-sided Probability for D = 0.160 with NOBS = 45 is 0.9105
One-sided Probability for D = 0.151 with NOBS = 50 is 0.9077