#[repr(C, align(64))]pub struct OnlineStats { /* private fields */ }Expand description
Online state for computing mean, variance and standard deviation.
Optimized memory layout for better cache performance:
- 64-byte alignment for cache line efficiency
- Grouped related fields together
- Uses bit flags to reduce padding overhead
Implementations§
Source§impl OnlineStats
impl OnlineStats
Sourcepub fn new() -> OnlineStats
pub fn new() -> OnlineStats
Create initial state.
Population size, variance and mean are set to 0.
Sourcepub fn from_slice<T: ToPrimitive>(samples: &[T]) -> OnlineStats
pub fn from_slice<T: ToPrimitive>(samples: &[T]) -> OnlineStats
Initializes OnlineStats from a sample.
Sourcepub fn harmonic_mean(&self) -> f64
pub fn harmonic_mean(&self) -> f64
Return the current harmonic mean.
Sourcepub fn geometric_mean(&self) -> f64
pub fn geometric_mean(&self) -> f64
Return the current geometric mean.
Sourcepub fn add<T: ToPrimitive>(&mut self, sample: &T)
pub fn add<T: ToPrimitive>(&mut self, sample: &T)
Add a new sample.
Sourcepub fn add_f64(&mut self, sample: f64)
pub fn add_f64(&mut self, sample: f64)
Add a new f64 sample. Skipping the ToPrimitive conversion.
Trait Implementations§
Source§impl Clone for OnlineStats
impl Clone for OnlineStats
Source§fn clone(&self) -> OnlineStats
fn clone(&self) -> OnlineStats
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Commute for OnlineStats
impl Commute for OnlineStats
Source§impl Debug for OnlineStats
impl Debug for OnlineStats
Source§impl Default for OnlineStats
impl Default for OnlineStats
Source§fn default() -> OnlineStats
fn default() -> OnlineStats
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for OnlineStats
impl<'de> Deserialize<'de> for OnlineStats
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<T: ToPrimitive> Extend<T> for OnlineStats
impl<T: ToPrimitive> Extend<T> for OnlineStats
Source§fn extend<I: IntoIterator<Item = T>>(&mut self, it: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, it: I)
Extends a collection with the contents of an iterator. Read more
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
🔬This is a nightly-only experimental API. (
extend_one)Extends a collection with exactly one element.
Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
🔬This is a nightly-only experimental API. (
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
Source§impl<T: ToPrimitive> FromIterator<T> for OnlineStats
impl<T: ToPrimitive> FromIterator<T> for OnlineStats
Source§fn from_iter<I: IntoIterator<Item = T>>(it: I) -> OnlineStats
fn from_iter<I: IntoIterator<Item = T>>(it: I) -> OnlineStats
Creates a value from an iterator. Read more
Source§impl PartialEq for OnlineStats
impl PartialEq for OnlineStats
Source§impl Serialize for OnlineStats
impl Serialize for OnlineStats
impl Copy for OnlineStats
impl StructuralPartialEq for OnlineStats
Auto Trait Implementations§
impl Freeze for OnlineStats
impl RefUnwindSafe for OnlineStats
impl Send for OnlineStats
impl Sync for OnlineStats
impl Unpin for OnlineStats
impl UnwindSafe for OnlineStats
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more