ArticleslgStudy

mathematics

Kolmogorov–Smirnov test

Kolmogorov–Smirnov test is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Kolmogorov–Smirnov test rather than just read about it. In short: In statistics, the Kolmogorov–Smirnov test (also K–S test or KS test) is a nonparametric test of the equality of continuous (or discontinuous, see Section 2.2), one-dimensional probability distributions. It can be used to test whether a sample came from a given reference probability distribution (one-sample K–S test), or to test whether or not two samples came from the same distribution (two-sample K–S test).

Kolmogorov–Smirnov test — main illustration
Kolmogorov–Smirnov test — illustration

Key takeaways

  • Kolmogorov–Smirnov test belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Kolmogorov–Smirnov test to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Kolmogorov–Smirnov test from memory before moving on to harder problems.

Reference excerpt

In statistics, the Kolmogorov–Smirnov test (also K–S test or KS test) is a nonparametric test of the equality of continuous (or discontinuous, see Section 2.2), one-dimensional probability distributions. It can be used to test whether a sample came from a given reference probability distribution (one-sample K–S test), or to test whether or not two samples came from the same distribution (two-sample K–S test). It is named after Andrey Kolmogorov and Nikolai Smirnov, who developed it in the 1930s. The Kolmogorov–Smirnov statistic quantifies a distance between the empirical distribution function of the sample and the cumulative distribution function of the reference distribution, or between the empirical distribution functions of two samples. The null distribution of this statistic is calculated under the null hypothesis that the sample is drawn from the reference distribution (in the one-sample case) or that the samples are drawn from the same distribution (in the two-sample case). In the one-sample case, the distribution considered under the null hypothesis may be continuous (see Section 2), purely discrete or mixed (see Section 2.2). In the two-sample case (see Section 3), the distribution considered under the null hypothesis is a continuous distribution but is otherwise unrestricted. The two-sample K–S test is one of the most useful and general nonparametric methods for comparing two samples, as it is sensitive to differences in both location and shape of the empirical cumulative distribution functions of the two samples. The Kolmogorov–Smirnov test can be modified to serve as a goodness of fit test. In the special case of testing for normality of the distribution, samples are standardized and compared with a standard normal distribution. This is equivalent to setting the mean and variance of the reference distribution equal to the sample estimates, and it is known that using these to define the specific reference distribution changes the null distribution of the test statistic (see Test with estimated parameters). Various studies have found that, even in this corrected form, the test is less powerful for testing normality than the Shapiro–Wilk test or Anderson–Darling test. However, these other tests have their own disadvantages. For instance, the Shapiro–Wilk test is known not to work well in samples with many identical values.

One-sample Kolmogorov–Smirnov statistic The empirical distribution function Fn for n independent and identically distributed (i.i.d.) ordered observations Xi is defined as

F n ( x ) = number of (elements in the sample ≤ x ) n = 1 n ∑ i = 1 n 1 ( − ∞ , x ] ( X i ) , {\displaystyle F_{n}(x)={\frac {{\text{number of (elements in the sample}}\leq x)}{n}}={\frac {1}{n}}\sum _{i=1}^{n}1_{(-\infty ,x]}(X_{i}),}

where 1 ( − ∞ , x ] ( X i ) {\displaystyle 1_{(-\infty ,x]}(X_{i})} is the indicator function, equal to 1 if X i ≤ x {\displaystyle X_{i}\leq x} and equal to 0 otherwise. The Kolmogorov–Smirnov statistic for a given cumulative distribution function F(x) is

D n = sup x | F n ( x ) − F ( x ) | {\displaystyle D_{n}=\sup _{x}|F_{n}(x)-F(x)|}

where supx is the supremum of the set of distances. Intuitively, the statistic takes the largest absolute difference between the two distribution functions across all x values. By the Glivenko–Cantelli theorem, if the sample comes from the distribution F(x), then Dn converges to 0 almost surely in the limit when n {\displaystyle n} goes to infinity. Kolmogorov strengthened this result, by effectively providing the rate of this convergence (see Kolmogorov distribution). Donsker's theorem provides a yet stronger result. In practice, the statistic requires a relatively large number of data points (in comparison to other goodness of fit criteria such as the Anderson–Darling test statistic) to properly reject the null hypothesis.

Kolmogorov distribution

The Kolmogorov distribution is the distribution of the random variable

K = sup t ∈ [ 0 , 1 ] | B ( t ) | {\displaystyle K=\sup _{t\in [0,1]}|B(t)|}

where B(t) is the Brownian bridge. The cumulative distribution function of K is given by

… excerpt ends here. Continue reading the full article.

Illustrations

Kolmogorov–Smirnov test: Illustration of the Kolmogorov–Smirnov statistic. The red line is a model CDF, the blue line is an  empirical CDF, and length of the black arrow is the KS statistic.
Illustration of the Kolmogorov–Smirnov statistic. The red line is a model CDF, the blue line is an empirical CDF, and length of the black arrow is the KS statistic.
Kolmogorov–Smirnov test: Illustration of the Kolmogorov distribution's PDF
Illustration of the Kolmogorov distribution's PDF
Kolmogorov–Smirnov test: Illustration of the two-sample Kolmogorov–Smirnov statistic. Red and blue lines each correspond to an empirical distribution function, and the black arrow is the two-sample KS statistic.
Illustration of the two-sample Kolmogorov–Smirnov statistic. Red and blue lines each correspond to an empirical distribution function, and the black arrow is the two-sample KS statistic.

Worked examples

Example 1 — a first encounter with Kolmogorov–Smirnov test

Start with the simplest possible case. Write down what Kolmogorov–Smirnov test claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Kolmogorov–Smirnov test before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Kolmogorov–Smirnov test ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Kolmogorov–Smirnov test

In research
Kolmogorov–Smirnov test appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Kolmogorov–Smirnov test in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Kolmogorov–Smirnov test is common in secondary-school and first-year university syllabi. It links to neighbouring topics Andrey Kolmogorov, Nonparametric statistics, Normality tests, so understanding it makes those chapters shorter.
In everyday life
Look for Kolmogorov–Smirnov test outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Kolmogorov–Smirnov test” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Kolmogorov–Smirnov test in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Kolmogorov–Smirnov test means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Kolmogorov–Smirnov test out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Kolmogorov–Smirnov test in simple terms?

In statistics, the Kolmogorov–Smirnov test (also K–S test or KS test) is a nonparametric test of the equality of continuous (or discontinuous, see Section 2.2), one-dimensional probability distributions. It can be used to test whether a sample came from a given reference probability distribution (o…

Why does Kolmogorov–Smirnov test matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Kolmogorov–Smirnov test?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Kolmogorov–Smirnov test.

Tags

  • Andrey Kolmogorov
  • Nonparametric statistics
  • Normality tests
  • Statistical distance

Keep exploring