# Kolmogorov-Smirnov CDF

I'm writing some C++ code that uses a two-sample K-S test. I've computed the largest difference between the two cumulative density functions, $D$, and then compute the test statistic $x = \sqrt{\frac{n_1 n_2}{n_1 + n_2}} D$.

Does anyone know of a simple form for the cumulative density function under the null hypothesis? I found the asymptotic form when $n \rightarrow \infty$ on Wikipedia:

But I haven't been able to find any approximation where $n$ is not large. Can you give me the formula or provide a reference?

Thanks a lot.

-
You may read how SPSS computes p-value for KS test (one-sample, 2-sample) in this document –  ttnphns Dec 15 '12 at 16:31
This is expressible in terms of a Jacobi Theta function, $\frac{1}{x} e^{\frac{3 \pi ^2}{8 x^2}} \left(e^{-\frac{\pi ^2}{2 x^2}}\right)^{3/4} \sqrt{\frac{\pi }{2}} \vartheta_2\left(0,e^{-\frac{\pi ^2}{2 x^2}}\right)$. But what is your question? It seems to have been cut off after "$n$ i...". –  whuber Dec 15 '12 at 22:02
Thanks! Oops-- edited. –  Oliver Dec 25 '12 at 18:21