pub struct ExponentialRunningStats { /* private fields */ }Expand description
Exponential Moving Average (EMA) running statistics for non-stationary signals.
Unlike Welford’s algorithm which weights all observations equally, EMA statistics give exponentially more weight to recent observations. This makes them suitable for tracking non-stationary distributions where the underlying mean/variance drift over time.
Update rules: mean_t = (1 - alpha) * mean_{t-1} + alpha * x_t var_t = (1 - alpha) * var_{t-1} + alpha * (x_t - mean_t)^2
The smoothing factor alpha controls the effective window:
- alpha = 2/(N+1) gives an N-step equivalent window
- Higher alpha = more responsive to change, noisier estimates
- Lower alpha = smoother estimates, slower to adapt
Implementations§
Source§impl ExponentialRunningStats
impl ExponentialRunningStats
Sourcepub fn from_window(window: usize) -> Self
pub fn from_window(window: usize) -> Self
Create from an equivalent window size N: alpha = 2 / (N + 1).
Sourcepub fn from_halflife(halflife: f64) -> Self
pub fn from_halflife(halflife: f64) -> Self
Create from a half-life (number of steps for weight to decay by 50%).
Sourcepub fn batch_update(&mut self, values: &[f64])
pub fn batch_update(&mut self, values: &[f64])
Update with a batch of observations (applied sequentially).
Trait Implementations§
Source§impl Clone for ExponentialRunningStats
impl Clone for ExponentialRunningStats
Source§fn clone(&self) -> ExponentialRunningStats
fn clone(&self) -> ExponentialRunningStats
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 moreAuto Trait Implementations§
impl Freeze for ExponentialRunningStats
impl RefUnwindSafe for ExponentialRunningStats
impl Send for ExponentialRunningStats
impl Sync for ExponentialRunningStats
impl Unpin for ExponentialRunningStats
impl UnsafeUnpin for ExponentialRunningStats
impl UnwindSafe for ExponentialRunningStats
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