Improve performance by making sure add
is inlined
This commit is contained in:
parent
262d5c88da
commit
4fa92eb9e0
@ -37,6 +37,7 @@ impl Average {
|
||||
}
|
||||
|
||||
/// Add an element sampled from the population.
|
||||
#[inline]
|
||||
pub fn add(&mut self, sample: f64) {
|
||||
// This algorithm introduced by Welford in 1962 trades numerical
|
||||
// stability for a division inside the loop.
|
||||
|
@ -40,6 +40,7 @@ impl WeightedAverage {
|
||||
}
|
||||
|
||||
/// Add a weighted element sampled from the population.
|
||||
#[inline]
|
||||
pub fn add(&mut self, sample: f64, weight: f64) {
|
||||
// The algorithm for the unweighted average was suggested by Welford in 1962.
|
||||
// The algorithm for the weighted average was suggested by West in 1979.
|
||||
|
Loading…
Reference in New Issue
Block a user