jaxopt.projection.projection_simplex

jaxopt.projection.projection_simplex(x, value=1.0)[source]

Projection onto a simplex:

\[\underset{p}{\text{argmin}} ~ ||x - p||_2^2 \quad \textrm{subject to} \quad p \ge 0, p^\top 1 = \text{value}\]

By default, the projection is onto the probability simplex.

Parameters
  • x (Array) – vector to project, an array of shape (n,).

  • value (float) – value p should sum to (default: 1.0).

Return type

Array

Returns

projected vector, an array with the same shape as x.