Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

p-norm vs Minkowski distance #672

Answered by rflamary
DRKWang asked this question in Q&A
Discussion options

Describe the bug

Hi there,

I have a project to compute different p-norm Wasserstein distances. I assume the function ot.dist(p = pnorm) is used to compute different p-norm cost matrices, which are referred to as "Minkowski distances" in the docstring. However, the following example shows that it does not follow what I expected.

import ot
import numpy as np
A = np.array([[0,0]])
B = np.array([[1,2]])
print(ot.dist(A,B,p = 1))
print(ot.dist(A,B,p = 2))
print(ot.dist(A,B,p = 3))
print(ot.dist(A,B,p = 4))
print(ot.dist(A,B,p = 5))
print(ot.dist(A,B,p = 6))

And the outputs are

[[5]]
[[5]]
[[5]]
[[5]]
[[5]]
[[5]]

Please let me know if there is any other function that can compute the p-norm function, as well as the 'inf'-norm case.

Thank you.

You must be logged in to vote

Hello,
As stated in the documentation and similarly to the original numpy functions parameter p is used only when the metric= 'minkowski' is passed since default is squared euclidean that corresponds to p=2
https://pythonot.github.io/all.html#ot.dist

Replies: 1 comment

Comment options

Hello,
As stated in the documentation and similarly to the original numpy functions parameter p is used only when the metric= 'minkowski' is passed since default is squared euclidean that corresponds to p=2
https://pythonot.github.io/all.html#ot.dist

You must be logged in to vote
0 replies
Answer selected by rflamary
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants
Converted from issue

This discussion was converted from issue #671 on August 21, 2024 06:34.

AltStyle によって変換されたページ (->オリジナル) /