[R] Earth Mover's Distance

Lorenzo Isella lorenzo.isella at gmail.com
Tue Mar 7 14:27:33 CET 2017

Dear All,
>From time to time I need to resort to the calculation of the earth
mover' distance (see

https://en.wikipedia.org/wiki/Earth_mover's_distance and
https://en.wikipedia.org/wiki/Wasserstein_metric .

In the past I used the package


which apparently is no longer available, but there is plenty of choice
in R.

>From the transport package, I found this example

x <- pp(matrix(runif(100),50,2))
y <- pp(matrix(runif(100),00,2))

but it is not 100% clear to me how to interpret it.
Are x and y meant as histograms where the the center of each bin is
provided and the total mass in the bins is automatically normalized to

Essentially, my situation is that I have two univariate samples of unequal
size. I would like to bin them and calculate the earth mover's
distance between them.

I am not sure if this is what the example above does.


More information about the R-help mailing list