Math calculator

Kolmogorov-Smirnov Test Calculator

Does the data fit?

Test the fit

Thirty values, mean 24.6733 and SD 5.0664 estimated from the sample itself. D is 0.18859. The Kolmogorov p-value is 0.20814 — comfortably normal. The correct p-value, once the fitting is accounted for, is 0.00960: rejected at the 1% level. The critical D drops from 0.2417 to 0.1589. Nothing about the data changed.

30 values · normal · parameters fitted to this sample

D = 0.18859, p = 0.00960

The largest gap between the sample and the fitted curve is 0.18859, at 23.1000. Rejecting at 5% needs D above 0.1589. Ignoring the fitting would give p = 0.20814 and a threshold of 0.2417 — 21.7× too forgiving here.

D statistic

0.18859

critical 0.1589

p-value (fitted)

0.00960

accounts for estimation

p-value (uncorrected)

0.20814

what most tools report

Fitted parameters

24.6733, 5.0664

mean, SD

The sample sits above the curve by at most 0.18859 and below it by at most 0.17815. D is the larger of the two, so the test is driven by whichever side of the distribution is misfitted — and it is least sensitive in the tails, where most departures from normality actually live.

The fit, plotted

00.510.250.50.751fitted cumulative sharesample cumulative share

Where the gap opens

The sample and fitted cumulative shares around the largest gap
ValueSample shareFitted shareGap
22.40000.433330.326820.10651
22.40000.466670.326820.13985
22.90000.500000.363160.13684
23.00000.533330.370590.16274
23.10000.566670.378070.18859
23.90000.600000.439340.16066
24.30000.633330.470630.16270
25.10000.666670.533560.13311
26.50000.700000.640780.05922
Corrects for fitted parameters Exact small-sample p-values One- and two-sample Weakest in the tails

What this tool shows

The shipped preset gives D = 0.18859 with a Kolmogorov p-value of 0.20814 — and a correct p-value of 0.00960. The difference is that the mean and standard deviation were estimated from the same thirty numbers being tested, which most KS calculators ignore. Fitting pulls the curve toward the data, D comes out small, and the standard table stops rejecting things it should. Both p-values are printed here.

  • One-sample KS against a normal, exponential, uniform or log-normal distribution
  • The Lilliefors correction whenever the parameters are fitted, with the uncorrected value shown beside it
  • Exact p-values from the Marsaglia–Tsang–Wang distribution rather than the limiting series
  • Two-sample KS with an exact lattice-path p-value on small samples
  • A P-P plot where the largest departure from the line is literally the statistic
  • The table of values around the largest gap, so you can see where the fit fails
Fitted-parameter correction Exact p-values One and two sample Four distributions

The KS test is weakest exactly where distributions usually fail: the tails.

Updated 13 September 2026 · Works in any browser, no installation

The KS test measures the largest vertical gap between your sample’s cumulative distribution and the one it is supposed to have. That gap is D. It needs no bins, no parameters of its own and no assumption beyond a continuous distribution — which is what makes it popular. The catch is that its published critical values assume the reference distribution was known in advance. Estimate the mean and SD from the sample and those values become badly wrong, in the direction of accepting too much.

At a glance

Formula shown
D = maxᵢ max( i/n − F(x₍ᵢ₎), F(x₍ᵢ₎) − (i−1)/n ) over the sorted sample. Under a fully specified F the null distribution of D is Kolmogorov's, computed here exactly by the Marsaglia–Tsang–Wang matrix method rather than from the limiting series 2Σ(−1)^{k−1}e^{−2k²λ²}. When F's parameters are fitted to the same sample the null is no longer Kolmogorov's: it is Lilliefors', simulated here with the fitting step included, and it is substantially tighter.
Scenario support
Checking whether measurements are normal before a t-test, testing whether wait times are exponential, comparing two samples without assuming any distribution for either, validating a simulation against the distribution it was meant to draw from, and screening data for the wrong distributional family before fitting a model to it.
Educational estimate
Planning support from the values you enter — not professional advice.

