How this calculation works
Wasserstein-1 measures how far probability mass must move to turn one one-dimensional empirical distribution into another. For ordered support points, both empirical cumulative distributions are constant between consecutive points. Their absolute difference times that interval’s width gives one contribution to the integral. This page adds all contributions and shows them in a table, with equal observation weights or separately normalized nonnegative weights for each sample.
W₁(P,Q)=∫|F_P(x)−F_Q(x)| dx for empirical distributions on the real line.A worked example
Take X=0,1,3 and Y=1,2,4 with equal weights. The absolute empirical-CDF gaps on intervals [0,1], [1,2], [2,3] and [3,4] are 1/3,1/3,0,1/3. Each interval has width one, so the distance is one. Because these samples have equal sizes, averaging the absolute differences of their sorted paired values also gives (1+1+1)/3=1.
Good to know
Supports up to 200 finite values per sample, with optional weights matching each sample’s length. Each weight vector is normalized separately and must have positive total; zero weights contribute no mass. This is a descriptive one-dimensional distance, not a test p-value or a multidimensional optimal-transport solver. Floating rounding can matter for tiny distances on a very large coordinate scale.
Reference: SciPy — one-dimensional Wasserstein distance (opens in a new tab) ↗
The horizontal scale supplies the units of the answer
A cumulative probability gap has no measurement units, but multiplying it by an interval width restores the units of the observations. If all coordinates change from metres to centimetres, the distance is multiplied by one hundred. Translating both samples by the same offset leaves it unchanged. This helps distinguish transport distance from dimensionless categorical divergences or a maximum vertical CDF gap.
Equal sample sizes are not required. Each empirical distribution carries total probability one, so a longer sample receives smaller equal weights per observation. Supplied observation weights are normalized within their own samples, not pooled across both lists. Duplicated coordinates combine their masses at the same support point. Zero-weight observations may appear in the input but do not alter the represented distribution.
The Jensen–Shannon divergence calculator from probabilities compares aligned category shares. Wasserstein instead uses the numerical distance between support values.
Distribution separation is not a sampling-significance calculation
A distance of one has to be interpreted in the units and scale of the problem. It does not mean a one-percent difference or a one-standard-deviation shift, and it is not the probability that two populations are the same. If the empirical samples are themselves random, uncertainty about the distance requires an additional inferential design. This page does not attach an automatic normal or permutation p-value.
The two-sample Kolmogorov–Smirnov calculator uses the largest vertical empirical-CDF gap. Wasserstein instead accumulates area across the coordinate range, so moving a small mass a long way can have a substantial effect. These measures emphasize different features. Choose the one matching the application rather than treating disagreement between their numerical magnitudes as evidence that one calculation must be wrong.
A few questions, answered
Must the weights sum to one before entry?
No. They are explicit observation weights and are normalized separately within each sample. They must be nonnegative, aligned with observations and have a positive total.
Is Wasserstein distance zero only for identical raw lists?
No. Different raw lists or weights can represent the same empirical probability distribution. In that case the mathematical distance is zero.