Skip to content
Omnikalc

Kolmogorov-Smirnov test calculator: do two samples come from the same distribution?

Enter the sample sizes, the observed maximum distance D and the significance level to get the asymptotic p-value and the critical value of D.

Updated on
Your inputs

Value out of range

Value out of range

Value out of range

Value out of range

Results

p-value (asymptotic)

0.0286

The distributions differ significantly at this level
Effective sample size
22.22
Critical value of D at the chosen level
0.2881
Observed D as a multiple of the critical value
1.04

Do two groups of measurements follow the same distribution, or does a sample fit a theoretical curve? The Kolmogorov-Smirnov test calculator takes the type of test, the sample sizes, the maximum distance D and the significance level, and gives the asymptotic p-value with a verdict, the effective sample size, the critical value of D and the ratio of the observed D to the critical value.

How the calculation works

  • Choose the type of test: one sample compared with a reference distribution, or two samples compared with each other.
  • Enter the sample sizes and the maximum distance D between the two cumulative distribution curves, from your software or your plot.
  • The calculator computes the effective sample size (n for one sample, n₁n₂/(n₁ + n₂) for two) and the critical value D = c(α) / √n, where c(α) = √(−ln(α/2)/2).
  • Read the asymptotic p-value and compare it with the significance level. If D is above the critical value, the p-value is below α and the distributions differ.

Example

Two samples of 50 and 40 points have a maximum distance D = 0.30 between their cumulative curves. The effective sample size is 50 × 40 / 90 = 22.2. At α = 0.05, the critical value is 1.358 / √22.2 = 0.288. The observed D is 1.04 times the critical value, and the p-value is about 0.029, which is below 0.05, so the two distributions differ significantly.

Why it matters

The K-S test is a standard check in data science, quality control and the natural sciences. It tells you whether a model fits data, whether a process has drifted between two periods or whether a new batch behaves like a reference batch, without assuming a normal distribution.

Good to know

The calculator does not compute D from raw data, so you need it from another tool or a plot. The p-value is asymptotic and approximate for very small samples, and it assumes continuous data and a fully specified reference distribution. A significant result says the distributions differ, but not how. Combine the test with a plot of the two curves.

The ANOVA calculator compares group means, the chi-square goodness of fit calculator compares counts with a model, the confidence interval calculator measures uncertainty, and the correlation significance calculator tests a linear link.

Frequently asked questions

What is the Kolmogorov-Smirnov test?

It is a test that compares cumulative distribution curves. The statistic D is the largest vertical gap between two empirical curves, or between one empirical curve and a reference distribution. If D is large compared with what chance gives for that sample size, you reject the idea that the samples come from the same distribution.

What are the advantages of the K-S test?

It makes no assumption about the shape of the distribution, it works on ordered data of any scale, and it is sensitive to differences in location, spread and shape at the same time. It is a good first check of whether a sample fits a normal distribution, or whether two groups behave alike.

What are its limits?

It is most sensitive near the centre of the distributions and less so in the tails. When parameters of the reference distribution are estimated from the same data, the plain p-value is too large, and you need a corrected version such as the Lilliefors test. Ties and discrete data also make the p-value conservative.

How accurate is the p-value here?

The calculator uses the asymptotic series of the Kolmogorov distribution with the Stephens correction on the sample size, which is accurate to a few thousandths for samples above about 10. For very small samples, use exact tables or software. A p-value near the significance level calls for a closer look, not for a firm decision.

Was this calculator helpful?

Thanks for your feedback!

Results are estimates provided for information purposes. They do not replace professional advice.