Chapter 5 The Wasserstein Distance
In this chapter we put a second geometry on the set of Gaussians: the Wasserstein distance, which measures how far apart two distributions are by the cost of transporting mass from one to the other. We mainly use measure-theoretic probability, the Gaussians of Chapter 1 (Definition 1.1), and the Riemannian metrics and distances of Chapter 2. The definition of the Wasserstein distance also appears in Why Pictures Emerge from Noise [KEI26b], but we restate what we need here. In this chapter we show the following.
-
•
A formula for the Wasserstein distance between Gaussians in terms of their means and covariance matrices (Theorem 5.4).
-
•
For , the upper half-plane carries the Euclidean distance (Corollary 5.5).
-
•
The displacement interpolation joining two Gaussians (Proposition 5.7).
-
•
The Riemannian metric derived from the kinetic energy of Gaussians (Definition 5.11).
We do not treat the general theory of optimal transport. The existence of optimal couplings for general probability measures, the fact that satisfies the axioms of a distance, the duality theorem and so on are not proved in this book. They can be found in Takatsu’s book [TAK26] (in Japanese), Villani’s book [VIL03] and Santambrogio’s book [SAN15].
History
The problem of minimising the cost of transporting mass goes back to Monge’s 1781 paper [MON81]. Kantorovich’s 1942 paper [KAN42] belongs to the same line. The formula for between Gaussians (Theorem 5.4) was given independently in 1982 by Dowson and Landau [DL82] and by Olkin and Pukelsheim [OP82]. Givens and Shortt [GS84] also discussed it in 1984.
5.1 Couplings and the Wasserstein Distance
A probability measure on means a probability measure on the Borel -algebra.
Definition 5.1 (Coupling).
Let be probability measures on . A probability measure on whose push-forwards to the first and second factors are and is called a coupling (joint law) of and . Equivalently, a pair of random variables on some probability space with and is also called a coupling; then .
Couplings always exist. For example, the product measure , that is, the pair of independent and , is a coupling. In general there are many couplings, and each specifies how and are tied together.
We write for the set of probability measures on with . For the mean and the covariance matrix are finite. The Gaussian belongs to , with mean and covariance matrix .
Definition 5.2 (Wasserstein distance).
For we put
and call it the Wasserstein distance.
Since depends only on , we may regard the infimum as taken over couplings of and . For the product coupling, , so is finite. By definition, every coupling of and satisfies
| (5.1) |
To compute , it suffices to prove the reverse inequality and find a coupling that attains the infimum. The next section carries this out for Gaussians.
5.2 The Distance Between Gaussians
Let have means and covariance matrices . For a coupling of and , define the cross-covariance matrix
Split . The second term has mean , so the cross term vanishes in expectation when we expand. Also , and . Hence
| (5.2) |
The means and covariance matrices are determined by , so the choice of coupling affects only . Computing thus becomes the problem of maximising .
From now on, for a positive definite symmetric matrix we write for its positive definite symmetric square root and for the inverse of that.
Theorem 5.4 (The Wasserstein distance between Gaussians).
Let and , and put
| (5.3) |
Then is a positive definite symmetric matrix satisfying .
-
1.
Let have means and covariance matrices . Every coupling of and satisfies
with equality if and only if .
-
2.
Let and put . Then , and the coupling attains equality in (1). Consequently
(5.4) and the infimum in Definition 5.2 is attained by this coupling.
For and () we have and . The coupling of (2) stretches about its mean by the factor and then translates it. By (1), an optimal coupling between Gaussians, that is, a coupling attaining equality in (1), has the uniquely determined cross-covariance matrix .
The following proof establishes the properties of , part (2), and part (1) for . The proof of (1) for is given afterwards, marked with ★.
Proof.
First we prove the properties of . Since is positive definite and symmetric, so is . Also .
Next, assuming (1), we prove (2). Since is an affine transformation of the Gaussian , it is Gaussian, with mean and covariance matrix . So is a coupling of and . Since is symmetric,
and equality holds in (1). Then , so by (5.2), equals the right-hand side of (5.4). By (5.1), is at most this value. On the other hand, by (1), is at least this value for every coupling, so is at least this value too. Hence (5.4) holds and the infimum is attained by .
Finally we prove (1) for . Writing , by (5.2) the inequality to be shown is equivalent to . This is nothing but the Cauchy–Schwarz inequality
The equality condition is . Moreover, by the equality condition of the Cauchy–Schwarz inequality, this is equivalent to the existence of a constant with a.s. Comparing the variances of both sides gives . ∎
The last paragraph of this proof also shows that for the coupling attaining equality in (1) is itself unique: equality holds if and only if a.s.
Proof.
We prove (1) for . Put . The covariance matrix of the -valued random variable is
For every , is the variance of , so is positive semidefinite.
Step 1. Put . We show that for all unit vectors . With we have
Step 2. We show . Put ; by the cyclicity of the trace, . Let be a singular value decomposition of , where are orthogonal matrices and , with since is invertible. Write for the th columns of ; these are unit vectors. By Step 1,
On the other hand, , so and . Hence , and (5.2) gives the inequality of (1).
Step 3. We prove the equality condition. As seen in the proof of (2), , so equality holds if . Conversely, suppose equality holds. Since , the inequality of Step 2 forces for all . Put . For unit vectors we have , and are also unit vectors, so by Step 1. Moreover, all diagonal entries of equal . The length of the th column of is . The only vector of length at most whose th component is is , so , that is, . Here gives . Therefore
∎
For , the geometry of the upper half-plane can be read off from Theorem 5.4 at once. We identify the point of with (Definition 1.1).
Corollary 5.5 (The Wasserstein distance for ).
Let . For ,
| (5.5) |
That is, the distance that puts on is the Euclidean distance, with regarded as a point of the Euclidean plane. This distance equals the distance (Definition 2.3) of the Riemannian metric on . The Gaussian curvature of this metric is . The space is not complete.
Proof.
Setting in (5.4) gives , hence (5.5). Next we find the distance of the metric . The length (Definition 2.2) of a piecewise curve satisfies . Since is convex, the segment joining two points lies in , and its length equals the Euclidean distance. Hence the distance is the Euclidean distance. Its Gaussian curvature is , by the formula of Definition 2.18 with . Finally, the sequence is a Cauchy sequence for the Euclidean distance. If it had a limit in , this would equal its limit in the Euclidean plane, contradicting . ∎
This is the second half of the book’s headline claim. The same was, with the Fisher metric, a complete hyperbolic plane of curvature (Theorem 3.12). The lack of completeness becomes clear when we look at where leads.
Example 5.6 (Dirac measures).
Let and let be the probability measure concentrated at . Let have mean and covariance matrix ( may be degenerate). If , then a.s., so the only couplings of and are of the form with . Hence
In particular . For we get , which is the Euclidean distance between and the boundary point . Hence, if we identify with , the correspondence of Corollary 5.5 extends to an isometry from the closed half-plane . As , , so the Gaussians approach a Dirac measure at finite distance.
5.3 Displacement Interpolation
The optimal coupling of Theorem 5.4 gives a curve joining two Gaussians: move each point in a straight line towards .
Proposition 5.7 (Displacement interpolation).
Let and , and let be the matrix of (5.3). Let , and . For put
-
1.
Put and . Then and . For , agrees with the above. Moreover for .
-
2.
Let and . Then with . Moreover for all .
Proof.
We prove (1). We have . As a convex combination of the positive definite symmetric matrices and , is positive definite and symmetric. Hence follows the Gaussian , and is positive definite. The endpoints agree because and by Theorem 5.4 (2). The pair is a coupling of and , and with we have . Since by Theorem 5.4 (2), (5.1) gives
For , the point moves along a segment in at constant speed. This is a geodesic (Definition 2.14) of the metric , because the Christoffel symbols of this metric vanish, so the geodesic equations are .
Remark 5.8.
The inequality of (1) is an equality also for . Indeed, granting the triangle inequality (Remark 5.3, not proved in this book), we have
so all the intermediate inequalities are equalities. Moreover, the curve is a geodesic of the Wasserstein metric of the next section (not proved in this book). See McCann [MCC97] and Takatsu [TAK11].
Figure 5.1 compares the displacement interpolation from to with the mixture of the two densities. The mixture is also a curve joining and , but it reassigns the heights of the peaks without moving any mass. At the values shown in the figure, the mixture has two peaks and so is not Gaussian. The displacement interpolation carries each point along a straight line and stays Gaussian throughout.
5.4 The Wasserstein Metric
By Corollary 5.5, for is the distance of the Riemannian metric . For general too, we would like a Riemannian metric on corresponding to . The clue is kinetic energy. Along a curve of Gaussians, we move the mass at each point by some velocity field, and take the kinetic energy of that field as the squared length of the tangent vector. First we translate the velocity of the covariance matrix into the linear part of the velocity field.
Lemma 5.9 (The matrix equation ).
Diagonalise as ( orthogonal, ), and let be a symmetric matrix. Then there is exactly one matrix satisfying
| (5.6) |
It is symmetric and is given by
Moreover .
Proof.
For a matrix put and . Multiplying (5.6) by on the left and by on the right gives , that is, entrywise. Since , the unique solution is . Since is symmetric, so is , and hence so is . Finally, by the cyclicity of the trace, so
∎
depends linearly on . For and we have . In particular, when moves with velocity , we have , so .
Proposition 5.10 (Kinetic energy of Gaussians).
Let be an open interval and a curve from to . For each , let be the symmetric solution of (Lemma 5.9). Let be the density of , and consider the velocity field on
Then the continuity equation
| (5.7) |
holds for all and . Moreover
| (5.8) |
The continuity equation is the conservation law that a density satisfies when mass flows along a velocity field . Hence gives one way of moving mass that realises the curve .
Proof.
Fix a time and omit the argument . With ,
Using , and , we obtain
On the other hand, and , so
Now substitute . Then . Also , and the scalar equals its transpose , so . Hence
which is (5.7).
Next let and put . Since and ,
∎
The next metric takes the right-hand side of (5.8) as the squared length of the tangent vector . The set is an open subset of (Definition 1.1), and its tangent vectors at each point are .
Definition 5.11 (Wasserstein metric).
For and tangent vectors (), let be the symmetric solution of (Lemma 5.9). We put
and call it the Wasserstein metric.
We check that this is a Riemannian metric (Definition 2.1). Since depends linearly on , is bilinear. Since , it is symmetric. We have , with equality only when , that is, . Hence is positive definite. is the image of under the inverse of the invertible linear map on . The entries of this linear map are linear in the entries of , and the entries of its inverse are ratios of minors. Hence the components of depend smoothly on . Also, by the cyclicity of the trace and transposition, , so
In particular . By Proposition 5.10, this equals the kinetic energy of the velocity field . Note that what enters the part of is , not itself.
Example 5.12 (The Wasserstein metric for ).
Remark 5.13 (Otto’s calculus).
The velocity field is not the only one satisfying the continuity equation (5.7), since we may add to any field with . Among all such fields, has the smallest kinetic energy (not proved in this book). This is the restriction to Gaussians of Otto’s calculus [OTT01], which regards all of formally as a Riemannian manifold. Moreover, also for , the Riemannian distance of equals the square root of the right-hand side of (5.4) (not proved in this book). See Takatsu [TAK11]. For this follows at once from Example 5.12 and Corollary 5.5. Takatsu [TAK11, Proposition A] writes this metric in the form , where are not but correspond to the of Lemma 5.9 for the two tangent vectors.
Remark 5.14 (Curvature for ).
For , is flat (Example 5.12). For the situation is different: the sectional curvature of is nonnegative (not proved in this book). Sectional curvature generalises the two-dimensional Gaussian curvature of Chapter 2 to higher dimensions; this book does not define it. See Takatsu [TAK11, Theorem B]. The only case in which this book shows that Wasserstein geometry is flat is .
Conclusion
The set of one-dimensional Gaussians can be regarded as the upper half-plane with coordinates . Measured with the Fisher metric, is a complete hyperbolic plane of curvature ; measured with the Wasserstein distance, it is a flat (incomplete) half-plane. Chapter 3 proved the first half; this chapter has proved the second (Corollary 5.5). The two geometries differ at the boundary : Dirac measures are infinitely far away for the Fisher metric but at finite distance for (Example 5.6). In Chapter 6 we compare the gradient flows of the same function for the two metrics.
Problems
-
1.
Let and , and for put . Show that .
Hint: Every coupling satisfies .
-
2.
Let be the eigenvalues of . Show that .
Hint: With and in (5.4), .
-
3.
Show that if satisfy , then . Here .
Hint: Commuting symmetric matrices can be diagonalised by the same orthogonal matrix.
-
4.
Let , and . Find the of Lemma 5.9 and show that . Check also that the squared length for the Fisher metric, , is .
Hint: , and the off-diagonal entries of are .
-
5.
Let and consider the of Proposition 5.7. Show that , where is the velocity field of Proposition 5.10 for the curve (extend the curve by the same formula to an open interval on which ).
Hint: Use and .