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

Type of arguments of wasserstein() #16

Open
ignace-computing opened this issue Dec 20, 2021 · 2 comments
Open

Type of arguments of wasserstein() #16

ignace-computing opened this issue Dec 20, 2021 · 2 comments

Comments

@ignace-computing
Copy link

Sorry if this issue looks ridiculous.
What is the required type of the arguments 'mu' and 'nu' of the function wasserstein()?

Is it also possible to pass two Vector{Float64}'s (currently that seems to throw an error)?

Many thanks!

@devmotion
Copy link
Member

wasserstein and squared2wasserstein provide a unified and optimized interface for ot_cost. Hence all sources mu and targets nu that are supported by ot_cost can be used. This includes, e.g., pairs Normal, MvNormal, and DiscreteNonParametric distributions (from the Distributions package) for which a closed form solution exists for specific cost functions (and hence specific Wasserstein distances). The Wasserstein distance for a continuous univariate source distribution and an arbitrary univariate target distribution can be computed with numerical integration.

Currently, one has to pass Distributions as source and target and raw Vectors are not supported. However, you can use a DiscreteNonParametric distribution instead. You can construct them explicitly with DiscreteNonParametric(mu_vector, mu_probs) (where probably mu_probs are uniform probabilities fill(inv(length(mu_probs)), length(mu_probs))) or the convenience function discretemeasure by discretemeasure(mu_vector, mu_probs) where mu_probs can be omitted in the uniform case.

@ignace-computing
Copy link
Author

Thank you!

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

No branches or pull requests

2 participants