pub struct SummStats { /* private fields */ }Expand description
Summary statistics struct
This struct aggregates data to compute summary statistics using constant space overhead. It implements the FromIterator trait so it can be collected from an iterator of floats.
Examples
let nums = [2.0, 4.0, 8.0];
let mut stats = inc_stats::SummStats::new();
for num in nums.iter() {
stats.add(num.clone());
}
assert_eq!(3, stats.count());let nums = [2.0, 4.0, 8.0];
let stats: inc_stats::SummStats = nums.iter().cloned().collect();
assert_eq!(3, stats.count());Implementations
sourceimpl SummStats
impl SummStats
sourcepub fn min(&self) -> Option<f64>
pub fn min(&self) -> Option<f64>
Get the minimum non nan value
Constant time. If no non nan values have been added, this is None.
Examples
let nums = [2.0, 4.0, std::f64::NAN];
let stats: inc_stats::SummStats = nums.iter().cloned().collect();
assert!((2.0 - stats.min().unwrap()).abs() < 1.0e-6);let mut stats = inc_stats::SummStats::new();
stats.add(std::f64::NAN);
assert!(stats.min().is_none());sourcepub fn max(&self) -> Option<f64>
pub fn max(&self) -> Option<f64>
Get the maximum non nan value
Constant time. If no non nan values have been added, this is None.
Examples
let nums = [2.0, 4.0, std::f64::NAN];
let stats: inc_stats::SummStats = nums.iter().cloned().collect();
assert!((4.0 - stats.max().unwrap()).abs() < 1.0e-6);sourcepub fn mean(&self) -> Option<f64>
pub fn mean(&self) -> Option<f64>
Get the mean
Constant time.
Examples
let nums = [2.0, 4.0];
let stats: inc_stats::SummStats = nums.iter().cloned().collect();
assert!((3.0 - stats.mean().unwrap()).abs() < 1.0e-6);let stats = inc_stats::SummStats::new();
assert!(stats.mean().is_none());sourcepub fn sum(&self) -> f64
pub fn sum(&self) -> f64
Get the sum
Constant time.
Examples
let nums = [2.0, 4.0];
let stats: inc_stats::SummStats = nums.iter().cloned().collect();
assert!((6.0 - stats.sum()).abs() < 1.0e-6);sourcepub fn standard_deviation(&self) -> Option<f64>
pub fn standard_deviation(&self) -> Option<f64>
Get the sample standard deviation
Constant time.
Examples
let nums = [2.0, 4.0];
let stats: inc_stats::SummStats = nums.iter().cloned().collect();
assert!((1.4142136 - stats.standard_deviation().unwrap()).abs() < 1.0e-6);sourcepub fn variance(&self) -> Option<f64>
pub fn variance(&self) -> Option<f64>
Get the sample variance
Constant time.
Examples
let nums = [2.0, 4.0];
let stats: inc_stats::SummStats = nums.iter().cloned().collect();
assert!((2.0 - stats.variance().unwrap()).abs() < 1.0e-6);let mut stats = inc_stats::SummStats::new();
stats.add(0.0);
assert!(stats.variance().is_none());sourcepub fn standard_error(&self) -> Option<f64>
pub fn standard_error(&self) -> Option<f64>
Get the standard error
Constant time.
Examples
let nums = [2.0, 4.0];
let stats: inc_stats::SummStats = nums.iter().cloned().collect();
assert!((1.0 - stats.standard_error().unwrap()).abs() < 1.0e-6);Trait Implementations
sourceimpl FromIterator<f64> for SummStats
impl FromIterator<f64> for SummStats
sourcefn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = f64>,
fn from_iter<I>(iter: I) -> Selfwhere
I: IntoIterator<Item = f64>,
Creates a value from an iterator. Read more
Auto Trait Implementations
impl RefUnwindSafe for SummStats
impl Send for SummStats
impl Sync for SummStats
impl Unpin for SummStats
impl UnwindSafe for SummStats
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more