How to use the kolmogorov-smirnov test calculator
- Choose One sample vs a model or Two samples.
- For one sample, choose the model (normal, uniform or exponential) and enter its parameters. For two samples, enter both lists.
- Paste each sample as numbers separated by commas, spaces or new lines.
- Read the D statistic, which is the largest gap between the two cumulative curves, and the asymptotic p value.
Formula
D = the largest vertical distance between the empirical cumulative distribution and the model (or the other sample)
One sample scaled statistic: (sqrt(n) + 0.12 + 0.11 / sqrt(n)) x D
Two sample effective size: n x m / (n + m)
p value = 2 x sum over j of (-1)^(j-1) x exp(-2 j^2 x scaled statistic^2)
The series is the Kolmogorov distribution. The scaled statistic uses a small sample correction, so the p value is better than the bare asymptotic form at modest sample sizes. It remains an approximation.
Ten values against a normal model
The ten values 3.1, 4.2, 4.8, 5.5, 6.1, 6.7, 7.3, 8.0, 4.4 and 5.9 are compared with a normal distribution with mean 5 and standard deviation 2. The largest gap between the sample curve and the model is D = 0.244578. The scaled statistic is 0.811281 and the p value is 0.5259, so there is no evidence against the model.
For two completely separated samples, 1 to 5 and 6 to 10, the largest gap is D = 1 and the p value is 0.0037814 with an effective sample size of 2.5.
What the test checks
The test looks at the whole shape of a distribution, not just its mean or spread. A small p value says the sample and the model, or the two samples, are unlikely to come from the same distribution. A large p value only says that this test found no clear gap, which is weaker evidence when the sample is small.
If your question is only whether data are normal, the Shapiro-Wilk test is usually more powerful. To see how a sample departs from normal in shape, use the skew and kurtosis calculator.
Parameters from the same data
The one sample test assumes the model is fully specified before you look at the data. If you estimate the mean and standard deviation from the same sample, the p value is too large and the test is too forgiving. A Lilliefors style correction is needed for that case, and this page does not apply one.
For counts in categories, the chi-square calculator is the usual goodness of fit tool.
Assumptions and limits
- Observations are independent and come from a continuous distribution. Many tied values weaken the test.
- Model parameters are chosen in advance and not estimated from the same sample.
- The p value is asymptotic with a small sample correction, so treat it as approximate for very small samples.
- The exponential model uses the rate you enter, and the uniform model uses the low and high ends.
Frequently asked questions
What does the D statistic mean?
It is the biggest vertical distance between two cumulative curves, on a scale from 0 to 1. A value near 0 means the curves nearly coincide and a value near 1 means they are far apart.
Can I compare two samples without a model?
Yes. Choose Two samples and enter both lists. The test asks whether they could share one distribution.
Is it valid for small samples?
The p value is approximate for small samples. Use it as a guide, and for very small samples prefer a table of exact critical values.
How does it differ from a t test?
A t test compares means. This test is sensitive to any difference in the distribution, including spread and shape, but it is less powerful for a pure shift in the mean.