lenskit.stats#

LensKit statistical computations.

Functions

gini(xs)

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:

float