Lably
Skip to content

Earth mover's distance

  • 5 min read
  • 6 chapters

Related on Lably

Through Frequency (statistics), Measure (mathematics) and Soil

Over probability distributions, the earth mover's distance is also known as the Wasserstein metric W1, Kantorovich–Rubinstein metric, or Mallows's distance. It is the solution of the optimal transport problem, which in turn is also known as the Monge-Kantorovich problem, or sometimes the Hitchcock–Koopmans transportation problem; when the measures are uniform over a set of discrete elements, the same optimization problem is known as minimum weight bipartite matching.

Formal definitions

The EMD between probability distributions P and Q can be defined as an infimum over joint probabilities:

EMD(P,Q)=infγ∈Π(P,Q)E(x,y)∼γ[d(x,y)]

where Π(P,Q) is the set of all joint distributions whose marginals are P and Q.

By Kantorovich-Rubinstein duality, this can also be expressed as:

EMD(P,Q)=sup‖f‖L≤1Ex∼P[f(x)]−Ey∼Q[f(y)]

where the supremum is taken over all 1-Lipschitz continuous functions, i.e. ‖∇f(x)‖≤1∀x.

EMD between signatures

In some applications, it is convenient to represent a distribution P as a signature, or a collection of clusters, where the i-th cluster represents a feature of mass wi centered at pi. In this formulation, consider signatures P={(p1,wp1),(p2,wp2),...,(pm,wpm)} and Q={(q1,wq1),(q2,wq2),...,(qn,wqn)}. Let D=[di,j] be the ground distance between clusters pi and qj. Then the EMD between P and Q is given by the optimal flow F=[fi,j], with fi,j the flow between pi and qj, that minimizes the overall cost.

minF∑i=1m∑j=1nfi,jdi,j

subject to the constraints:

fi,j≥0,1≤i≤m,1≤j≤n
∑j=1nfi,j≤wpi,1≤i≤m
∑i=1mfi,j≤wqj,1≤j≤n
∑i=1m∑j=1nfi,j=min{∑i=1mwpi,∑j=1nwqj}

The optimal flow F is found by solving this linear optimization problem. The earth mover's distance is defined as the work normalized by the total flow:

EMD(P,Q)=∑i=1m∑j=1nfi,jdi,j∑i=1m∑j=1nfi,j

Sign in to keep reading

5 more chapters are free with a Lably account.

More in Computing and communication