Wasserstein metric
   HOME

TheInfoList



OR:

In mathematics, the Wasserstein distance or
Kantorovich Leonid Vitalyevich Kantorovich ( rus, Леони́д Вита́льевич Канторо́вич, , p=lʲɪɐˈnʲit vʲɪˈtalʲjɪvʲɪtɕ kəntɐˈrovʲɪtɕ, a=Ru-Leonid_Vitaliyevich_Kantorovich.ogg; 19 January 19127 April 1986) was a Soviet ...
Rubinstein metric is a
distance function In mathematics, a metric space is a set together with a notion of ''distance'' between its elements, usually called points. The distance is measured by a function called a metric or distance function. Metric spaces are the most general setting ...
defined between Probability distribution, probability distributions on a given metric space M. It is named after Leonid Vaserstein, Leonid Vaseršteĭn. Intuitively, if each distribution is viewed as a unit amount of earth (soil) piled on ''M'', the metric is the minimum "cost" of turning one pile into the other, which is assumed to be the amount of earth that needs to be moved times the mean distance it has to be moved. This problem was first formalised by Gaspard Monge in 1781. Because of this analogy, the metric is known in computer science as the earth mover's distance. The name "Wasserstein distance" was coined by Roland Dobrushin, R. L. Dobrushin in 1970, after learning of it in the work of Leonid Vaserstein, Leonid Vaseršteĭn on Markov processes describing large systems of automata (Russian, 1969). However the metric was first defined by Leonid Kantorovich in ''The Mathematical Method of Production Planning and Organization'' (Russian original 1939) in the context of optimal transport planning of goods and materials. Some scholars thus encourage use of the terms "Kantorovich metric" and "Kantorovich distance". Most English language, English-language publications use the German language, German spelling "Wasserstein" (attributed to the name "Vaseršteĭn" being of Germanic languages, German origin).


Definition

Let (M,d) be a metric space that is a Polish_space#Radon_spaces, Radon space. For p \in [1, \infty), the Wasserstein p-distance between two probability measures \mu and \nu on M with finite p-Moment (mathematics), moments is :W_p(\mu, \nu) = \left( \inf_ \mathbf_ d(x, y)^p \right)^ where \Gamma(\mu, \nu) is the set of all coupling (probability), couplings of \mu and \nu. A coupling \gamma is a joint probability measure on M \times M whose marginal distribution, marginals are \mu and \nu on the first and second factors, respectively. That is, :\int_M \gamma(x, y) \,\mathrmy = \mu(x) :\int_M \gamma(x, y) \,\mathrmx = \nu(y)


Intuition and connection to optimal transport

One way to understand the above definition is to consider the optimal transport problem. That is, for a distribution of mass \mu(x) on a space X, we wish to transport the mass in such a way that it is transformed into the distribution \nu(x) on the same space; transforming the 'pile of earth' \mu to the pile \nu. This problem only makes sense if the pile to be created has the same mass as the pile to be moved; therefore without loss of generality assume that \mu and \nu are probability distributions containing a total mass of 1. Assume also that there is given some cost function :c(x,y) \geq 0 that gives the cost of transporting a unit mass from the point x to the point y. A transport plan to move \mu into \nu can be described by a function \gamma(x,y) which gives the amount of mass to move from x to y. You can imagine the task as the need to move a pile of earth of shape \mu to the hole in the ground of shape \nu such that at the end, both the pile of earth and the hole in the ground completely vanish. In order for this plan to be meaningful, it must satisfy the following properties : \begin \int \gamma(x,y) \,\mathrm y = \mu(x) & \qquad \text x \text \\ \int \gamma(x,y) \,\mathrm x = \nu(y) & \qquad \text y \text \end That is, that the total mass moved ''out of'' an infinitesimal region around x must be equal to \mu(x) \mathrmx and the total mass moved ''into'' a region around y must be \nu(y)\mathrmy. This is equivalent to the requirement that \gamma be a joint probability distribution with marginals \mu and \nu. Thus, the infinitesimal mass transported from x to y is \gamma(x,y) \, \mathrm x \, \mathrm y, and the cost of moving is c(x,y) \gamma(x,y) \, \mathrm x \, \mathrm y, following the definition of the cost function. Therefore, the total cost of a transport plan \gamma is : \iint c(x,y) \gamma(x,y) \, \mathrm x \, \mathrm y = \int c(x,y) \, \mathrm \gamma(x,y) The plan \gamma is not unique; the optimal transport plan is the plan with the minimal cost out of all possible transport plans. As mentioned, the requirement for a plan to be valid is that it is a joint distribution with marginals \mu and \nu; letting \Gamma denote the set of all such measures as in the first section, the cost of the optimal plan is : C = \inf_ \int c(x,y) \, \mathrm \gamma(x,y) If the cost of a move is simply the distance between the two points, then the optimal cost is identical to the definition of the W_1 distance.


Examples


Point masses (degenerate distributions)

