Kolmogorov-Smirnov test
Goodness of fit and normality · reference distribution: D (Kolmogorov)
When to use it
Compare a sample with a fully specified theoretical distribution.
Null hypothesis
The data follow the distribution F₀.
Assumptions
- F₀ continuous, with parameters known in advance
Test statistic
D = \sup_x \left| F_n(x) - F_0(x) \right|How to report it
D = 0.12, p = .43
In R and Python
R
ks.test(x, "pnorm", mean = 0, sd = 1)
Python
stats.kstest(x, "norm", args=(0, 1))
In Python, stats is scipy.stats and np is numpy.
Variants and alternatives
- Lilliefors, when the parameters are estimated from the data
- Two-sample version, which compares the two empirical distributions: D = sup |F₁(x) − F₂(x)|
Where it sits in the catalog
Goodness of fit and normality. Goodness of fit: do the data follow the expected distribution? Normality tests are the most common case and check an assumption of parametric tests.
In the decision tree
- What do you want to do? Check an assumption or the distribution of the data
- What do you want to check? Whether the data follow another continuous distribution
- Are the parameters of the distribution known in advance? Yes