pub struct ExpWeightedMovingAvg { /* private fields */ }Expand description
Exponentially-weighted moving average with a configurable half-life.
Supports two decay modes:
- Time-based: Decay factor for elapsed time Δt is: decay = 2^(-Δt / half_life)
- Count-based: Decay factor for sample count Δn is: decay = 2^(-Δn / half_life)
Implementations§
Source§impl ExpWeightedMovingAvg
impl ExpWeightedMovingAvg
Sourcepub fn new_time_decay(half_life: Duration) -> Self
pub fn new_time_decay(half_life: Duration) -> Self
Create a new tracker with time-based decay using the given half-life.
Sourcepub fn new_count_decay(half_life_count: f64) -> Self
pub fn new_count_decay(half_life_count: f64) -> Self
Create a new tracker with count-based decay using the given half-life in number of samples.
Sourcepub fn update_with_weight(&mut self, sample: f64, weight: f64)
pub fn update_with_weight(&mut self, sample: f64, weight: f64)
Add a sample, automatically decaying existing state first.
pub fn update(&mut self, sample: f64)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ExpWeightedMovingAvg
impl RefUnwindSafe for ExpWeightedMovingAvg
impl Send for ExpWeightedMovingAvg
impl Sync for ExpWeightedMovingAvg
impl Unpin for ExpWeightedMovingAvg
impl UnsafeUnpin for ExpWeightedMovingAvg
impl UnwindSafe for ExpWeightedMovingAvg
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> DropFlavorWrapper<T> for T
impl<T> DropFlavorWrapper<T> for T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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