pub struct QuantileNormF32 { /* private fields */ }Expand description
Quantile normalizer via P² estimator grid.
Maps values to approximate uniform [0, 1] by maintaining a grid of P² percentile estimators at uniformly spaced quantile points. The normalized value is the interpolated rank within the grid.
O(resolution) per update. Requires alloc.
§Examples
use nexus_stats_core::normalization::QuantileNormF32;
let mut qn = QuantileNormF32::builder().resolution(9).build().unwrap();
for i in 0..500 {
let _ = qn.update(i as f32);
}
let v = qn.update(250.0).unwrap();
assert!(v.is_some());Implementations§
Source§impl QuantileNormF32
impl QuantileNormF32
Sourcepub fn builder() -> QuantileNormF32Builder
pub fn builder() -> QuantileNormF32Builder
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 to all grid estimators. Returns the approximate normalized rank in [0, 1] once primed.
§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>
Ranks an arbitrary value against current grid without updating state.
Returns None if not primed.
Sourcepub fn resolution(&self) -> usize
pub fn resolution(&self) -> usize
Number of quantile grid points.
Trait Implementations§
Source§impl Clone for QuantileNormF32
impl Clone for QuantileNormF32
Source§fn clone(&self) -> QuantileNormF32
fn clone(&self) -> QuantileNormF32
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 QuantileNormF32
impl RefUnwindSafe for QuantileNormF32
impl Send for QuantileNormF32
impl Sync for QuantileNormF32
impl Unpin for QuantileNormF32
impl UnsafeUnpin for QuantileNormF32
impl UnwindSafe for QuantileNormF32
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