Struct inc_stats::SummStats [−][src]
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 mut stats = inc_stats::SummStats::new(); for &num in &[2.0, 4.0, 8.0] { stats.add(num); } assert_eq!(3, stats.count());
let stats: inc_stats::SummStats = [2.0, 4.0, 8.0].iter().collect(); assert_eq!(3, stats.count());
Implementations
impl<T: Float + FromPrimitive + AddAssign> SummStats<T>[src]
pub fn new() -> Self[src]
Create a new SummStats struct with no data
pub fn add(&mut self, bval: impl DerefCopy<Output = T>)[src]
Add a number
Examples
let mut stats = inc_stats::SummStats::new(); stats.add(0.0); stats.add(&1.2); assert_eq!(2, stats.count());
Panics
when the internal count can’t be converted into the float data type.
pub fn checked_add(
&mut self,
rval: impl DerefCopy<Output = T>
) -> Result<(), StatsError>[src]
&mut self,
rval: impl DerefCopy<Output = T>
) -> Result<(), StatsError>
Add a number
Check for conversion errors, will only happen when the internal count can’t be converted into the float data type.
Examples
let mut stats = inc_stats::SummStats::new(); stats.checked_add(0.0).unwrap(); assert_eq!(1, stats.count());
pub fn count(&self) -> u64[src]
Get the number of values added
pub fn min(&self) -> Option<T>[src]
Get the minimum non nan value
Constant time. If no non nan values have been added, this is None.
Examples
let stats: inc_stats::SummStats = [2.0, 4.0, std::f64::NAN].iter().collect(); assert_eq!(2.0, stats.min().unwrap());
let mut stats = inc_stats::SummStats::new(); stats.add(std::f64::NAN); assert!(stats.min().is_none());
pub fn max(&self) -> Option<T>[src]
Get the maximum non nan value
Constant time. If no non nan values have been added, this is None.
Examples
let stats: inc_stats::SummStats = [2.0, 4.0, std::f64::NAN].iter().collect(); assert_eq!(4.0, stats.max().unwrap());
pub fn mean(&self) -> Option<T>[src]
Get the mean
Constant time.
Examples
let stats: inc_stats::SummStats = [2.0, 4.0].iter().collect(); assert!((3.0 - stats.mean().unwrap()).abs() < 1.0e-6);
let stats = inc_stats::SummStats::<f64>::new(); assert!(stats.mean().is_none());
pub fn sum(&self) -> T[src]
Get the sum
Constant time.
Examples
let stats: inc_stats::SummStats = [2.0, 4.0].iter().collect(); assert!((6.0 - stats.sum()).abs() < 1.0e-6);
pub fn standard_deviation(&self) -> Option<T>[src]
Get the sample standard deviation
Constant time.
Examples
let stats: inc_stats::SummStats = [2.0, 4.0].iter().collect(); assert!((1.4142136 - stats.standard_deviation().unwrap()).abs() < 1.0e-6);
pub fn variance(&self) -> Option<T>[src]
Get the sample variance
Constant time.
Examples
let stats: inc_stats::SummStats = [2.0, 4.0].iter().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());
pub fn standard_error(&self) -> Option<T>[src]
Get the standard error
Constant time.
Examples
let stats: inc_stats::SummStats = [2.0, 4.0].iter().collect(); assert!((1.0 - stats.standard_error().unwrap()).abs() < 1.0e-6);
Trait Implementations
impl<T: Debug + Float + FromPrimitive + AddAssign> Debug for SummStats<T>[src]
impl<T: Float + FromPrimitive + AddAssign> Default for SummStats<T>[src]
impl<T: Float + FromPrimitive + AddAssign, V: DerefCopy<Output = T>> FromIterator<V> for SummStats<T>[src]
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = V>, [src]
I: IntoIterator<Item = V>,
Auto Trait Implementations
impl<T> RefUnwindSafe for SummStats<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for SummStats<T> where
T: Send,
T: Send,
impl<T> Sync for SummStats<T> where
T: Sync,
T: Sync,
impl<T> Unpin for SummStats<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for SummStats<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,