truncated_mean
- negmas.helpers.truncated_mean(scores, limits=None, top_limit=2.0, bottom_limit=inf, base='tukey', return_limits=False)[source]
Calculates the truncated mean
- Parameters
scores (np.ndarray) – A list of scores for which to calculate the truncated mean
limits (tuple[float, float] | None) – The limits to use for trimming the scores. If not given, they will be calculated based on
top_limit
,bottom_limit
andbase.
You can pass the special value “mean” as a string to disable limits and calcualte the mean. You can pass the special value “median” to calculate the median (which is the same as passing top_limit==bottom_limit=0.5 and base == “scores”).top_limit – top limit on scores to use for truncated mean calculation. See
base
bottom_limit – bottom limit on scores to use for truncated mean calculation. See
base
base – The base for calculating the limits used to apply the
top_limit
andbottom_limit
. Possible values are: - zscore: the number of sigmas to remove above/below. A good default choice is 3. Pass inf to disable a side. - tukey: the fraction of IQR to remove above/below. A good default choice is 1.5 or 3 (we use 2). Pass inf to disable a side. - iqr : same as tukey - iqr_fraction: the fraction is interpreted as the fraction of scores above/below the 1st/3rd qauntile - scores: the fraction is interpreted as fraction of highest and lowest scores - fraction: the fraction is interpreted as literal fraction of the values (i.e. given 10 values and 0.1, removes 1 value) - mean: simply returns the mean (limits ignored) - median: simply returns the median (limits ignored)return_limits – If true, the method will also return the limiting scores used in its mean calculation.
- Return type