pub struct Welford { /* private fields */ }Expand description
Online (streaming) mean and variance via Welford’s algorithm.
Naive “sum of squares minus square of sum” variance loses precision catastrophically once
the values share a large common offset (see this module’s tests for a worked example);
Welford’s algorithm instead updates the mean and the sum of squared deviations from the
running mean one sample at a time, and never needs to retain the samples themselves –
exactly the shape an adaptive Monte Carlo driver needs: an unbounded trial count held in
O(1) memory.
Implementations§
Source§impl Welford
impl Welford
Sourcepub fn sample_variance(&self) -> f64
pub fn sample_variance(&self) -> f64
Unbiased (Bessel-corrected) sample variance, m2 / (n - 1).
0.0 when fewer than two observations have been pushed – a single point has no
defined spread.
Sourcepub fn population_variance(&self) -> f64
pub fn population_variance(&self) -> f64
Population variance, m2 / n. 0.0 when no observations have been pushed yet.
Sourcepub fn sample_std(&self) -> f64
pub fn sample_std(&self) -> f64
Sample standard deviation, sqrt(sample_variance()).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Welford
impl RefUnwindSafe for Welford
impl Send for Welford
impl Sync for Welford
impl Unpin for Welford
impl UnsafeUnpin for Welford
impl UnwindSafe for Welford
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.