pub struct RollingWindow { /* private fields */ }Expand description
Exact sliding-window mean and variance over the last capacity samples.
Uses a circular buffer (VecDeque) plus Welford incremental updates on the window boundary (remove oldest, add newest) so each push is O(1) in both time and space.
Implementations§
Source§impl RollingWindow
impl RollingWindow
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Creates a rolling window with the given capacity (must be ≥ 1).
§Panics
Panics when capacity is zero.
Sourcepub fn push(&mut self, value: f64)
pub fn push(&mut self, value: f64)
Pushes a new sample into the window, evicting the oldest if full.
Sourcepub fn variance(&self) -> f64
pub fn variance(&self) -> f64
Returns the population variance of the current window.
Uses the computational formula: σ² = E[X²] − (E[X])².
Sourcepub fn min(&self) -> f64
pub fn min(&self) -> f64
Returns the minimum value in the current window, or f64::INFINITY if empty.
Trait Implementations§
Source§impl Clone for RollingWindow
impl Clone for RollingWindow
Source§fn clone(&self) -> RollingWindow
fn clone(&self) -> RollingWindow
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 RollingWindow
impl RefUnwindSafe for RollingWindow
impl Send for RollingWindow
impl Sync for RollingWindow
impl Unpin for RollingWindow
impl UnsafeUnpin for RollingWindow
impl UnwindSafe for RollingWindow
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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