AKS2DF
This function evaluates the cumulative distribution function of the Kolmogorov‑Smirnov goodness of fit D test statistic based on continuous data for two samples.
Function Return Value
AKS2DF — The probability of a smaller D. (Output)
Required Arguments
NOBSX — The total number of observations in the first sample. (Input)
NOBSY — The total number of observations in the second sample. (Input)
D — The D test statistic. (Input)
D is the maximum absolute difference between empirical cumulative distribution functions (CDFs) of the two samples.
FORTRAN 90 Interface
Generic: AKS2DF (NOBSX, NOBSY, D)
Specific: The specific interface names are S_AKS2DF and D_AKS2DF.
FORTRAN 77 Interface
Single: AKS2DF (NOBSX, NOBSY, D)
Double: The double precision name is DKS2DF.
Description
Function AKS2DF computes the cumulative distribution function (CDF) for the two‑sided Kolmogorov‑Smirnov two‑sample D statistic when the theoretical CDF is strictly continuous. Exact probabilities are computed according to a method given by Kim and Jennrich (1973). Approximate asymptotic probabilities are computed according to methods also given in this reference.
Let Fn(x) and Gm(x) denote the empirical distribution functions for the two samples, based on n = NOBSX and m = NOBSY observations. Then, the D statistic is computed as
Comments
1. Workspace may be explicitly provided, if desired, by use of AK22DF/DK22DF. The reference is:
AK22DF (NOBSX, NOBSY, D, WK)
The additional argument is:
WK — Work vector of length max(NOBSX, NOBSY) + 1.
2. Informational errors
Type | Code | Description |
---|
1 | 2 | Since the D test statistic is less than zero, then the distribution function is zero at D. |
1 | 3 | Since the D test statistic is greater than one, then the distribution function is one at D. |
Programming Notes
Function AKS2DF requires on the order of NOBSX * NOBSY operations to compute the exact probabilities, where an operation consists of an addition and a multiplication. For NOBSX * NOBSY less than 10000, the exact probability is computed. If this is not the case, then the Smirnov approximation discussed by Kim and Jennrich (1973) is used if the minimum of NOBSX and NOBSY is greater than ten percent of the maximum of NOBSX and NOBSY, or if the minimum is greater than 80. Otherwise, the Kolmogorov approximation discussed by Kim and Jennrich (1973) is used.
Example
Function AKS2DF is used to compute the probability of a smaller D statistic for a variety of sample sizes using values close to the 0.95 probability value.
USE UMACH_INT
USE AKS2DF_INT
IMPLICIT NONE
INTEGER I, NOBSX(10), NOBSY(10), NOUT
REAL D(10)
!
DATA NOBSX/5, 20, 40, 70, 110, 200, 200, 200, 100, 100/
DATA NOBSY/10, 10, 10, 10, 10, 20, 40, 60, 80, 100/
DATA D/0.7, 0.55, 0.475, 0.4429, 0.4029, 0.2861, 0.2113, 0.1796, &
0.18, 0.18/
!
CALL UMACH (2, NOUT)
!
DO 10 I=1, 10
!
WRITE (NOUT,99999) D(I), NOBSX(I), NOBSY(I), &
AKS2DF(NOBSX(I),NOBSY(I),D(I))
!
99999 FORMAT (' Probability for D = ', F5.3, ' with NOBSX = ', I3, &
' and NOBSY = ', I3, ' is ', F9.6, '.')
10 CONTINUE
END
Output
Probability for D = 0.700 with NOBSX = 5 and NOBSY = 10 is 0.980686.
Probability for D = 0.550 with NOBSX = 20 and NOBSY = 10 is 0.987553.
Probability for D = 0.475 with NOBSX = 40 and NOBSY = 10 is 0.972423.
Probability for D = 0.443 with NOBSX = 70 and NOBSY = 10 is 0.961646.
Probability for D = 0.403 with NOBSX = 110 and NOBSY = 10 is 0.928667.
Probability for D = 0.286 with NOBSX = 200 and NOBSY = 20 is 0.921126.
Probability for D = 0.211 with NOBSX = 200 and NOBSY = 40 is 0.917110.
Probability for D = 0.180 with NOBSX = 200 and NOBSY = 60 is 0.914520.
Probability for D = 0.180 with NOBSX = 100 and NOBSY = 80 is 0.908185.
Probability for D = 0.180 with NOBSX = 100 and NOBSY = 100 is 0.946098.