Statistical Methods

Locate the Largest Gap Between Two Empirical Distributions

Define the task

The two-sample Kolmogorov–Smirnov statistic is the largest vertical separation between empirical cumulative distribution functions. It addresses an entire distribution rather than only its mean or median. Record the measurement, units, sample sizes and whether samples are independent. The local tool reports descriptive D and the signed difference at its first maximizing coordinate. It deliberately does not calculate a p-value: continuous-distribution reference assumptions may be inappropriate for tied, discrete or dependent observations.

Carry out the check

Sort pooled observed coordinates. At each coordinate, count the fraction in each sample less than or equal to it, then compare the fractions. Keep tied values together and normalize each sample by its own size. The statistic lies between zero and one and has no measurement units. Several coordinates may share the same maximum; the displayed location is not necessarily unique. A change in shape, spread or center can produce a gap. Do not interpret its location as a prespecified clinical threshold or proof of a causal effect.

Worked hypothetical example

For hypothetical A=(0,1) and B=(1,2), the CDF difference is 0.5 at 0 and 0.5 at 1, then zero at 2. Thus D=0.5 and the first maximizing coordinate is 0. Swapping the samples preserves D but reverses the sign. Identical samples give D=0 and no meaningful gap location. Compare this unitless vertical gap with a distance measured along the measurement axis before selecting a distribution-comparison summary.

Method checked 18 November 2026 against Primary method documentation: ks_2samp.

Open the maximum empirical cdf gap.

Download the cdf gap audit worksheet.

Related reading

Reading path: Analyze data. Guide 164 of 172. Choose any guide to suit your project.

Statistical Methods

Choose Between a Mean and a Median by the Question

Distinguish average burden from a typical observation before reacting to skewed data.

Statistical Methods

Compare Reported Standard Errors with Empirical Simulation Variation

Use between-replicate spread to assess whether model-based uncertainty is calibrated.

Browse this reading pathTools for this stageGuides and downloads for this stage