Wasserstein Distance Calculator (Two Gaussians)
Inputs
- Inputs: first Gaussian mean 0.00, sd 1.00; second Gaussian mean 1.50, sd 1.00.
- For two normal distributions the Wasserstein-2 distance has a closed form: the mean shift of 1.5000 and the spread shift of 0.0000 combine as orthogonal components.
- W2 = sqrt(1.5000^2 + 0.0000^2) = sqrt(2.2500) = 1.5000.
- Wasserstein-2 distance: 1.5000 - the least work needed to reshape one Gaussian into the other, in the distributions' own units.
Most divergences between distributions are abstract numbers. The Wasserstein distance is physical: the minimum work needed to reshape one distribution into the other, moving probability mass across the gap between them. For two normal distributions it has an exact closed form, which this calculator evaluates from the two means and standard deviations.
The result is measured in the data's own units - a distance of 1.5000 means the distributions sit one and a half units apart in the earth-mover sense - which is why the measure has become the default geometry for comparing distributions in machine learning and drift monitoring.
Worked examples
Pure location shift
(0 · 1 · 1.5 · 1)
| Wasserstein-2 distance | 1.5000 |
| Mean shift | 1.5000 |
| Spread shift | 0.0000 |
| Squared distance W2^2 | 2.2500 |
Shift and stretch combined
(10 · 2 · 13 · 4.5)
| Wasserstein-2 distance | 3.9051 |
| Mean shift | 3.0000 |
| Spread shift | 2.5000 |
| Squared distance W2^2 | 15.2500 |
Mostly slide, slight stretch
(50 · 5 · 47 · 5.8)
| Wasserstein-2 distance | 3.1048 |
| Mean shift | 3.0000 |
| Spread shift | 0.8000 |
| Squared distance W2^2 | 9.6400 |
Earth moving for bell curves
Picture each distribution as a pile of earth shaped like a bell. The cheapest way to morph one pile into the other moves mass from where the first has surplus to where the second needs it, paying cost proportional to amount times distance squared. The Wasserstein-2 distance is the square root of that minimum cost.
For Gaussians the optimal plan separates cleanly into two independent jobs: slide the whole pile by the difference in means, and stretch or compress it by the difference in standard deviations. The first worked example is pure sliding - means 0 and 1.50, identical standard deviations of 1 - so the distance is exactly the mean shift, 1.5000, and the spread shift is 0.0000.
Because the two jobs are orthogonal, their costs add as squares: the squared distance is the squared mean shift plus the squared spread shift, a Pythagorean structure visible in every worked example on this page.
- W2 squared = (mean difference) squared + (standard deviation difference) squared, for Gaussians.
- The formula is exact for normals and a lower bound intuition for other shapes.
- Unlike KL divergence, W2 is symmetric and finite even for disjoint distributions.
The closed form and its two components
The second worked example combines both jobs: means 10 and 13 (a shift of 3.0000) and standard deviations 2 and 4.50 (a spread shift of 2.5000). The squared distance is 15.2500, and the distance itself is 3.9051. Neither component dominates; the reshaping is half slide, half stretch.
The third example is mostly slide: a mean shift of 3.0000 with a spread shift of only 0.8000 gives a squared distance of 9.6400 and a distance of 3.1048. Comparing the components across examples tells you how two distributions differ, not just how much - a diagnostic no single scalar divergence provides.
The decomposition is a Gaussian privilege. For general distributions the optimal transport plan mixes location and shape changes, and computing it is a numerical optimisation rather than a formula - which is why the Gaussian case is the workhorse for quick comparisons.
| Example | W2 | Mean shift | Spread shift | W2 squared |
|---|---|---|---|---|
| First | 1.5000 | 1.5000 | 0.0000 | 2.2500 |
| Second | 3.9051 | 3.0000 | 2.5000 | 15.2500 |
| Third | 3.1048 | 3.0000 | 0.8000 | 9.6400 |
Worked examples
Example 1: Mean of the first distribution 0; Std. dev. of the first 1; Mean of the second distribution 1.5; Std. dev. of the second 1. Wasserstein-2 distance = 1.5000. Supporting values: Mean shift 1.5000; Spread shift 0.0000; Squared distance W2^2 2.2500. Inputs: first Gaussian mean 0.00, sd 1.00; second Gaussian mean 1.50, sd 1.00. For two normal distributions the Wasserstein-2 distance has a closed form: the mean shift of 1.5000 and the spread shift of 0.0000 combine as orthogonal components. W2 = sqrt(1.5000^2 + 0.0000^2) = sqrt(2.2500) = 1.5000. Wasserstein-2 distance: 1.5000 - the least work needed to reshape one Gaussian into the other, in the distributions' own units.
Example 2: Mean of the first distribution 10; Std. dev. of the first 2; Mean of the second distribution 13; Std. dev. of the second 4.5. Wasserstein-2 distance = 3.9051. Supporting values: Mean shift 3.0000; Spread shift 2.5000; Squared distance W2^2 15.2500. Inputs: first Gaussian mean 10.00, sd 2.00; second Gaussian mean 13.00, sd 4.50. For two normal distributions the Wasserstein-2 distance has a closed form: the mean shift of 3.0000 and the spread shift of 2.5000 combine as orthogonal components. W2 = sqrt(3.0000^2 + 2.5000^2) = sqrt(15.2500) = 3.9051. Wasserstein-2 distance: 3.9051 - the least work needed to reshape one Gaussian into the other, in the distributions' own units.
Example 3: Mean of the first distribution 50; Std. dev. of the first 5; Mean of the second distribution 47; Std. dev. of the second 5.8. Wasserstein-2 distance = 3.1048. Supporting values: Mean shift 3.0000; Spread shift 0.8000; Squared distance W2^2 9.6400. Inputs: first Gaussian mean 50.00, sd 5.00; second Gaussian mean 47.00, sd 5.80. For two normal distributions the Wasserstein-2 distance has a closed form: the mean shift of 3.0000 and the spread shift of 0.8000 combine as orthogonal components. W2 = sqrt(3.0000^2 + 0.8000^2) = sqrt(9.6400) = 3.1048. Wasserstein-2 distance: 3.1048 - the least work needed to reshape one Gaussian into the other, in the distributions' own units.
Wasserstein against KL divergence
KL divergence answers a coding question - how wasteful is it to encode one distribution using the other - and it behaves accordingly: asymmetric, unbounded, and infinite when the second distribution gives zero probability anywhere the first does not. Two Gaussians with different means always overlap, but for distributions on separated supports KL simply breaks.
Wasserstein keeps its footing in exactly those cases, because moving mass across a gap costs a finite, meaningful amount. The cost is interpretability: a W2 of 3.9051 in the second example is 3.9051 units of the measured quantity, immediately graspable by anyone who knows the scale of the data.
Uses in generative modelling and drift monitoring
Wasserstein GANs replaced the original GAN objective with an earth-mover loss because it keeps giving usable gradients when the generated and real distributions barely overlap - the regime where other divergences saturate. The Gaussian closed form appears inside that literature as the tractable special case used for analysis and for Gaussian mixture components.
In production monitoring, the same formula compares this week's score or measurement distribution against a reference: a rising W2 flags drift, and the mean/spread decomposition says whether the world shifted location or widened. Both readings come from the four numbers this calculator takes.
When the Gaussian form does not apply
Real data with skew, heavy tails or multiple modes is not summarised honestly by a mean and a standard deviation, and the closed form will understate the true transport cost - two distributions can share both moments and still differ. Use the formula for genuinely bell-shaped quantities, or as a fast first pass before a numerical computation.
Enter standard deviations, not variances, and keep both distributions in the same units. A mean shift computed in centimetres against a spread shift in metres produces a squared distance that mixes scales and means nothing.
Choosing between Wasserstein-1 and Wasserstein-2 is choosing a cost function for the transport: W1 charges linearly for distance moved, W2 charges quadratically, so W2 penalises long hauls disproportionately and yields the smoother geometry - and, for Gaussians, the closed form used here. In one dimension W1 has its own elementary form, the average gap between the two quantile functions, which is why it dominates univariate applications like income-distribution comparisons.
The multivariate Gaussian case extends the pattern with a twist: the mean shift still separates, but the spread term becomes a comparison of covariance matrices - the Bures metric - involving their square roots rather than a simple difference of standard deviations. The one-dimensional formula on this page is that geometry flattened to a line. When you use it on summary statistics of real data, you are implicitly accepting the Gaussian picture of both distributions; the number is exact for the picture, and approximate for the world.
The distance also disciplines a common visual habit: judging two distributions by their summary statistics alone. Two Gaussians sharing a mean but differing in spread - means equal, standard deviations 1 and 2, say - are a full unit apart in W2 by the spread term alone, a difference invisible to anyone comparing only averages. Conversely, distributions with different means and spreads can sit closer in transport terms than either difference suggests, because the components combine in quadrature rather than adding. The formula's two-term structure is the antidote to one-number comparisons, which is most of its practical value.
In short: for two normal distributions, bring the two means and the two standard deviations, and take away a distance in the data's own units whose squared value separates cleanly into a location part and a spread part - the rare comparison of distributions that tells you not only how far apart they are, but in which way.
FAQs
What distance does the first example give?
The first example gives a Wasserstein-2 distance of 1.5000 - a pure location shift between two Gaussians of equal spread, so the distance equals the mean shift exactly.
What spread shift does the first example have?
The spread shift is 0.0000 in the first example: both standard deviations are 1, so no stretching is needed and all the transport cost is in the slide.
What distance does the second example give?
The second example gives 3.9051, combining a mean shift of 3.0000 with a spread shift of 2.5000 in quadrature.
What is the squared distance in the second example?
The squared distance is 15.2500 in the second example - the squared mean shift plus the squared spread shift. The calculator reports it because transport costs add in squared form.
What distance does the third example give?
The third example gives 3.1048, driven mostly by its mean shift of 3.0000; the spread shift of 0.8000 adds only a little.
What is the squared distance in the third example?
The squared distance is 9.6400 in the third example: 9 from the mean shift and the remainder from the spread shift of 0.8000.