Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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. – user Dec 25 '12 at 18:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.