kde_cpi.math.utils module

Common helper functions for statistical routines.

kde_cpi.math.utils.cumulative_weights(weights)[source]

Compute the cumulative sum of weights.

Return type:

ndarray[tuple[Any, ...], dtype[float64]]

Parameters:

weights (ndarray[tuple[Any, ...], dtype[float64]])

kde_cpi.math.utils.normalize_weights(weights, *, ensure_positive=True)[source]

Normalize weights so they sum to one and validate positivity.

Return type:

ndarray[tuple[Any, ...], dtype[float64]]

Parameters:
kde_cpi.math.utils.sort_by_values(values, weights)[source]

Return values and weights sorted together by ascending values.

Return type:

tuple[ndarray[tuple[Any, ...], dtype[float64]], ndarray[tuple[Any, ...], dtype[float64]]]

Parameters:
  • values (ndarray[tuple[Any, ...], dtype[float64]])

  • weights (ndarray[tuple[Any, ...], dtype[float64]])

kde_cpi.math.utils.to_numpy(values)[source]

Coerce the input sequence into a NumPy float array.

Return type:

ndarray[tuple[Any, ...], dtype[float64]]

Parameters:

values (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | Iterable[float])