Let \mu_ = \delta_ and \mu_ = \delta_ be two degenerate distributions (i.e. Dirac delta distributions) located at points a_ and a_ in \mathbb. There is only one possible coupling of these two measures, namely the point mass \delta_ located at (a_, a_) \in \mathbb^. Thus, using the usual absolute value function as the distance function on \mathbb, for any p \geq 1, the p-Wasserstein distance between \mu_ and \mu_2 is :W_p (\mu_1, \mu_2) = , a_1 - a_2 , . By similar reasoning, if \mu_ = \delta_ and \mu_ = \delta_ are point masses located at points a_ and a_ in \mathbb^, and we use the usual Euclidean norm on \mathbb^ as the distance function, then :W_p (\mu_1, \mu_2) = \, a_1 - a_2 \, _2 .


Normal distributions

Let \mu_1 = \mathcal(m_1, C_1) and \mu_2 = \mathcal(m_2, C_2) be two non-degenerate Gaussian measures (i.e. normal distributions) on \mathbb^n, with respective expected values m_1 and m_2 \in \mathbb^n and symmetric positive definite, symmetric positive semi-definite covariance matrix, covariance matrices C_ and C_2 \in \mathbb^. Then, with respect to the usual Euclidean norm on \mathbb^, the 2-Wasserstein distance between \mu_ and \mu_ is :W_ (\mu_1, \mu_2)^2 = \, m_1 - m_2 \, _2^2 + \mathop \bigl( C_1 + C_2 - 2 \bigl( C_2^ C_1 C_2^ \bigr)^ \bigr) . This result generalises the earlier example of the Wasserstein distance between two point masses (at least in the case p = 2), since a point mass can be regarded as a normal distribution with covariance matrix equal to zero, in which case the trace (linear algebra), trace term disappears and only the term involving the Euclidean distance between the means remains.


One-dimensional distributions

Let \mu_1, \mu_2 \in P_p(\mathbb) be probability measures on \mathbb, and denote their cumulative distribution function, cumulative distribution functions by F_1(x) and F_2(x). Then the transport problem has an analytic solution: Optimal transport preserves the order of probability mass elements, so the mass at quantile q of \mu_1 moves to quantile q of \mu_2. Thus, the p-Wasserstein distance between \mu_1 and \mu_2 is :W_p(\mu_1, \mu_2) = \left(\int_0^1 \left, F_1^(q) - F_2^(q) \^p \, \mathrm q\right)^ where F_1^ and F_2^ are the quantile function, quantile functions (inverse CDFs). In the case of p=1, a change of variables leads to the formula :W_1(\mu_1, \mu_2) = \int_ \left, F_1(x) - F_2(x) \ \, \mathrm x .


Applications

The Wasserstein metric is a natural way to compare the probability distributions of two variables ''X'' and ''Y'', where one variable is derived from the other by small, non-uniform perturbations (random or deterministic). In computer science, for example, the metric ''W''1 is widely used to compare discrete distributions, ''e.g.'' the color histograms of two digital images; see earth mover's distance for more details. In their paper 'Wasserstein GAN', Arjovsky et al. use the Wasserstein-1 metric as a way to improve the original framework of Generative adversarial network, Generative Adversarial Networks (GAN), to alleviate the Vanishing gradient problem, vanishing gradient and the mode collapse issues. The special case of normal distributions is used in a Frechet inception distance, Frechet Inception Distance. The Wasserstein metric has a formal link with Procrustes analysis, with application to chirality measures, and to shape analysis. In computational biology, Wasserstein metric can be used to compare between Persistent homology, persistence diagrams of cytometry datasets. The Wasserstein metric also has been used in inverse problems in geophysics. The Wasserstein metric is used in Integrated information theory to compute the difference between concepts and conceptual structures.


Properties


Metric structure

