pub struct ZScoreNormF64 { /* private fields */ }Expand description
Z-score normalizer backed by EWMA variance.
Returns (sample - mean) / std_dev using exponentially weighted
estimates of mean and standard deviation. Useful for online feature
normalization before feeding into adaptive filters or learners.
§Examples
use nexus_stats_core::normalization::ZScoreNormF64;
let mut zs = ZScoreNormF64::builder().span(20).build().unwrap();
for i in 0..100 {
let _ = zs.update(100.0 as f64 + i as f64);
}
let z = zs.update(150.0).unwrap();
assert!(z.is_some());Implementations§
Source§impl ZScoreNormF64
impl ZScoreNormF64
Sourcepub fn builder() -> ZScoreNormF64Builder
pub fn builder() -> ZScoreNormF64Builder
Creates a builder.
Sourcepub fn update(&mut self, sample: f64) -> Result<Option<f64>, DataError>
pub fn update(&mut self, sample: f64) -> Result<Option<f64>, DataError>
Feeds a sample. Returns the z-score once primed.
If the standard deviation is zero (constant stream), returns 0.0.
§Errors
Returns DataError::NotANumber if the sample is NaN, or
DataError::Infinite if the sample is infinite.
Sourcepub fn normalize(&self, value: f64) -> Option<f64>
pub fn normalize(&self, value: f64) -> Option<f64>
Normalizes an arbitrary value against current statistics without updating state.
Returns None if not primed.
Trait Implementations§
Source§impl Clone for ZScoreNormF64
impl Clone for ZScoreNormF64
Source§fn clone(&self) -> ZScoreNormF64
fn clone(&self) -> ZScoreNormF64
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ZScoreNormF64
impl RefUnwindSafe for ZScoreNormF64
impl Send for ZScoreNormF64
impl Sync for ZScoreNormF64
impl Unpin for ZScoreNormF64
impl UnsafeUnpin for ZScoreNormF64
impl UnwindSafe for ZScoreNormF64
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