Skip to content

Commit a78b197

Browse files
Finish PR 734 : typo in \text{max_nz} in ot.utils.projection_sparse_simplex (#746)
* typo in \text{max_nz} in ot.utils.projection_sparse_simplex( * add line with PR number * updatre doc * update pr number * update reference * fix other part in the doc --------- Co-authored-by: Joseph Salmon <[email protected]>
1 parent a97a788 commit a78b197

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

RELEASES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
- Clean references in documentation (PR #722)
3131
- Clean documentation for `ot.gromov.gromov_wasserstein` (PR #737)
3232
- Debug wheels building (PR #739)
33+
- Fix doc for projection sparse simplex (PR #734, PR #746)
3334

3435
## 0.9.5
3536

ot/utils.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,24 +140,29 @@ def projection_sparse_simplex(V, max_nz, z=1, axis=None, nx=None):
140140
r"""Projection of :math:`\mathbf{V}` onto the simplex with cardinality constraint (maximum number of non-zero elements) and then scaled by `z`.
141141
142142
.. math::
143-
P\left(\mathbf{V}, max_nz, z\right) = \mathop{\arg \min}_{\substack{\mathbf{y} >= 0 \\ \sum_i \mathbf{y}_i = z} \\ ||p||_0 \le \text{max_nz}} \quad \|\mathbf{y} - \mathbf{V}\|^2
143+
P\left(\mathbf{V}, \text{max_nz}, z\right) = \mathop{\arg \min}_{\substack{\mathbf{y} >= 0 \\ \sum_i \mathbf{y}_i = z} \\ ||p||_0 \le \text{max_nz}} \quad \|\mathbf{y} - \mathbf{V}\|^2
144144
145145
Parameters
146146
----------
147147
V: 1-dim or 2-dim ndarray
148+
max_nz: int
149+
Maximum number of non-zero elements in the projection.
150+
If `max_nz` is larger than the number of elements in `V`, then
151+
the projection is equivalent to `proj_simplex(V, z)`.
148152
z: float or array
149153
If array, len(z) must be compatible with :math:`\mathbf{V}`
150154
axis: None or int
151-
- axis=None: project :math:`\mathbf{V}` by :math:`P(\mathbf{V}.\mathrm{ravel}(), max_nz, z)`
152-
- axis=1: project each :math:`\mathbf{V}_i` by :math:`P(\mathbf{V}_i, max_nz, z_i)`
153-
- axis=0: project each :math:`\mathbf{V}_{:, j}` by :math:`P(\mathbf{V}_{:, j}, max_nz, z_j)`
155+
- axis=None: project :math:`\mathbf{V}` by :math:`P(\mathbf{V}.\mathrm{ravel}(), \text{max_nz}, z)`
156+
- axis=1: project each :math:`\mathbf{V}_i` by :math:`P(\mathbf{V}_i, \text{max_nz}, z_i)`
157+
- axis=0: project each :math:`\mathbf{V}_{:, j}` by :math:`P(\mathbf{V}_{:, j}, \text{max_nz}, z_j)`
154158
155159
Returns
156160
-------
157161
projection: ndarray, shape :math:`\mathbf{V}`.shape
158162
159-
References:
160-
Sparse projections onto the simplex
163+
References
164+
----------
165+
.. [1] Sparse projections onto the simplex
161166
Anastasios Kyrillidis, Stephen Becker, Volkan Cevher and, Christoph Koch
162167
ICML 2013
163168
https://arxiv.org/abs/1206.1529

0 commit comments

Comments
 (0)