When two distributions are compared, equal means need not mean they are alike: one may concentrate near the center while the other spreads more toward the ends. The one-dimensional first-order Wasserstein distance offers another comparison: redistribute the probability mass of the first distribution along the number line until it becomes the second; multiply each piece of mass by the distance it travels, sum the costs, and seek the lowest attainable total. Because total mass is 1, that lowest cost is also the lowest average transport distance.[1]
Let random variables X and Y have marginal distributions P and Q. A coupling specifies how X and Y take values jointly while keeping X distributed as P and Y as Q. The one-dimensional first-order Wasserstein distance is written W₁(P,Q)=inf E|X−Y|, where the infimum runs over all such couplings. It measures the lowest average distance attainable under mass conservation, not the mean absolute difference obtained by pairing two arrays in input order.[1]
On the one-dimensional line the same distance has an intuitive computation. If F and G are the cumulative distribution functions of P and Q, then W₁(P,Q)=∫₋∞⁺∞|F(x)−G(x)|dx. That is, at each location compare how much probability each distribution has accumulated up to that point, then integrate the absolute difference along the axis; the area between the two CDFs is the transport distance.[1]
Computing the same example by area and by transport
Construct two discrete distributions: u places mass 0.50, 0.25, and 0.25 at 0, 1, and 3; v places mass 0.25, 0.50, and 0.25 at 0, 2, and 4. Each sums to 1. Pool the support points and look at the CDF difference between neighboring locations.
| Interval | Cumulative mass of u | Cumulative mass of v | Absolute CDF difference | Area |
|---|---|---|---|---|
| [0, 1) | 0.50 | 0.25 | 0.25 | 0.25 |
| [1, 2) | 0.75 | 0.25 | 0.50 | 0.50 |
| [2, 3) | 0.75 | 0.75 | 0 | 0 |
| [3, 4) | 1.00 | 0.75 | 0.25 | 0.25 |
Each interval has length 1, and outside these intervals the CDFs agree, so the areas sum to 0.25+0.50+0+0.25=1. The unit matches that of the support locations.
Now arrange transport from left to right: of the mass at 0, keep 0.25 at 0 and move 0.25 to 2; move the 0.25 at 1 to 2; move the 0.25 at 3 to 4. Each destination receives exactly the mass v requires; the costs are 0, 0.25×2=0.50, 0.25×1=0.25, and 0.25×1=0.25, totaling 1 again. Matching mass in position order on the line yields the lowest cost and equals the CDF area.[1]

Numerical walk-through of constructed weighted discrete distributions: both the absolute CDF-difference area and the monotone transport cost equal 1; the right panel has two distributions with mean 0 but W₁=3. The figure is a schematic drawn for this article.
The distance can also capture differences means miss. For example, take x=[−1,−1,1,1] and y=[−4,−4,4,4], each point with equal weight; both means are 0. Moving the left half of the mass from −1 to −4 and the right half from 1 to 4 gives average distance 0.5×3+0.5×3=3, so W₁=3. The difference here is in spread; W₁ itself only returns a combined distance and cannot, from one number alone, attribute every distributional difference to the same structure.
Giving the distance a statistical reading
The numerical value of W₁ shares the unit of the horizontal axis. If the axis is in centimeters, W₁=1 means a lowest average transport of 1 centimeter; if every coordinate in the example is multiplied by 100, the distance changes from 1 to 100. It is not a probability or a p-value, and it alone cannot prove a difference is significant, that two distributions are equivalent, or that a particular factor caused the difference. Interpreting size requires the variable's dimension and the research question; standardization changes the scale and therefore the reading of the number.
When empirical distributions are computed, the two samples need not be the same size: each observation within a group may receive equal mass, or corresponding nonnegative weights may be used. Weights are normalized separately within each distribution; the input weight totals need only be finite and positive, not already equal to 1.[1] Multiplying all weights of u by 7 and of v by 13 leaves both distributions unchanged after normalization, so the distance remains 1.
If the data come from a weighted histogram, feed each bin's location and its probability mass—not the counts as positions on the axis. If the histogram gives density heights, first multiply height by bin width to obtain mass within the bin. The resulting distance treats the chosen bin locations as representatives of each bin's mass.
In use, first fix the variable and unit to compare, then decide what mass each sample or location represents, and finally interpret W₁ alongside the shapes of the two distributions. The CDF area shows where cumulative mass differs; the transport view gathers those differences into a single distance with the original dimension.
References
- [1] SciPy. “scipy.stats.wasserstein_distance — SciPy v1.18.0 Manual.”