%
%  Vincent Yannello
%
\documentclass[12pt,fullpage]{article}
\usepackage{fullpage}
\usepackage{amsmath}
\DeclareMathOperator{\erf}{erf}
\usepackage{psfrag}                                          % LaTeX graphics tool
\usepackage{pslatex}                                         % avoids the default cmr font
\usepackage{graphicx}                                        % graphics package 
\usepackage{epsfig}                                          % figures
\usepackage{hyperref}
\usepackage{color}

\begin{document}

\noindent
{\bf Kolmogorov--Smirnov distribution} (from \color{blue}\url{http://www.math.wm.edu/~leemis/chart/UDR/UDR.html}\color{black})

\noindent
The symbol used for the Kolmogorov--Smirnov test statistic for a sample size $n$ is typically $D_n$.
Using a result from Birnbaum, Z.W. (1952), ``Numerical Tabulation of the Distribution of Kolomogorov's
Statistic for Finite Sample Size,'' {\emph{Journal of the American Statistical Association}},
47, 425--441, a Kolmogorov--Smirnov random variable $D_n$ with parameter $n$ has a cumulative distribution function 
of $D_n - 1/(2n)$ of
$$
P\left(D_n < \frac{1}{2n} + v \right) = n! \, \int_{\frac{1} {2n} - v} ^ {\frac{1} {2n} + v} \int_{\frac{3} {2n} - v} ^ {\frac{3} {2n} + v}\ldots 
\int_{\frac{2n - 1} {2n} - v} ^ {\frac{2n - 1} {2n} + v} g(u_1,\, u_2, \ldots, u_n) \kern 0.08 em du_n \ldots du_2\, du_1 \qquad 0 \leq v \leq \frac{2n - 1}{2n}
$$
for all positive integer values of
$n$ with $g(u_1, u_2, \ldots, u_n) = 1$ over
$0 \leq u_1 \leq u_2 \leq \ldots \leq u_n \leq 1$, and~$0$ otherwise.
Computing this integral is non-trivial, particularly for larger values of $n$.  \\

The cumulative distribution function of $D_1$ for $n=1$ is
$$
F_{D_1}(t) = P(D_1 \le t) = \left\{ \begin{array}{ll}
                                      0 & \qquad t \le \frac{1}{2} \\ [0.5em]
                                      2t - 1 & \qquad \frac{1}{2} < t < 1\\ [0.5em]
                                      1 & \qquad t \ge 1.
                        \end{array} \right.
$$
The cumulative distribution function of $D_2$ for $n=2$ is 
$$ 
F_{D_2}(t) = P(D_2 \le t) = \left\{ \begin{array}{ll}
                                      0 & \qquad t \le \frac{1}{4} \\ [0.5em]
                                      8 \left(t - \frac{1}{4} \right)^2 & \qquad \frac{1}{4} < t < \frac{1}{2} \\ [0.5em]
                                      1 - 2 (1 - t) ^ 2 & \qquad \frac{1}{2} < t < 1 \\ [0.5em]
                                      1 & \qquad t \ge 1.
                        \end{array} \right.
$$

\noindent
The general cumulative distribution function is mathematically intractable, but an algorithm to calculate
it for specific values of $n$ is given in 
Drew, Glen, and Leemis (2000),
``Computing the Cumulative Distribution Function of the Kolmogorov--Smirnov Statistic,''
{\it Computational Statistics and Data Analysis}, Volume 34, Number 1, July 2000, 1--15.
Applying this algorithm when $n = 6$ gives the cumulative distribution function of $D_6$ as
\begin{small}
\[
F_{D_6}(t) =
\begin{cases}
0 & \qquad t <  \frac {1}{12} 
\cr 46080\,{t}^{6} - 23040\,{t}^{5} + 4800\,{t}^{4} -
\frac {1600}{3}\,{t}^{3} +
  \frac {100}{3}\,{t}^{2} - \frac {10}{9}\,{t} + \frac
{5}{324}
  & \qquad  \frac {1}{12} \leq t <  \frac {1}{6} 
\cr   2880\,t^{6} - 4800\,t^{5} + 2360\,t^{4} -  \frac
{1280}{3} \,t^{3}
  + \frac {235}{9} \,t^{2} + \frac {10}{27} \,t -
\frac {5}{81}
  & \qquad \frac {1}{6} \leq t <  \frac {1}{4} 
\cr  320\,t^{6} + 320\,t^{5}   - \frac {2600}{3}
\,t^{4}
  +  \frac {4240}{9} \,t^{3}
  -  \frac {785}{9} \,t^{2} + \frac {145}{27} \,t -
\frac {35}{1296}
  & \qquad \frac {1}{4} \leq t <  \frac {1}{3}
\cr  - 280\,t^{6} + 560\,t^{5} -  \frac {1115}{3}
\,t^{4} +
  \frac {515}{9} \,t^{3}  +  \frac {1525}{54} \,t^{2}
-  \frac {565}{81} \,t +
  \frac {5}{16}
  & \qquad  \frac {1}{3} \leq t < \frac {5}{12} 
\cr  104\,t^{6} - 240\,t^{5} + 295\,t^{4} - \frac
{1985}{9} \,t^{3}
  + \frac {775}{9} \,t^{2} -  \frac {7645}{648} \,t +
\frac {5}{16}
  & \qquad  \frac {5}{12} \leq t < \frac {1}{2} 
\cr   - 20\,t^{6}  + 32\,t^{5}  -  \frac {185}{9}
\,t^{3}
  +  \frac {175}{36} \,t^{2}  +  \frac {3371}{648} \,t
- 1
 & \qquad  \frac {1}{2} \leq t < \frac {2}{3} 
\cr  10\,t^{6} - 38\, t^{5}  +  \frac {160}{3} \,t^{4}
 - \frac {265}{9} \,t^{3} -  \frac {115}{108} \,t^{2}
  +  \frac {4651}{648} \,t - 1
  & \qquad  \frac {2}{3} \leq t <  \frac {5}{6} 
\cr   - 2\,t^{6} + 12\,t^{5}  - 30\,t^{4} + 40\,t^{3}
- 30\,t^{2} + 12\,t - 1
  & \qquad  \frac {5}{6} \leq t < 1
\cr 1
  & \qquad t \geq 1.\cr 
  \end{cases}
\]
\end{small}

\noindent
The survivor, hazard, cumulative hazard, inverse distribution, moment generating, and characteristic functions on the support 
of $X$ are also mathematically intractable.\\
\\
The population mean, variance, skewness, and kurtosis of $X$ are mathematically intractable.
Using the APPL function {\tt KSRV(n)}, however, one can calculate the moments of $D_n$ for
any value of $n$.  For example, the population means of $D_n$ for $n = 1, \, 2, \, \ldots, \, 6$ are given
in the table below.

\begin{center}
\begin{tabular}{c|c|c|c|c|c|c}
$n$ & 1 & 2 & 3 & 4 & 5 & 6 \\ \hline
$E[D_n]$ & $3/4$ & $13/24$ & $293/648$ & $813/2048$ & $134377/375000$ & $1290643/3919104$
\end{tabular}
\end{center}

\end{document}
