KS Test PDF
KS Test PDF
Kolmogorov-Smirnov Tests
There are many situations where experimenters need to know what is the dis-
tribution of the population of their interest. For example, if they want to use
a parametric test it is often assumed that the population under investigation
is normal. In this chapter we consider Kolmogorov-Smirnov tests for veri-
fying that a sample comes from a population with some known distribution
and also that two populations have the same distribution.
27
28 CHAPTER 3. KOLMOGOROV-SMIRNOV TESTS
1.0
0.8
u
0.6
U
0.4
0.2
0.0
x_u
-2 0 2 4 6
X
Lemma 3.1
Let X be a continuous r.v. with a c.d.f. F and let U = F (X). Then
Proof
Let u [0, 1]. X is continuous so xu R F (xu ) = u. See Figure (3.1).
find maximum absolute difference between F (u) and the empirical dis-
tribution F (u) for the generated sample
Small Example
Five independent weighings of a standard weight (in gm 106 ) give the
following discrepancies from the supposed true weight:
Calculations:
F(x)
0.617
0.2 d_max
0.617 x
Another random sample of 5 uniform r.vs will give another value dmax . Re-
peating this procedure we simulate a set of values for D5 . Then, having
the approximate null distribution of the test statistic we may calculate the
p value of the observed d0 .
- 0.18 18 ****
0.18 - 0.24 107 *********************
0.24 - 0.30 220 ********************************************
0.30 - 0.36 231 **********************************************
0.36 - 0.42 169 **********************************
0.42 - 0.48 119 ************************
0.48 - 0.54 80 ****************
0.54 - 0.60 35 *******
0.60 - 0.66 16 ***
0.66 - 5 *
This shows that d0 = 0.326 is well in the middle of the distribution and
so the data do not contradict the null hypothesis that the discrepancies are
normally distributed with zero mean and variance equal to one.
3.1. THE ONE-SAMPLE TEST 31
that is
lim P ( nDn x) = Q(x).
n
H0 : F1 (x) 6= F2 (x)
Then we have r
mn
lim P t = Q(t), (3.6)
m,n m+n
where Q(t) is given by (3.4)
Hence, the function Dm,n may serve as a test statistic for our null hypothesis.
It has asymptotic Kolmogorov-Smirnovs distribution.
NOTES
The MWW test is more powerful when H1 is the location shift. The K-S
test has reasonable power against a range of alternative hypotheses.
For small samples we may simulate the null distribution of Dm,n ap-
plying standard uniform distribution U [0, 1].