lenskit.stats#
LensKit statistical computations.
Functions
|
Compute the ordered positions of the top n elements. |
|
Compute the Gini coefficient of an array of values. |
- lenskit.stats.gini(xs)#
Compute the Gini coefficient of an array of values.
This is inspired by Olivia Guest’s implementation and based on the StatsDirect reference. It does not include Olivia’s zero adjustment; the Gini coefficient is fine with some zeros, so long as the sum is strictly positive.
- Stability:
- Caller (see Stability Levels).
- Parameters:
xs (numpy.typing.ArrayLike) – An array of values representing the “resource” allocated to each instance.
- Returns:
The Gini coefficient of the values in
xs
.- Return type:
- lenskit.stats.argtopn(xs, n)#
Compute the ordered positions of the top n elements. Similar to
torch.topk()
, but works with NumPy arrays and only returns the indices.Deprecated since version 2025.3.0: This was never declared stable, but is now deprecated and will be removed in 2026.1.