It can be shown that ''W''''p'' satisfies all the axioms of a metric (mathematics), metric on ''P''''p''(''M''). Furthermore, convergence with respect to ''W''''p'' is equivalent to the usual weak convergence of measures plus convergence of the first ''p''th moments.


Dual representation of ''W''1

The following dual representation of ''W''1 is a special case of the duality theorem of
Kantorovich Leonid Vitalyevich Kantorovich ( rus, Леони́д Вита́льевич Канторо́вич, , p=lʲɪɐˈnʲit vʲɪˈtalʲjɪvʲɪtɕ kəntɐˈrovʲɪtɕ, a=Ru-Leonid_Vitaliyevich_Kantorovich.ogg; 19 January 19127 April 1986) was a Soviet ...
and Rubinstein (1958): when ''μ'' and ''ν'' have Bounded set, bounded Support (measure theory), support, :W_1 (\mu, \nu) = \sup \left\, where Lip(''f'') denotes the minimal Lipschitz continuity, Lipschitz constant for ''f''. Compare this with the definition of the Radon metric: :\rho (\mu, \nu) := \sup \left\. If the metric ''d'' is bounded by some constant ''C'', then :2 W_1 (\mu, \nu) \leq C \rho (\mu, \nu), and so convergence in the Radon metric (identical to total variation convergence when ''M'' is a Polish space) implies convergence in the Wasserstein metric, but not vice versa.


Proof

The following is an intuitive proof which skips over technical points. A fully rigorous proof is found in. Discrete case: When M is discrete, solving for the 1-Wasserstein distance is a problem in linear programming:\begin \min_\gamma \sum_ c(x, y) \gamma(x, y) \\ \sum_y \gamma(x, y) = \mu(x) \\ \sum_x \gamma(x, y) = \nu(y) \\ \gamma \geq 0 \endwhere c: M \times M \to [0, \infty) is a general "cost function". By carefully writing the above equations as matrix equations, we obtain its Dual linear program, dual problem:\begin \max_ \sum_x \mu(x)f(x) + \sum_y \nu(y)g(y)\\ f(x) + g(y) \leq c(x, y) \endand by the Dual linear program#Strong duality, duality theorem of linear programming, since the primal problem is feasible and bounded, so is the dual problem, and the minimum in the first problem equals the maximum in the second problem. That is, the problem pair exhibits ''strong duality''. For the general case, the dual problem is found by converting sums to integrals:\begin \sup_ \mathbb E_[f(x)] + \mathbb E_[g(y)]\\ f(x) + g(y) \leq c(x, y) \endand the ''strong duality'' still holds. This is the Kantorovich duality theorem. Cédric Villani recounts the following interpretation from Luis Caffarelli:
Suppose you want to ship some coal from mines, distributed as \mu, to factories, distributed as \nu. The cost function of transport is c. Now a shipper comes and offers to do the transport for you. You would pay him f(x) per coal for loading the coal at x, and pay him g(y) per coal for unloading the coal at y. For you to accept the deal, the price schedule must satisfy f(x) + g(y) \leq c(x, y). The Kantorovich duality states that the shipper can make a price schedule that makes you pay almost as much as you would ship yourself.
This result can be pressed further to yield: The two infimal convolution steps are visually clear when the probability space is \R. For notational convenience, let \square denote the infimal convolution operation. For the first step, where we used f = cone\square (-g), plot out the curve of -g, then at each point, draw a cone of slope 1, and take the lower envelope of the cones as f, as shown in the diagram, then f cannot increase with slope larger than 1. Thus all its secants have slope \Big, \frac\Big, \leq 1. For the second step, picture the infimal convolution cone \square (-f), then if all secants of f have slope at most 1, then the lower envelope of cone \square (-f) are just the cone-apices themselves, thus cone \square (-f)=-f. 1D Example. When both \mu, \nu are distributions on \R, then integration by parts give\mathbb_[f(x)] - \mathbb E_[f(y)] = \int f'(x) (F_\nu(x) - F_\mu(x)) dxthus f(x) = K \cdot \mathop(F_\nu(x) - F_\mu(x))


Fluid mechanics interpretation of ''W''2

Benamou & Brenier found a dual representation of W_2 by fluid mechanics, which allows efficient solution by convex optimization. Given two probability distributions on \R^n with density p, q, then W_2(p, q) = \min_v \int_0^T \int_ \, v(x, t)\, ^2 \rho(x, t)dxdtwhere v(x, t) is a velocity field, and \rho(x, t) is the fluid density field, such that \begin &\frac=-\operatorname\left( \rho(\cdot, t) v \right) \\ &\rho(x, 0)=p \\ &\rho(x, T)=q \endThat is, the mass should be conserved, and the velocity field should transport the probability distribution p to q during the time interval [0, T].


Equivalence of ''W''2 and a negative-order Sobolev norm

Under suitable assumptions, the Wasserstein distance W_2 of order two is Lipschitz equivalent to a negative-order homogeneous Sobolev space, Sobolev norm. More precisely, if we take M to be a connected space, connected Riemannian manifold equipped with a positive measure \pi, then we may define for f \colon M \to \mathbb the seminorm :\, f \, _^ = \int_ , \nabla f(x) , ^ \, \pi(\mathrm x) and for a signed measure \mu on M the dual norm :\, \mu \, _ = \sup \bigg\ . Then any two probability measures \mu and \nu on M satisfy the upper bound :W_ (\mu, \nu) \leq 2 \, \mu - \nu \, _ . In the other direction, if \mu and \nu each have densities with respect to the volume form, standard volume measure on M that are both bounded above some 0 < C < \infty, and M has non-negative Ricci curvature, then :\, \mu - \nu \, _ \leq \sqrt W_ (\mu, \nu) .


Separability and completeness

For any ''p'' ≥ 1, the metric space (''P''''p''(''M''), ''W''''p'') is Separable space, separable, and is Complete space, complete if (''M'', ''d'') is separable and complete.


See also

* Hutchinson metric * Lévy metric * Lévy–Prokhorov metric * Fréchet distance * Total variation distance of probability measures * Transportation theory (mathematics), Transportation theory * Earth mover's distance * Wasserstein GAN


References


Further reading

* * * *


External links

* {{cite web , url=https://stats.stackexchange.com/q/295617 , title=What is the advantages of Wasserstein metric compared to Kullback–Leibler divergence? , date=August 1, 2017 , work=Stack Exchange Measure theory Metric geometry Theory of probability distributions Statistical distance