summaryrefslogtreecommitdiff
path: root/src/python
diff options
context:
space:
mode:
authortlacombe <lacombe1993@gmail.com>2019-10-17 23:55:17 +0200
committertlacombe <lacombe1993@gmail.com>2019-10-17 23:55:17 +0200
commita625d5879beaaae47118bc79fda17f441483dffe (patch)
tree9b67c4ce9618b3ff37065b7920e39726b11b8222 /src/python
parent7ea7dfe83e93dc3d33d8d50917f718c05f32ca7f (diff)
Few improvements to the documentation.
Diffstat (limited to 'src/python')
-rw-r--r--src/python/gudhi/wasserstein.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/python/gudhi/wasserstein.py b/src/python/gudhi/wasserstein.py
index 0b2fe79a..4e17811d 100644
--- a/src/python/gudhi/wasserstein.py
+++ b/src/python/gudhi/wasserstein.py
@@ -26,8 +26,8 @@ def _proj_on_diag(X):
def _build_dist_matrix(X, Y, p=2., q=2.):
'''
- :param X: (n x 2) np.array encoding the (points of the) first diagram.
- :param Y: (m x 2) np.array encoding the second diagram.
+ :param X: (n x 2) numpy.array encoding the (points of the) first diagram.
+ :param Y: (m x 2) numpy.array encoding the second diagram.
:param q: Ground metric (i.e. norm l_q).
:param p: exponent for the Wasserstein metric.
:returns: (n+1) x (m+1) np.array encoding the cost matrix C.
@@ -54,19 +54,19 @@ def _build_dist_matrix(X, Y, p=2., q=2.):
def _perstot(X, p, q):
'''
- :param X: (n x 2) numpy array (points of a given diagram)
- :param q: Ground metric on the (upper-half) plane (i.e. norm l_q in R^2); Default value is 2 (euclidean norm).
+ :param X: (n x 2) numpy.array (points of a given diagram).
+ :param q: Ground metric on the (upper-half) plane (i.e. norm l_q in R^2); Default value is 2 (Euclidean norm).
:param p: exponent for Wasserstein; Default value is 2.
:returns: float, the total persistence of the diagram (that is, its distance to the empty diagram).
'''
Xdiag = _proj_on_diag(X)
- return (np.sum(np.linalg.norm(X - Xdiag, ord=q, axis=1)**p))**(1/p)
+ return (np.sum(np.linalg.norm(X - Xdiag, ord=q, axis=1)**p))**(1./p)
def wasserstein_distance(X, Y, p=2., q=2.):
'''
- :param X: (n x 2) np.array encoding the (points of the) first diagram.
- :param Y: (m x 2) np.array encoding the second diagram.
+ :param X: (n x 2) numpy.array encoding the (finite points of the) first diagram. Must not contain essential points (i.e. with infinite coordinate).
+ :param Y: (m x 2) numpy.array encoding the second diagram.
:param q: Ground metric on the (upper-half) plane (i.e. norm l_q in R^2); Default value is 2 (euclidean norm).
:param p: exponent for Wasserstein; Default value is 2.
:returns: the p-Wasserstein distance (1 <= p < infty) with respect to the q-norm as ground metric.