pub struct ExponentialMovingAverage { /* private fields */ }Expand description
Exponential moving average with configurable smoothing factor α.
EMA_n = α * value + (1 - α) * EMA_{n-1}. Smaller α → smoother but slower to respond.
Implementations§
Source§impl ExponentialMovingAverage
impl ExponentialMovingAverage
Sourcepub fn new(alpha: f64) -> Self
pub fn new(alpha: f64) -> Self
Create a new EMA. alpha must be in (0, 1].
A good default for frame times is α = 0.1 (90% weight on history).
Sourcepub fn with_samples(n: f64) -> Self
pub fn with_samples(n: f64) -> Self
Create an EMA tuned to smooth over approximately n samples.
Sourcepub fn sample_count(&self) -> u64
pub fn sample_count(&self) -> u64
Number of samples seen.
Trait Implementations§
Source§impl Clone for ExponentialMovingAverage
impl Clone for ExponentialMovingAverage
Source§fn clone(&self) -> ExponentialMovingAverage
fn clone(&self) -> ExponentialMovingAverage
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 ExponentialMovingAverage
impl RefUnwindSafe for ExponentialMovingAverage
impl Send for ExponentialMovingAverage
impl Sync for ExponentialMovingAverage
impl Unpin for ExponentialMovingAverage
impl UnsafeUnpin for ExponentialMovingAverage
impl UnwindSafe for ExponentialMovingAverage
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