[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

https://r-forge.r-project.org/projects/earthmovdist/

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

>From the transport package, I found this example

set.seed(27)
x <- pp(matrix(runif(100),50,2))
y <- pp(matrix(runif(100),00,2))
wasserstein(x,y,p=1)

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
1?

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.
Cheers

Lorenzo



More information about the R-help mailing list