Given an ordered set of n
standard uniform variates,
$x_1 < \dots < x_n$, Kolmogorov suggested $D_n = \max[D_n^-, D_n^+]$
as a goodness-of-fit measure, where:
$D_n^- = \max_{i=1, \dots n} [x_i - (i - 1) / n]$ and
$D_n^+ = \max_{i=1, \dots n} [i / n - x_i]$. Wang, Tsang, and Marsaglia (2003) have proposed an algorithm to compute the
cumulative distribution function $K(n, d) = P(D_n < d)$.
pkolmim
offers an improved implementation that uses less memory and
should be more efficient for a range of arguments that are common in
practice, while keeping the same precision.
The original algorithm of Wang, Tsang, and Marsaglia is implemented in the C
routine pkolmogorov2x
that is used by ks.test
(package
stats
) for one-sample two-sided exact tests. Similarly,
pkolmim
is used by ks.test.imp
in package
kolmim
.