-
Notifications
You must be signed in to change notification settings - Fork 98
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 p-Wasserstein distance #158
base: master
Are you sure you want to change the base?
Conversation
I would say the main issue of introducing this PR is its huge dependency. You know, at present this package is quite small julia> @time using Distances
0.078969 seconds (52.74 k allocations: 3.509 MiB) Probably this package isn't the best place to put the codes to |
Yes, this PR introduces a lot of dependencies. But since you need to solve a (possibly large) linear program in order to calculate the Wasserstein distance, you need to introduce at least some dependencies (granted that you don't want to re-implement a linear program solver on your own)... So what do you think would be a better place for the code? And what do others think? |
Another implementation (though solved quite differently) is in #159. Don't really know about the implementation there though. |
FYI: https://github.com/JuliaOptimalTransport/OptimalTransport.jl contains specialized implementations for the 1D solution, both for discrete and continuous distributions, but also a pure Julia implementation for solving the optimal transport problem with discrete measures in arbitrary dimensions (and soon there will be also a specialized implementation for multivariate normal distributions). We just added |
Adding JuMP as a dependency to Distances.jl would certainly be a problem. As noted at #159 (comment), the 1D Wasserstein distance has a closed form solution, and Distances.jl only includes 1D distances, so we should use that. |
We started splitting OptimalTransport.jl into smaller subpackages, the Wasserstein distances, based on MOI in the general case and including special cases as 1D and e.g. Gaussian distributions, are moved to https://github.com/JuliaOptimalTransport/ExactOptimalTransport.jl. |
This PR adds the p-Wasserstein distance (a.k.a. Earth Mover Distance). Calculating the p-Wasserstein entails solving a linear program. This is done using JuMP.jl with the Cbc.jl optimizer.
Fixes #37