🧮  Kolmogorov–Smirnov (KS) Test

Kolmogorov–Smirnov (KS) Test#

A test comparing distributions via their largest cumulative gap.

Important

✨ AI-generated content. This page was written with the assistance of an AI language model and is provided as a learning aid. Despite careful review, it may still contain mistakes, omissions, or out-of-date information. Whether you are new to the topic, a team lead, or a senior practitioner, treat it as a starting point rather than an authoritative reference: read it critically and independently verify anything you act on (code, commands, figures, and factual claims) against official documentation and primary sources before relying on it.

What it is#

The KS test is a non-parametric test of whether two samples come from the same distribution (two-sample), or whether a sample matches a reference distribution (goodness-of-fit). It compares their cumulative distribution functions (CDFs).

The statistic#

Its D-statistic is the largest vertical gap between the two CDFs:

\[D = \sup_{x} \,\big|F_1(x) - F_2(x)\big|.\]

A bigger D means the distributions are further apart. Because it uses the CDF directly, it makes no assumptions about the distribution’s shape — its great strength.

Where it’s used#

With a null of “same distribution,” a small p-value flags a significant difference — making the KS test a standard tool for drift detection on continuous features and for goodness-of-fit checks. It underlies the KS statistic used as a drift metric.


Theme: Statistical Inference & Power  ·  All terminology



See also

Source article Adapted (context, re-expressed) in our own words from: Kolmogorov–Smirnov (KS) Test (insightful-data-lab.com).

Tags: purpose: reference topic: terminology level: beginner