pkolm {kolmim} | R Documentation |
Cumulative distribution function for Kolmogorov's goodness-of-fit measure.
pkolm(d, n)
d |
the argument for the cumulative distribution function of Dn. |
n |
the number of variates. |
Given an ordered set of n
standard uniform variates,
x_1 < … < x_n, Kolmogorov suggested D_n = \max[D_n^-, D_n^+]
as a goodness-of-fit measure, where:
D_n^- = \max_{i=1, … n} [x_i - (i - 1) / n] and
D_n^+ = \max_{i=1, … n} [i / n - x_i].
pkolm
provides the original algorithm proposed by Wang, Tsang, and
Marsaglia (2003) to compute the cumulative distribution function
K(n, d) = P(D_n < d). This routine is used by ks.test
(package stats
) for one-sample two-sided exact tests, and it is
implemented in the C routine pkolmogorov2x
. pkolm
is a simple
wrap around pkolmogorov2x
.
Returns K(n, d) = P(D_n < d).
The two-sided one-sample distribution comes via Wang, Tsang, and Marsaglia (2003).
George Marsaglia, Wai Wan Tsang and Jingbo Wang (2003), Evaluating Kolmogorov's distribution. Journal of Statistical Software, 8/18. http://www.jstatsoft.org/v08/i18/.
pkolmim
for an improved routine to compute K(n, d), and
ks.test
for the Kolmogorov-Smirnov test.
n <- 100 x <- 1:100 / 500 plot(x, sapply(x, function (x) pkolm(x, n)), type='l') # Wang et al. approximation s <- x ^ 2 * n ps <- pmax(0, 1 - 2 * exp(-(2.000071 + .331 / sqrt(n) + 1.409 / n) * s)) lines(x, ps, lty=2)