pub struct SimpleExponentialSmoothing { /* private fields */ }Expand description
Simple Exponential Smoothing.
Implementations§
Source§impl SimpleExponentialSmoothing
impl SimpleExponentialSmoothing
Sourcepub fn new(alpha: f64) -> Option<Self>
pub fn new(alpha: f64) -> Option<Self>
Creates a new SES smoother.
§Parameters
alpha: smoothing constant, must be in (0, 1)
Returns None if alpha is out of range or non-finite.
Sourcepub fn fit(data: &[f64]) -> Option<Self>
pub fn fit(data: &[f64]) -> Option<Self>
The smoother whose α minimises the sum of squared one-step errors on
data (from SesResult::FIRST_ERROR; module documentation).
Returns None with fewer than 2 values or a non-finite one.
use u_analytics::smoothing::SimpleExponentialSmoothing;
let data = [10.0, 12.0, 11.0, 13.0, 12.5, 13.5, 13.0, 14.0];
let ses = SimpleExponentialSmoothing::fit(&data).unwrap();
assert!(ses.alpha() > 0.0 && ses.alpha() < 1.0);Auto Trait Implementations§
impl Freeze for SimpleExponentialSmoothing
impl RefUnwindSafe for SimpleExponentialSmoothing
impl Send for SimpleExponentialSmoothing
impl Sync for SimpleExponentialSmoothing
impl Unpin for SimpleExponentialSmoothing
impl UnsafeUnpin for SimpleExponentialSmoothing
impl UnwindSafe for SimpleExponentialSmoothing
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