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:
objectBundle of weighted descriptive statistics for CPI components.
- Parameters:
- 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:
- Parameters:
values (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
weights (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
trim (float)
kde_bandwidth (float | None)
grid_points (int)
- kde_cpi.math.effective_sample_size(weights)[source]¶
Estimate the effective sample size implied by the weights.
- kde_cpi.math.weighted_kde_bandwidth(values, weights)[source]¶
Scott’s rule of thumb generalized for weighted samples.
- Return type:
- Parameters:
values (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
weights (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
- 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:
- Parameters:
values (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
weights (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
bandwidth (float | None)
grid_points (int)
extend (float)
- kde_cpi.math.weighted_kurtosis(values, weights, fisher=True)[source]¶
Return the weighted fourth standardized moment (Fisher by default).
- Return type:
- Parameters:
values (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
weights (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
fisher (bool)
- kde_cpi.math.weighted_mean(values, weights)[source]¶
Compute the weighted arithmetic mean.
- Return type:
- Parameters:
values (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
weights (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
- kde_cpi.math.weighted_median(values, weights)[source]¶
Return the weighted 50th percentile.
- Return type:
- Parameters:
values (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
weights (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
- kde_cpi.math.weighted_skewness(values, weights)[source]¶
Return the weighted third standardized moment.
- Return type:
- Parameters:
values (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
weights (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
- kde_cpi.math.weighted_std(values, weights)[source]¶
Return the weighted population standard deviation.
- Return type:
- Parameters:
values (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
weights (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
- kde_cpi.math.weighted_trimmed_mean(values, weights, trim=0.08)[source]¶
Compute a symmetric trimmed mean with weight-aware clipping.
- Return type:
- Parameters:
values (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
weights (_Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str])
trim (float)