pub struct ExponentialMovingAverage<const FACTOR: usize> {
count: usize,
average: f64,
}Expand description
An exponential moving average calculator.
Based on the formula:
EMA_t = EMA_{t-1} + (Value_t - EMA_{t-1}) / min(t, FACTOR)
this object maintains a running average that emphasizes recent values more heavily and creates a smooth long-tailed averaging effect over time.
Fields§
§count: usize§average: f64Implementations§
Trait Implementations§
Source§impl<const FACTOR: usize> Clone for ExponentialMovingAverage<FACTOR>
impl<const FACTOR: usize> Clone for ExponentialMovingAverage<FACTOR>
Source§fn clone(&self) -> ExponentialMovingAverage<FACTOR>
fn clone(&self) -> ExponentialMovingAverage<FACTOR>
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 moreSource§impl<const FACTOR: usize> Debug for ExponentialMovingAverage<FACTOR>
impl<const FACTOR: usize> Debug for ExponentialMovingAverage<FACTOR>
Source§impl<const FACTOR: usize> Default for ExponentialMovingAverage<FACTOR>
impl<const FACTOR: usize> Default for ExponentialMovingAverage<FACTOR>
Source§fn default() -> ExponentialMovingAverage<FACTOR>
fn default() -> ExponentialMovingAverage<FACTOR>
Returns the “default value” for a type. Read more
Source§impl<const FACTOR: usize> PartialEq for ExponentialMovingAverage<FACTOR>
impl<const FACTOR: usize> PartialEq for ExponentialMovingAverage<FACTOR>
Source§fn eq(&self, other: &ExponentialMovingAverage<FACTOR>) -> bool
fn eq(&self, other: &ExponentialMovingAverage<FACTOR>) -> bool
Tests for
self and other values to be equal, and is used by ==.impl<const FACTOR: usize> Copy for ExponentialMovingAverage<FACTOR>
impl<const FACTOR: usize> StructuralPartialEq for ExponentialMovingAverage<FACTOR>
Auto Trait Implementations§
impl<const FACTOR: usize> Freeze for ExponentialMovingAverage<FACTOR>
impl<const FACTOR: usize> RefUnwindSafe for ExponentialMovingAverage<FACTOR>
impl<const FACTOR: usize> Send for ExponentialMovingAverage<FACTOR>
impl<const FACTOR: usize> Sync for ExponentialMovingAverage<FACTOR>
impl<const FACTOR: usize> Unpin for ExponentialMovingAverage<FACTOR>
impl<const FACTOR: usize> UnwindSafe for ExponentialMovingAverage<FACTOR>
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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