p = 0.208 and p = 0.0096 from the same D

This is the single most common error in applied KS testing, and it is silent: nothing warns you, the number just comes out too large.

The shipped preset gives D = 0.18859 on thirty values. Mean 24.6733 and SD 5.0664, both estimated from those same thirty values.

The Kolmogorov p-value is 0.20814. The Lilliefors p-value is 0.00960. One says there is no evidence against normality; the other rejects at the 1% level.

The critical D falls from 0.2417 to 0.1589. Fitting the parameters to the sample drags the curve toward the data, so D is systematically smaller under the null than the standard table expects.

The correction only ever makes the test stricter. On the genuinely-normal preset the uncorrected p is 0.97038 and the corrected one 0.84167 — still nowhere near rejection, which is what a correct test looks like on data that really does fit.

Exact, not asymptotic — and the difference has a direction

The KS p-value is usually computed from a limiting series that is exact only as n goes to infinity. At real sample sizes it errs, and not in the safe direction.

On the two-sample preset — eighteen against eighteen — the exact p is 0.000083 and the limiting formula gives 0.000061. About 27% smaller.

Smaller means more significant, so the approximation over-rejects. It reports more evidence than the data contains.

The exact two-sample p counts lattice paths. Every one of the C(36,18) ways the two samples could interleave is accounted for, which is why the answer is a fraction rather than an approximation.

Ten against ten with no overlap gives p = 2/184756 exactly. Only two of the C(20,10) orderings keep every value of one sample below every value of the other, and the verification suite asserts that fraction rather than a decimal.

The KS test is blind where it matters most

This is the limitation that decides whether KS is the right test at all, and it follows directly from the definition.

D is a gap between two cumulative curves, and both are pinned to 0 and 1 at the ends. Near the tails there is very little room for a gap to open.

So KS is most sensitive near the median and least sensitive in the tails, which is the opposite of where non-normality usually shows up.

Heavy tails, the reason most people check normality in the first place, are what it misses most reliably. An Anderson–Darling test weights the tails explicitly and will usually catch them first.

Use KS when the question is about the middle of the distribution or about a completely wrong family, as in the exponential preset here, where D reaches 0.59353 because the fitted curve puts mass where the data has none.

The two-sample test assumes nothing

Fill in the second column and the test changes character entirely: it stops asking about a distribution and starts asking whether two samples came from the same one.

No parameters are fitted, so no correction is needed. The two-sample null is exact and distribution-free, which is why this is the more trustworthy of the two modes.

It is sensitive to any difference, not just a shift in location. Two samples with identical means and different spreads will separate here where a t-test sees nothing.

Which is also its weakness as a comparison: a significant result tells you the distributions differ and not how, so it belongs before a more specific test rather than instead of one.

Ties reduce its power. The test assumes continuous data; on heavily rounded or discrete values the true p-value is larger than the one reported.

Why the plot is a P-P plot

The chart here puts the fitted cumulative share across and the sample’s up, rather than drawing two staircases against the value axis.

A perfect fit puts every point on the diagonal. There is nothing to interpret: the line is the hypothesis.

And the largest vertical departure from that line is exactly D. The picture is the statistic rather than an illustration of it.

A systematic bow above or below the line is a location or scale mismatch; an S shape is a skewness mismatch, and a pinch at both ends with a bulge in the middle is a tail-weight mismatch.

A Q-Q plot would spread the tails out and compress the middle, which is better for spotting outliers and worse for seeing the quantity this test actually uses.

When to reach for something else

KS is the default goodness-of-fit test and it is rarely the best one available.

For normality specifically, Shapiro–Wilk has more power at almost every sample size. It is built for that one job and the normality test calculator runs it.

For tail behaviour, use Anderson–Darling. It weights the ends of the distribution where KS cannot see.

For discrete or binned data, use a chi-square goodness-of-fit test. KS assumes continuity and is conservative when that fails.

And for the question “is n large enough that normality even matters?”, none of these help. A formal test on 500 observations rejects departures far too small to affect anything you would do next.

