synthesizer.utils.stats¶
Functions
- synthesizer.utils.stats.weighted_mean(data, weights)[source]¶
Calculate the weighted mean
- Parameters:
data (list or numpy.array) – data
weights (list or numpy.array) – weights
Author: Stephen Wilkins
- synthesizer.utils.stats.weighted_median(data, weights)[source]¶
- Parameters:
data (list or numpy.array) – data
weights (list or numpy.array) – weights
- synthesizer.utils.stats.weighted_quantile(values, quantiles, sample_weight=None, values_sorted=False, old_style=False)[source]¶
Taken from From https://stackoverflow.com/a/29677616/1718096
Very close to numpy.percentile, but supports weights. NOTE: quantiles should be in [0, 1]!
- Parameters:
values (numpy.array) – values to weight
quantiles (array-like) – array of quantiles needed
sample_weight (array-like) – same length as array
values_sorted (bool) – f True, then will avoid sorting of initial array
old_style (bool) – If True, will correct output to be consistent with numpy.percentile.
- Returns:
numpy.array with computed quantiles.