Skip to content

Commit

Permalink
pydocs
Browse files Browse the repository at this point in the history
  • Loading branch information
marcocuturi committed Jul 3, 2023
1 parent 422afe4 commit 4268043
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/ott/tools/soft_sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def ranks(
Returns:
A jnp.ndarray of the same shape as the input with soft-rank values
normalized to be in :math:`[0,1]` that replace the orignal ones.
normalized to be in :math:`[0,1]`, replacing the original ones.
"""
return apply_on_axis(_ranks, inputs, axis, num_targets, **kwargs)
Expand All @@ -280,14 +280,13 @@ def quantile(
x_quantiles = quantiles(x, q=jnp.array([0.2, 0.8]))
```
``x_quantiles`` will hold an approximation to the 20-th and 80-th
percentiles in ``x``, computed as a convex combination
(a weighted mean, with weights summing to 1) of all values in ``x`` (and not,
as would be the usual approach, the 20th and 80th values of ``x`` sorted in
ascending order). These values offer a trade-off between accuracy
(closeness to the true percentiles) and gradient (the Jacobian of
``x_quantiles`` w.r.t ``x`` will impact all values listed in ``x``, not just
the 20th and 80th).
``x_quantiles`` will hold an approximation to the 20 and 80 percentiles in
``x``, computed as a convex combination (a weighted mean, with weights summing
to 1) of all values in ``x`` (and not, as would be the usual approach, the
values ``x_sorted[20]`` and ``x_sorted[80]`` is ``x_sorted=jnp.sort(x)``.
These values offer a trade-off between accuracy (closeness to the true
percentiles) and gradient (the Jacobian of ``x_quantiles`` w.r.t ``x`` will
impact all values listed in ``x``, not just those indexed at 20 and 80).
The non-differentiable version is given by :func:`jax.numpy.quantile`, e.g.
```
Expand Down

0 comments on commit 4268043

Please sign in to comment.