pub trait StatsExt {
fn sum(&self) -> f64;
fn min(&self) -> f64;
fn max(&self) -> f64;
fn mean(&self) -> f64;
fn var(&self) -> f64;
fn std_dev(&self) -> f64;
fn imin(&self) -> usize;
fn imax(&self) -> usize;
}
Expand description
Trait that provides simple descriptive statistics on a univariate set of numeric samples.
Required methods
Sum of the samples.
Note: this method sacrifices performance at the altar of accuracy Depends on IEEE-754 arithmetic guarantees. See proof of correctness at: “Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates”
Arithmetic mean (average) of the samples: sum divided by sample-count.
Variance of the samples: bias-corrected mean of the squares of the differences of each
sample from the sample mean. Note that this calculates the sample variance rather than the
population variance, which is assumed to be unknown. It therefore corrects the (n-1)/n
bias that would appear if we calculated a population variance, by dividing by (n-1)
rather
than n
.
Standard deviation: the square root of the sample variance.
Note: this is not a robust statistic for non-normal distributions. Prefer the
median_abs_dev
for unknown distributions.