Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I'm implementing the two sample K-S test using the great Wikipedia page.

As an example, I have two lists: 1 2 3 4 5 6 7 6 1 3 4 and 1 3 2 10 11 4 1 15 13 3 17

$D_n$, the largest absolute difference between the two cumulative distributions is 0.4545 (confirmed via this online K-S test).

The Wikipedia page says that I reject when $\sqrt{\frac{n_1 n_2}{n_1 + n_2}} D_n$ exceeds the critical value $K_\alpha$. Thus, I should be able to compute my p-value using the CDF for the $K$ statistic:

$x = \sqrt{\frac{n_1 n_2}{n_1 + n_2}} D_n$

$p-value = Pr(K \leq x)$

For the example lists, $x = 0.4545 \sqrt{\frac{11}{2}} = 1.0660025157744704$

Wikipedia lists two forms of the CDF:

Although I get the same answer for both forms of the CDF for this $x$, I get this:

$p-value = Pr(K \geq x) = 1-K_{CDF}(x) = 1-0.794163 = 0.205837$

Why does this $p-value$ not match the one given by the applet (also confirmed with SciPy), 0.147? What have I done wrong?

share|improve this question

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.