Kolmogorov-Smirnov Test Calculator

StatisticsLast updated: August 22, 2026

The Kolmogorov-Smirnov test measures the largest vertical distance between the empirical cumulative distribution function of a sample, Fₙ(x), and the cumulative function F(x) of a theoretical normal distribution. That distance is the D statistic: when it is small the observed distribution tracks the theoretical curve, and when it is large the sample departs systematically from it in some region.

The most common mistake with this test is to estimate the mean and standard deviation from the same sample and then read the classical Kolmogorov table. When the parameters are estimated from the data, D comes out smaller than it should and the classical p-value systematically understates the real departure; the correct reference is the Lilliefors distribution. This calculator computes both p-values, places them side by side, states plainly which one is valid, and reports how many times larger the classical value is.

Enter at least 4 observations. Values may be separated by commas, spaces, or line breaks; both decimal points and decimal commas are accepted (4.2 or 4,2).
If μ and σ are estimated from the same sample, the classical KS p-value is invalid and the Lilliefors correction must be used.
Sets the false positive risk. In the social sciences 5% is the common choice.

Kolmogorov-Smirnov Test Statistic

Fₙ(x) = (number of observations ≤ x) / n              — empirical distribution
F(x)  = Φ( (x − μ) / σ )                              — theoretical distribution
D⁺ = maxᵢ [ i/n − F(x₍ᵢ₎) ]
D⁻ = maxᵢ [ F(x₍ᵢ₎) − (i−1)/n ]
D  = max(D⁺, D⁻) = supₓ |Fₙ(x) − F(x)|
λ  = ( √n + 0.12 + 0.11/√n ) · D
p_classical = Q(λ) = 2·Σ_{j≥1} (−1)^{j−1} · e^{−2j²λ²}
Critical D (classical, α = 0.05):   1.358 / (√n + 0.12 + 0.11/√n)
Critical D (Lilliefors, α = 0.05):  0.895 / (√n − 0.01 + 0.85/√n)
H₀: the data come from the specified normal distribution

When μ and σ are estimated from the same sample, the distribution of D changes, and the classical Q(λ) approximation then makes p look larger than it is. The correct reference is the Lilliefors (Dallal-Wilkinson) distribution — SPSS marks this with the "Lilliefors Significance Correction" footnote, and in R it corresponds to lillie.test() from the nortest package.

How to Calculate

  1. Paste all the values of your numeric variable into the box; at least 4 observations are required.
  2. Choose where the parameters of the theoretical distribution come from: pick "I will specify them" if you know μ and σ (from theory, a standard, or an earlier study), and "Estimate from the data" if you do not.
  3. Set the significance level; the default is α = 0.05.
  4. Read D, D⁺, and D⁻: a large D⁺ means the data pile up to the left of the theoretical curve, and a large D⁻ means they pile up to the right.
  5. Study the classical and Lilliefors p-values together in the comparison table; if the parameters were estimated, report only the Lilliefors row.
  6. Check the point of greatest separation between the two curves in the cumulative distribution chart, and the pattern of departure in the Q-Q plot.

Worked Examples

A right-skewed series where classical p and Lilliefors p diverge (n = 20)

D = 0.2493 (D⁺ = 0.2493; D⁻ = 0.2086), with the largest departure at x = 6.70. The classical Kolmogorov p = 0.141 fails to reject normality, while Lilliefors, the correct reference, rejects it clearly with p = 0.002; the classical approach makes p about 68.4 times larger. The same D value leads to entirely opposite conclusions depending on which reference distribution is used.

D statistic: 0.2493 · D⁺ (empirical curve above): 0.2493 · D⁻ (theoretical curve above): 0.2086

Exam scores that follow a normal distribution (n = 20)

With D = 0.0903, the Lilliefors p = 0.939 and normality cannot be rejected. The Lilliefors critical D (n = 20; α = 0.05) is 0.1924, so the observed D falls well below that threshold. The classical p = 0.995 points the same way, so both approaches agree here — they only diverge for D values close to the threshold.

D statistic: 0.0903 · D⁺ (empirical curve above): 0.0903 · D⁻ (theoretical curve above): 0.0684

Testing the fit to a known N(100; 15) distribution

Because the parameters come from theory, the classical KS is valid: D = 0.3806 with p = 0.004 rejects the hypothesis that the sample comes from N(100; 15.00). The largest departure is D⁻ = 0.3806 at x = 105, showing that the observations have shifted to the right of the theoretical curve. Had the same data been tested with estimated parameters, Lilliefors p = 0.956 would have left normality unrejected: the shape of the distribution is normal, the problem is its location.

D statistic: 0.3806 · D⁺ (empirical curve above): 0.0011 · D⁻ (theoretical curve above): 0.3806

Frequently Asked Questions

What exactly does the Lilliefors correction correct?
The classical Kolmogorov table assumes that the parameters of the theoretical distribution are known INDEPENDENTLY of the data. When μ and σ are computed from the same sample, the theoretical curve is already positioned to fit the data as well as possible, so D shrinks artificially. Lilliefors calibrates the true sampling distribution of D under that condition by Monte Carlo simulation; as a result it returns a far smaller p for the same D value.
Does the KS test in SPSS already include the Lilliefors correction?
Yes. In the "Tests of Normality" table under Analyze → Descriptive Statistics → Explore, the Kolmogorov-Smirnov row carries the footnote "a. Lilliefors Significance Correction" and the reported p is the corrected one. R's built-in ks.test() function does NOT apply any correction; if you feed it parameters estimated from the data you get a misleading p, so use lillie.test() from the nortest package instead.
What does the difference between D⁺ and D⁻ mean?
D⁺ is the largest amount by which the empirical cumulative curve runs ahead of the theoretical one, and it indicates that the data pile up at smaller values than the theoretical distribution predicts. D⁻ indicates the opposite, that the data have shifted toward larger values. A marked imbalance between the two is a sign of a location shift or skewness; roughly equal values point to a departure driven by spread or by the tails.
Should I prefer Kolmogorov-Smirnov or Shapiro-Wilk?
For testing normality, Shapiro-Wilk is more powerful in almost every setting, and modern sources recommend it; using KS as a normality test is largely a historical habit. The real value of KS is that it can test the fit to any continuous distribution (exponential, uniform, Weibull) and that it can compare two samples directly.
Do tied values in the data break the test?
The KS test assumes a continuous distribution. Tied values turn the empirical distribution into a coarser step function and make the true D look smaller; the test becomes conservative, meaning it rejects normality less often than it should. The effect is pronounced with integer-scaled or heavily rounded measurements, and the calculator warns you when it detects ties.
Which should I follow if the critical D and the p-value disagree?
Follow the p-value. The critical D is derived from the asymptotic table coefficients of Stephens (1974), while p comes from the Dallal-Wilkinson regression approximation. Because the two are different approximations to the same distribution, small inconsistencies can appear right at the threshold. When that happens the result is borderline by definition, and it would be wrong to force a firm decision out of a single cutoff.
Is the KS test useful when n is very small?
Around n < 10 the power of the test is very low; even serious departures go undetected, and a verdict of "normality could not be rejected" carries no information. The Lilliefors approximation is also not calibrated for n < 5. With small samples the decision should rest on theoretical knowledge about the process that generated the data and on the Q-Q plot, not on the test.