pub trait SMA<T> {
// Required methods
fn push(&mut self, sample: T);
fn average(&self) -> Option<T>;
fn window_size(&self) -> usize;
fn len(&self) -> usize;
fn is_empty(&self) -> bool;
// Provided method
fn is_window_full(&self) -> bool { ... }
}
Expand description
Simple Moving Average trait.
The second-most useful filter type, bested only by coffee filters.
Required Methods§
Sourcefn average(&self) -> Option<T>
fn average(&self) -> Option<T>
Calculates the moving average value.
Returns None
if no samples were added.
Sourcefn window_size(&self) -> usize
fn window_size(&self) -> usize
Returns the window size.
Provided Methods§
Sourcefn is_window_full(&self) -> bool
fn is_window_full(&self) -> bool
Indicates whether the window is fully occupied with samples.