Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Earth Mover's Distance/Wasserstein metric #37

Open
tlnagy opened this issue Feb 2, 2016 · 6 comments · May be fixed by #158
Open

Add Earth Mover's Distance/Wasserstein metric #37

tlnagy opened this issue Feb 2, 2016 · 6 comments · May be fixed by #158

Comments

@tlnagy
Copy link

tlnagy commented Feb 2, 2016

EMD is useful for calculating distances between histograms or distributions. It would be cool to see it added to Distances.jl

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

@currymj
Copy link

currymj commented May 30, 2017

Would also be neat to see the Sinkhorn distance, or entropy-regularized Wasserstein norm.

@ararslan
Copy link
Member

We always accept PRs, so if anyone is interested in adding those metrics to this package, it would certainly be welcome.

@currymj
Copy link

currymj commented May 30, 2017

In the context of this package, is there a sensible way to provide an arbitrary cost function when constructing the norm? Or would that not make sense with the design? Another option would just be to provide specific subtypes for the 1-, 2-, and max-norms. But arbitrary cost functions fit better with the general idea.

Likewise for the entropy-regularized case, the type would have to be parameterized with a float coefficient. Is this also reasonable?

@currymj
Copy link

currymj commented May 30, 2017

Also, I've just noticed that the norms seem to work well for numbers as well as vectors.

Would it be reasonable to define something like WassersteinNorm{N<:Metric}, which works on a vector with elements of some type T for which Metric is meaningful? This might be even cleaner.

This is a very clean and minimal library so I don't want to overcomplicate things.

@mirkobunse
Copy link

mirkobunse commented Feb 8, 2018

I made a small wrapper of the original EMD implementation by Rubner, the inventor of the Earth Mover Distance:

https://github.com/mirkobunse/EarthMoversDistance.jl

The wrapper only supports one-dimensional histograms for now, but it is easily extensible. The original wrapped algorithm can compute the EMD of any two distributions. Already, the wrapper allows you to define arbitrary ground distances. I'd appreciate your support in extending the project! Comments are welcome, as well.

Ultimately, I hope that the wrapper helps in implementing the EMD natively in Julia, e.g., in the Distances package. Specifically, efficient special-case algorithms would be great. My wrapper can be used to test such implementations.

@Sh4pe Sh4pe linked a pull request Feb 16, 2020 that will close this issue
@caseykneale
Copy link

I wrote a really basic pure julia EMD script here: https://discourse.julialang.org/t/computing-discrete-wasserstein-emd-distance-in-julia/9600/10?u=ckneale

Not sure if this is still of interest but I did see this is an open issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants