Comparing Distributions
Comparing distributions means quantifying how similar or different two probability distributions are, using graphical tools (Q–Q plots, ECDF overlays), summary-statistic comparisons (mean, variance, quantiles), formal hypothesis tests (two-sample t, Kolmogorov–Smirnov, Mann–Whitney), and distance/divergence measures (total variation, KL divergence, Wasserstein). Key result: different tools answer different questions — "are these the same distribution?" vs. "are their means equal?" vs. "how far apart are they?" — and choosing the wrong one is the central practical error. Applies across statistics, machine learning, econometrics, and the experimental sciences. Foundational figures: Kolmogorov, Smirnov, Mann, Whitney, and Wasserstein (1969 metric).
There is no single "distance" between distributions — there is a toolbox, and each tool privileges a different feature. Mean comparisons ask about the first moment; variance comparisons about the second; the Kolmogorov–Smirnov statistic about the largest vertical gap between cumulative distribution functions (CDFs); KL divergence about information loss; Wasserstein distance about the physical cost of moving probability mass. The art of comparing distributions is matching the question ("equal centers?" "same shape?" "indistinguishable laws?") to the right instrument, while respecting whether your data are paired or independent, continuous or discrete, and how heavy the tails are.
Formal Statement
Let and be random variables with cumulative distribution functions and . We have independent samples from and from .
Two distributions are equal, written , if their CDFs agree everywhere:
Derivation hint: the CDF uniquely determines a probability law on , so equality of CDFs is equivalent to equality of distributions; this is the strongest sense in which two distributions can "be the same."
The ECDF of a sample estimates the true CDF by the fraction of observations at or below each point:
where is the indicator function (1 if true, 0 if false). Derivation hint: is an average of i.i.d. Bernoulli indicators, so by the law of large numbers ; uniform convergence is the Glivenko–Cantelli theorem.
The two-sample KS statistic is the supremum (largest) vertical distance between the two ECDFs:
Derivation hint: because both ECDFs are step functions that jump only at observed data points, the supremum is attained at one of the sample values, making computable by scanning the pooled sorted data.
For distributions with densities and (or PMFs), the total variation distance is
where the supremum runs over all measurable events . Derivation hint: the optimal event is ; substituting and using over the whole space yields the form.
The KL divergence from to measures expected information lost when is used to approximate :
Derivation hint: nonnegativity follows from Jensen's inequality applied to the convex function , since .
The -Wasserstein distance is the minimal cost of transporting mass from to :
where is the set of joint distributions (couplings) with marginals and . Derivation hint: for on , the optimal coupling matches quantiles, giving the closed form .
The ECDF converges uniformly to the true CDF almost surely:
Derivation hint: pointwise a.s. convergence from the SLLN plus monotonicity of CDFs lets a finite grid control the whole real line; refining the grid drives the uniform error to zero.
Under (continuous), the scaled KS statistic has a distribution-free limit:
Derivation hint: the empirical process converges to a Brownian bridge whose supremum has the Kolmogorov distribution; the result is distribution-free because the time-change removes dependence on .
Why It Holds / Derivation
Claim: Under with continuous, the null distribution of does not depend on the underlying . 1. Probability integral transform. If with continuous, then is Uniform. Apply to every observation in both samples. 2. ECDFs transform consistently. Since is monotone increasing, . Writing and , the indicator equals . 3. The supremum is invariant. As ranges over , ranges over , so
where the right side uses ECDFs of the transformed uniform samples. 4. Conclusion. Under both transformed samples are i.i.d. Uniform, irrespective of the original . Hence the distribution of depends only on and — not on .
∎1. Write where . 2. The function is convex on . 3. By Jensen's inequality, . 4. Compute the inner expectation: . 5. Therefore , with equality iff a.e., i.e. .
∎Kolmogorov axiomatized probability theory in 1933 and, the same year, introduced the goodness-of-fit statistic that compares an ECDF to a hypothesized CDF via their maximal gap. His insight that this gap's limiting distribution is governed by the Brownian bridge — and is free of the underlying distribution — made distribution comparison rigorous and universal. Nikolai Smirnov extended the idea to the two-sample case in 1939, giving the tool used to this day for asking "do these two samples come from the same law?"
Building Intuition
Picture each distribution as a pile of sand on a number line. Comparing means asks only where the balance point of each pile sits — you could shovel sand around wildly without moving it. Comparing variances asks how spread out each pile is. The KS statistic stacks the sand into a running cumulative wall and asks: what is the biggest height difference between the two walls anywhere? Wasserstein distance asks the most physical question of all: if I literally had to shovel one pile into the shape of the other, what is the minimum total "dirt × distance" work? Notice these can disagree dramatically: two piles with the same balance point can have a huge KS gap (different shapes), and two piles a KS test calls "barely different" can be far apart in Wasserstein if the difference lives in the tails. The choice of tool is a choice of what "different" means.
Worked Examples
Given: A new fertilizer (group A) and control (group B). Yields (kg/plot): A: , mean , sd . B: , mean , sd .
Goal: Test at (two-sided), assuming equal variances.
Step 1 — Pooled variance.
Step 2 — Standard error.
Step 3 — t-statistic.
Step 4 — Critical value. With , .
Step 5 — Decision. Since , we fail to reject .
Given: Two small samples (sorted). A: (). B: ().
Goal: Test using .
Step 1 — Build ECDFs over the pooled sorted points . Each step is .
| 1 | 0.25 | 0.00 | 0.25 |
| 2 | 0.50 | 0.00 | 0.50 |
| 3 | 0.50 | 0.25 | 0.25 |
| 4 | 0.75 | 0.25 | 0.50 |
| 5 | 0.75 | 0.50 | 0.25 |
| 6 | 0.75 | 0.75 | 0.00 |
| 7 | 1.00 | 0.75 | 0.25 |
| 8 | 1.00 | 1.00 | 0.00 |
Step 2 — Maximum gap. (attained at and ).
Step 3 — Critical value. For at , the exact critical value is .
Step 4 — Decision. Since , we fail to reject .
Common Misconceptions
Equal means do NOT imply equal distributions. A two-sample t-test that "finds no difference" tests only the first moment. Two groups can have identical means and still differ wildly in variance, skew, or modality. Always ask which feature your test is sensitive to before declaring distributions "the same."
A non-significant test is not evidence of equality. Failing to reject means you lacked power to detect a difference, not that the distributions match. With small samples (as in the KS example above), the test can miss even large real differences. "Absence of evidence is not evidence of absence."
KL divergence is not a distance. It is asymmetric, , fails the triangle inequality, and blows up to whenever assigns zero probability where does not. Do not use it as if it were a metric — use TV or Wasserstein for that.
Identical mean and variance, totally different shape. Let and let be the two-point mixture placing mass at and at . Both have mean and variance . A t-test and an F-test (variance test) both report "no difference." Yet is discrete and bimodal while is unimodal continuous — a KS or Wasserstein comparison detects a large gap. Moment-matching can perfectly disguise a structural difference.
Connections
Comparing distributions sits at the crossroads of several areas. The KS test rests on the Empirical Distribution Function and its convergence (Glivenko–Cantelli), while its limiting law is governed by the Brownian Bridge from stochastic processes. Mean comparisons descend from the Central Limit Theorem and Hypothesis Testing. Divergence measures like KL connect to Information Theory (entropy, cross-entropy) and to Maximum Likelihood Estimation, where minimizing KL to the empirical distribution is maximizing likelihood. Wasserstein distance links to Optimal Transport and underlies modern generative modeling. Rank-based comparisons (Mann–Whitney) belong to Nonparametric Statistics.
Real-World Applications
Historical Development
Subtleties & Limits
Several deep issues remain practically and theoretically active. (1) High-dimensional comparison: the KS test has no canonical multivariate generalization, and estimating Wasserstein or KL distances in high dimensions suffers a curse of dimensionality (sample requirements grow exponentially). Entropic regularization (Sinkhorn distances) and kernel methods (Maximum Mean Discrepancy) are partial answers, but optimal sample complexity is still studied. (2) Calibrated equivalence testing: standard tests are built to detect differences, not to certify similarity; rigorous "two one-sided test" (TOST) equivalence frameworks exist but choosing the equivalence margin remains a modeling judgment. (3) Distribution-free guarantees under dependence: most theory assumes i.i.d. data, yet real time-series and networked data violate this, and the limiting distributions of comparison statistics under general dependence are incompletely characterized.
See Also
Empirical Distribution Function · Hypothesis Testing · Kolmogorov–Smirnov Test · Mann–Whitney U Test · Optimal Transport · Information Theory · Brownian Bridge · Goodness-of-Fit Testing · Central Limit Theorem