kde_cpi.math package

Statistical utilities for CPI analysis.

class kde_cpi.math.StatSummary(weighted_mean, weighted_median, trimmed_mean, weighted_std, weighted_skewness, weighted_kurtosis, weighted_kde_bandwidth, weighted_kde_mode, effective_sample_size)[source]

Bases: object

Bundle of weighted descriptive statistics for CPI components.

Parameters:
  • weighted_mean (float)

  • weighted_median (float)

  • trimmed_mean (float)

  • weighted_std (float)

  • weighted_skewness (float)

  • weighted_kurtosis (float)

  • weighted_kde_bandwidth (float)

  • weighted_kde_mode (float)

  • effective_sample_size (float)

effective_sample_size: float
trimmed_mean: float
weighted_kde_bandwidth: float
weighted_kde_mode: float
weighted_kurtosis: float
weighted_mean: float
weighted_median: float
weighted_skewness: float
weighted_std: float
kde_cpi.math.compute_statistics(values, weights, *, trim=0.08, kde_bandwidth=None, grid_points=2048)[source]

Compute a consistent set of weighted statistics for CPI components.

Return type:

StatSummary

Parameters:
kde_cpi.math.effective_sample_size(weights)[source]

Estimate the effective sample size implied by the weights.

Return type:

float

Parameters:

weights (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])

kde_cpi.math.weighted_kde_bandwidth(values, weights)[source]

Scott’s rule of thumb generalized for weighted samples.

Return type:

float

Parameters:
kde_cpi.math.weighted_kde_mode(values, weights, bandwidth=None, *, grid_points=2048, extend=3.0)[source]

Locate the mode of a weighted kernel density estimate.

Return type:

float

Parameters:
kde_cpi.math.weighted_kurtosis(values, weights, fisher=True)[source]

Return the weighted fourth standardized moment (Fisher by default).

Return type:

float

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

Compute the weighted arithmetic mean.

Return type:

float

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

Return the weighted 50th percentile.

Return type:

float

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

Return the weighted third standardized moment.

Return type:

float

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

Return the weighted population standard deviation.

Return type:

float

Parameters:
kde_cpi.math.weighted_trimmed_mean(values, weights, trim=0.08)[source]

Compute a symmetric trimmed mean with weight-aware clipping.

Return type:

float

Parameters:

Submodules