Skip to content

Kolmogorov–Smirnov Test Calculator

Paste a sample to test it against a normal, uniform, or exponential distribution — or paste two samples to test whether they come from the same distribution. You get the KS statistic D, an exact p-value (limiting distribution for large samples), the point where the gap is largest, and an empirical CDF plot you can download. A built-in warning and a Lilliefors p-value cover the case where parameters are estimated from the data. Free, no sign-up.

Test

0 values

Enter at least one value and the parameters of the distribution.

How to Use the Kolmogorov–Smirnov Test Calculator

  1. 1. Choose the test. Pick One sample to compare your data with a named distribution, or Two samples to compare two data sets with each other.
  2. 2. Enter the data. Paste numbers separated by commas, spaces, or new lines. For a one-sample test, choose the distribution and enter its parameters, or let the calculator estimate them from the sample (read the caveat below first).
  3. 3. Pick the alternative. Two-sided asks whether the distributions differ in any way. The one-sided choices test whether one CDF lies above the other.
  4. 4. Read D and p. D is the largest vertical gap between the two cumulative curves, and the plot marks where it occurs. Copy the APA line when you are done.

What the KS Statistic Measures

The empirical CDF F̂(x) is the share of the sample at or below x; it rises in steps of 1/n. The Kolmogorov–Smirnov statistic is the largest vertical distance between two cumulative curves. In the one-sample test it is D = max |F̂(x) − F(x)| against the hypothesised CDF F, computed from D⁺ = max(i/n − F(xᵢ)) and D⁻ = max(F(xᵢ) − (i − 1)/n). In the two-sample test it is D = max |F̂₁(x) − F̂₂(x)| over the pooled values. Because D uses only the cumulative curves, the test is sensitive to differences in location, spread, and shape at once — and it makes no assumption about the form of the data's distribution under the null.

The p-value is the probability of a gap at least as large as D if the distributions were the same. The calculator uses the exact distribution: Marsaglia, Tsang, and Wang's algorithm for the one-sample case (as in R) up to n = 500, and a lattice-path count for two samples that handles tied values correctly. Beyond those sizes it uses the limiting Kolmogorov distribution with λ = √n × D.

The Estimated-Parameters Trap

The standard KS p-value assumes the reference distribution is fully specified before you look at the data. If you estimate the mean and standard deviation from the same sample and then test normality, the fitted curve sits closer to the data than any pre-specified curve would, D is too small, and the p-value is too large — the test almost never rejects. The Lilliefors test corrects for this for the normal distribution; the calculator shows its p-value (an analytic approximation accurate to about 0.01) when you choose to estimate the parameters. For uniform and exponential distributions, the calculator warns you instead. If your real goal is to test normality, the Shapiro-Wilk test is usually more powerful.

Worked Example

Click Try an example to load 25 standardised scores to test against a standard normal distribution, and two samples of 8 and 10 values for the two-sample test.

One-sample KS test against N(0, 1)

D⁺ = 0.0382 and D⁻ = 0.1741, so D = 0.1741 at x = 0.29

There the empirical CDF is 0.44 (just below) while Φ(0.29) = 0.614

Exact p-value (n = 25) = .390 → no evidence the scores depart from N(0, 1)

Estimating μ = 0.216 and σ = 1.112 instead: D = 0.0864; the ordinary p = .984 is far too high, the approximate Lilliefors p is about .90

In APA style: a one-sample Kolmogorov–Smirnov test did not reject a standard normal distribution, D(25) = .17, p = .390. For the two samples (8 and 10 values) the largest gap is D = .60 at x = 8.8, where the first sample's CDF has reached 1 and the second's is only 0.4; the exact two-sample p-value is .050, on the edge of significance at α = .05.

Choosing Between Distribution Tests

QuestionBetter choice
Is a sample consistent with a fully specified distribution?One-sample KS
Is a sample normal, with the mean and SD unknown?Shapiro-Wilk, or Lilliefors
Do two samples come from the same distribution?Two-sample KS
Do two samples differ in location only?Mann-Whitney U test, which is more powerful for shifts
Categorical or binned data against expected counts?Chi-square goodness of fit

Frequently Asked Questions

What does the Kolmogorov–Smirnov test tell you?
It tests whether a sample comes from a specified distribution (one-sample) or whether two samples come from the same distribution (two-sample). A small p-value means the cumulative curves are further apart than chance would allow. It does not say how the distributions differ — location, spread, or shape — only that they do.
Can I use the KS test to check for normality?
Only if you specify the mean and standard deviation in advance. With parameters estimated from the sample, the ordinary p-value is too large. Use the Lilliefors correction (shown when you estimate parameters) or, better, the Shapiro-Wilk test, which has more power against typical departures from normality.
What is a good p-value for the KS test?
There is no "good" value. If you want to show the data fit a distribution, a p-value above your α only means the test found no evidence against the fit — it is not proof of a fit, especially in small samples where the test has little power. If you want to show a difference, you need p below α.
How do I report a Kolmogorov–Smirnov test in APA style?
Name the test and the reference distribution, then give D, the sample size, and p: D(25) = .17, p = .390. For two samples report both sizes: D = .60, n₁ = 8, n₂ = 10, p = .050. Drop the leading zero from D and p, and say whether p is exact.
How do ties affect the test?
The KS test is designed for continuous data, where ties have probability zero. With ties the one-sample p-value is conservative, meaning it is larger than it should be. For two samples this calculator computes the exact p-value conditional on the tied values, as R does, so the result stays valid.
When should I use a two-sample KS test instead of a Mann-Whitney test?
Use the KS test when you care about any difference between the distributions, including spread and shape. Use Mann-Whitney when the question is about location (one group tends to have larger values), since it has more power for that. The two tests can disagree when the distributions have the same centre but different spreads.

Related Tools

More in Statistics Calculators

See all Statistics Calculators