pub struct ZScoreNormF32 { /* 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::ZScoreNormF32;
let mut zs = ZScoreNormF32::builder().span(20).build().unwrap();
for i in 0..100 {
let _ = zs.update(100.0 as f32 + i as f32);
}
let z = zs.update(150.0).unwrap();
assert!(z.is_some());Implementations§
Source§impl ZScoreNormF32
impl ZScoreNormF32
Sourcepub fn builder() -> ZScoreNormF32Builder
pub fn builder() -> ZScoreNormF32Builder
Creates a builder.
Sourcepub fn update(&mut self, sample: f32) -> Result<Option<f32>, DataError>
pub fn update(&mut self, sample: f32) -> Result<Option<f32>, 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: f32) -> Option<f32>
pub fn normalize(&self, value: f32) -> Option<f32>
Normalizes an arbitrary value against current statistics without updating state.
Returns None if not primed.
Trait Implementations§
Source§impl Clone for ZScoreNormF32
impl Clone for ZScoreNormF32
Source§fn clone(&self) -> ZScoreNormF32
fn clone(&self) -> ZScoreNormF32
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 ZScoreNormF32
impl RefUnwindSafe for ZScoreNormF32
impl Send for ZScoreNormF32
impl Sync for ZScoreNormF32
impl Unpin for ZScoreNormF32
impl UnsafeUnpin for ZScoreNormF32
impl UnwindSafe for ZScoreNormF32
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