Reporting a KS test

Four items, and the second is the one that makes the p-value interpretable at all.

Give D and n. D alone means nothing; the critical value moves with n roughly as 1/√n.

Say whether the parameters were fitted. “KS against a normal with mean and SD estimated from the sample, Lilliefors p” is a complete description; “KS p = 0.21” is not.

Say whether the p-value is exact or asymptotic. They differ by a quarter at eighteen per group, in the anti-conservative direction.

And say what you did with the answer. A goodness-of-fit test is a step in an argument; on its own, failing to reject is not evidence that the distribution is right.

Sources and methodology

References for the KS distribution and the fitted-parameter correction.

Method. The one-sample null distribution is computed exactly by the Marsaglia–Tsang–Wang matrix method rather than from the limiting series, and the suite checks the resulting critical values against the published Kolmogorov–Smirnov table at n = 5, 10, 20, 25 and 30 — all five to three decimals. When the parameters are fitted, the null is instead simulated with the fitting step included, which is Lilliefors’ correction; those critical values are checked against Lilliefors’ own published table at seven sample sizes. That simulation is seeded, so the same input always returns the same p-value, and it uses between 2,500 and 20,000 draws depending on n — which puts a floor under the smallest p-value it can report, and that floor is what you see when a fit fails badly. The two-sample p-value is exact by lattice-path counting whenever n₁·n₂ allows it: the suite asserts that two disjoint samples of ten return exactly 2/184756. It also asserts that D is unchanged by shifting and rescaling a fitted sample, that D is always the larger of its two one-sided halves, and that the exact and limiting p-values converge as n grows. That engine is verified on every change against 157 assertions. The count and the per-case breakdown are published on the formula verification page.

Related calculators

Where this goes next:

Normality TestShapiro-Wilk, Anderson-Darling and Jarque-Bera with a Q-Q plot, plus a resampled sweep answering the question the tests cannot: was your sample size big enough to detect anything?
Chi-SquareGoodness of fit and tests of independence with every expected count and per-cell contribution shown — because the validity condition is about expected counts, not observed ones, and most calculators hide them.
Goodness of FitChi-square with per-cell contributions and standardised residuals, plus a measured answer to the “expected at least 5” rule — below the floor the test is CONSERVATIVE (3.27% at 2 per cell), not liberal.
Benford's LawLeading-digit frequencies against Benford's law with MAD conformity bands, a chi-square test and per-digit z scores.
Mann-Whitney UMann-Whitney U with the tie correction and both medians shown, because it is not a test of medians — two samples with identical medians of 4 are separated at p = 0.01.
t-testOne-sample, two-sample and paired t-tests defaulting to Welch, with Student's pooled version printed beside it — and a warning when the two disagree on the verdict.

More in Math, or browse all calculators.

Educational use disclaimer

An educational tool. The KS test is least sensitive in the tails, which is where departures from normality usually matter, so failing to reject is weak evidence that a distribution fits. It also assumes continuous data: on rounded or discrete values the reported p-value is smaller than the true one. The fitted-parameter p-values are simulated, with a floor set by the number of draws.

How we calculate · Found an error? email us

Authorship & verification

Written and maintained by , a business operator who builds spreadsheet-based calculators.

What's changed (5 updates)

Published 13 September 2026

  1. Launched the KS test with the exact Marsaglia-Tsang-Wang null distribution rather than the limiting series.
  2. Applied the Lilliefors correction whenever the parameters are fitted, and printed the uncorrected p-value beside it: the shipped preset gives 0.00960 against 0.20814 from the same D of 0.18859.
  3. Checked the exact critical values against the published KS table at five sample sizes and the fitted-parameter ones against Lilliefors at seven.
  4. Added an exact two-sample p-value by lattice-path counting; two disjoint samples of ten return exactly 2/184756.
  5. Plotted the fit as a P-P plot, where the largest departure from the diagonal is the statistic itself rather than an illustration of it.

Add this calculator to your site

Responsive embed — and private: nothing your visitors type leaves their browser.