You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ot/lp/__init__.py
+22-8Lines changed: 22 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,6 @@ def emd(a,b,M):
7
7
"""
8
8
Solves the Earth Movers distance problem and returns the optimal transport matrix
9
9
10
-
gamm=emd(a,b,M)
11
10
12
11
.. math::
13
12
\gamma = arg\min_\gamma <\gamma,M>_F
@@ -21,6 +20,8 @@ def emd(a,b,M):
21
20
22
21
- M is the metric cost matrix
23
22
- a and b are the sample weights
23
+
24
+
Uses the algorithm proposed in [1]_
24
25
25
26
Parameters
26
27
----------
@@ -31,27 +32,40 @@ def emd(a,b,M):
31
32
M : (ns,nt) ndarray, float64
32
33
loss matrix
33
34
35
+
Returns
36
+
-------
37
+
gamma: (ns x nt) ndarray
38
+
Optimal transportation matrix for the given parameters
39
+
40
+
34
41
Examples
35
42
--------
36
43
37
-
Simple example with obvious solution. The function :func:emd accepts lists and
38
-
perform automatic conversion tu numpy arrays
44
+
Simple example with obvious solution. The function emd accepts lists and
45
+
perform automatic conversion to numpy arrays
39
46
40
47
>>> a=[.5,.5]
41
48
>>> b=[.5,.5]
42
49
>>> M=[[0.,1.],[1.,0.]]
43
50
>>> ot.emd(a,b,M)
44
51
array([[ 0.5, 0. ],
45
52
[ 0. , 0.5]])
53
+
54
+
References
55
+
----------
46
56
47
-
Returns
48
-
-------
49
-
gamma: (ns x nt) ndarray
50
-
Optimal transportation matrix for the given parameters
51
-
57
+
.. [1] Bonneel, N., Van De Panne, M., Paris, S., & Heidrich, W. (2011, December). Displacement interpolation using Lagrangian mass transport. In ACM Transactions on Graphics (TOG) (Vol. 30, No. 6, p. 158). ACM.
0 commit comments