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

Why does Wasserstein differ from scipy? #29

Closed
itsdfish opened this issue May 16, 2023 · 1 comment
Closed

Why does Wasserstein differ from scipy? #29

itsdfish opened this issue May 16, 2023 · 1 comment

Comments

@itsdfish
Copy link

Hi,

I was wondering why the results for wasserstein differ from scipy. I didn't see anything different in terms of configuration.

Thanks!

Julia

using ExactOptimalTransport
wasserstein(Categorical([0, .25, .75]), Categorical([.4,.4,.2]))
# output 0.9500000000000001

Python

import scipy
scipy.stats.wasserstein_distance([.0,.25,.75], [.4,.4,.2])
# output 0.23333333333333334
@zsteve
Copy link
Member

zsteve commented May 17, 2023

In the Julia code, you're computing the 1-Wass distance between two discrete measures that share a common support on [1, 2, 3] (that's how Categorical works).
On the other hand, to my understanding from the documentation of the scipy funciton (https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.wasserstein_distance.html) the inputs u, v are actually the empirical points.
For comparison:


julia> wasserstein(DiscreteNonParametric([.0,.25,.75], [1/3, 1/3, 1/3]), DiscreteNonParametric([.4,.2], [2/3, 1/3]))
0.23333333333333334

@zsteve zsteve closed this as completed May 17, 2023
@zsteve zsteve reopened this May 17, 2023
@zsteve zsteve closed this as completed May 17, 2023
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