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/solver_1d.py
+63-23Lines changed: 63 additions & 23 deletions
Original file line number
Diff line number
Diff line change
@@ -933,8 +933,8 @@ def wasserstein_circle(
933
933
eps=1e-6,
934
934
require_sort=True,
935
935
):
936
-
r"""Computes the Wasserstein distance on the circle using either [45] for p=1 or
937
-
the binary search algorithm proposed in [44] otherwise.
936
+
r"""Computes the Wasserstein distance on the circle using either :ref:`[45] <references-wasserstein-circle>` for p=1 or
937
+
the binary search algorithm proposed in :ref:`[44] <references-wasserstein-circle>` otherwise.
938
938
Samples need to be in :math:`S^1\cong [0,1[`. If they are on :math:`\mathbb{R}`,
939
939
takes the value modulo 1.
940
940
If the values are on :math:`S^1\subset\mathbb{R}^2`, it requires to first find the coordinates
@@ -996,6 +996,8 @@ def wasserstein_circle(
996
996
>>> wasserstein_circle(u.T, v.T)
997
997
array([0.1])
998
998
999
+
1000
+
.. _references-wasserstein-circle:
999
1001
References
1000
1002
----------
1001
1003
.. [44] Hundrieser, Shayan, Marcel Klatt, and Axel Munk. "The statistics of circular optimal transport." Directional Statistics for Innovative Applications: A Bicentennial Tribute to Florence Nightingale. Singapore: Springer Nature Singapore, 2022. 57-82.
samples in the source domain (coordinates on [0,1[)
1117
+
u_weights : ndarray, shape (n, ...), optional
1118
+
samples weights in the source domain
1119
+
1120
+
Returns
1121
+
-------
1122
+
embedding: ndarray of shape (m, ...)
1123
+
Embedding evaluated at :math:`x`
1106
1124
1107
-
Output:
1108
-
- embedding of shape (m, ...)
1125
+
.. _references-lcot:
1126
+
References
1127
+
----------
1128
+
.. [76] Martin, R. D., Medri, I., Bai, Y., Liu, X., Yan, K., Rohde, G. K., & Kolouri, S. (2024). LCOT: Linear Circular Optimal Transport. International Conference on Learning Representations.
where :math:`\hat{\mu}(x)=F_{\mu}^{-1}(x-\int z\mathrm{d}\mu(z)+\frac12) - x` for all :math:`x\in [0,1[`,
1177
+
and :math:`d_{S^1}(x,y)=\min(|x-y|, 1-|x-y|)` for :math:`x,y\in [0,1[`.
1146
1178
1147
1179
Parameters
1148
1180
----------
1149
-
1150
-
Inputs:
1151
-
- u_values: shape (n, ...) - samples in the source domain (coordinates on [0,1[)
1152
-
- v_values: shape (m, ...) , optional- samples in the target domain (coordinates on [0,1[), if None, compute distance against uniform distribution
1153
-
- u_weights: shape (n, ...), optional - weights of the first empirical distribution, if None then uniform weights are used
1154
-
- v_weights, shape (m, ...), optional - weights of the second empirical distribution, if None then uniform weights are used
1181
+
u_values : ndarray, shape (n, ...)
1182
+
samples in the source domain (coordinates on [0,1[)
1183
+
v_values : ndarray, shape (n, ...), optional
1184
+
samples in the target domain (coordinates on [0,1[), if None, compute distance against uniform distribution
1185
+
u_weights : ndarray, shape (n, ...), optional
1186
+
samples weights in the source domain
1187
+
v_weights : ndarray, shape (n, ...), optional
1188
+
samples weights in the target domain
1155
1189
1156
1190
Returns
1157
1191
-------
1158
-
Outputs:
1159
-
- return batchs LCOT
1192
+
loss: float
1193
+
Cost associated to the linear optimal transportation
1160
1194
1161
1195
Examples
1162
1196
--------
1197
+
>>> u = np.array([[0.2,0.5,0.8]])%1
1198
+
>>> v = np.array([[0.4,0.5,0.7]])%1
1199
+
>>> linear_circular_ot(u.T, v.T)
1200
+
array([0.0127])
1201
+
1163
1202
1203
+
.. _references-lcot:
1164
1204
References
1165
1205
----------
1166
1206
.. [76] Martin, R. D., Medri, I., Bai, Y., Liu, X., Yan, K., Rohde, G. K., & Kolouri, S. (2024). LCOT: Linear Circular Optimal Transport. International Conference on Learning Representations.
0 commit comments