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.