Enum Aggregate
pub enum Aggregate {
Mean,
Median,
Iqm,
MeanMinusStd(f64),
}Expand description
How the per-seed values of a fan collapse into one sampler-visible number.
The aggregate is computed identically whatever the study’s
Direction — the direction only decides which aggregate wins (via
Direction::is_better), never how it is computed.
Variants§
Mean
The arithmetic mean of the replicates.
Median
The median (the average of the two middle values for an even count).
Iqm
The interquartile mean: the mean of the middle 50%, dropping the
bottom and top floor(k / 4) replicates each (the rliable estimator,
robust to a lucky or unlucky seed).
The trimming rule for small k is documented on
Aggregate::apply; for k <= 3 nothing is trimmed and the IQM equals
the plain mean.
MeanMinusStd(f64)
mean - lambda * std, with the population standard deviation
(divided by k, so it is 0 — not undefined — for a single replicate).
A risk-averse aggregate: it prefers configurations that are both good and
consistent. It is computed identically regardless of direction, so for
a Minimize study — where subtracting the spread
rewards inconsistency — the risk-averse choice is a negative
lambda.
Implementations§
§impl Aggregate
impl Aggregate
pub fn apply(self, values: &[f64]) -> Result<f64>
pub fn apply(self, values: &[f64]) -> Result<f64>
Collapses values (the per-seed objective values of one objective
dimension) into a single number.
§Non-finite values
A NaN or ±inf replicate is a real observation about a diverging run,
so it is neither rejected nor rounded: it propagates into the result
(a mean containing NaN is NaN), where
Direction::is_better then ensures it can never silently win a
comparison. Sorting for Median and
Iqm uses f64::total_cmp, so it is total even in
the presence of NaN.
§The small-k trimming rule for Iqm
With k sorted replicates the IQM drops d = floor(k / 4) from each end
and averages the remaining k - 2d (always at least one, since
2d < k). This matches SciPy’s trim_mean(…, 0.25):
k | dropped each side | averaged |
|---|---|---|
| 1 | 0 | all 1 (= the value) |
| 2 | 0 | all 2 (= the mean) |
| 3 | 0 | all 3 (= the mean) |
| 4 | 1 | the 2 middle |
| 8 | 2 | the 4 middle |
§Errors
Error::InvalidSpace if values is empty — an aggregate of no
replicates is undefined, and this is reported as a clean error rather
than a panic or a silent NaN.