The Kolmogorov-Smirnov Two-Sample Test

JavaScript
Given a sample of size m from distribution function, F,
and a sample of size n from distribution function, G,
the Smirnov test tests the null hypothesis that F=G.
The Smirnov test statistic is Dm,n = supx|Fm(x)-Gn(x)|,
where Fm and Gn are the respective sample distribution functions.
Dm,n only takes values i/k for i=1,2,...,k, where k=lcm(m,n).

      Enter m and n and the cutoff point.

    Sample size m: 
    Sample size n: 
          x-value: 


P(Dm,n <= x) : Approximation:

Exact probabilities for Dm,n are calculated. For example, P(D100,100 <= .1) = .41699.
If both m and n tend to infinity, the distribution of √((m+n)/mn)Dm,n approaches the Kolgomorov
distribution but convergence is very slow. To see why, compute the same probability
for m=101 and n=100 (or x=.0999999). The approximation used here employs an ad-hoc
correction for continuity. The running time for the exact computation is proportional
to m times n, so take care if m times n is large (> 1,000,000 say).