pub struct RollingMean { /* private fields */ }Expand description
Rolling mean over a fixed-size window.
The window is a FIFO queue: when full, the oldest observation is removed before the newest is inserted.
§Examples
use rill_ml::stats::RollingMean;
use rill_ml::OnlineStatistic;
let mut rm = RollingMean::new(3).unwrap();
rm.update(1.0).unwrap();
rm.update(2.0).unwrap();
rm.update(3.0).unwrap();
assert!((rm.value().unwrap() - 2.0).abs() < 1e-12);
rm.update(6.0).unwrap(); // window becomes [2, 3, 6]
assert!((rm.value().unwrap() - 3.6666666666666665).abs() < 1e-12);Implementations§
Trait Implementations§
Source§impl Clone for RollingMean
impl Clone for RollingMean
Source§fn clone(&self) -> RollingMean
fn clone(&self) -> RollingMean
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RollingMean
impl Debug for RollingMean
Auto Trait Implementations§
impl Freeze for RollingMean
impl RefUnwindSafe for RollingMean
impl Send for RollingMean
impl Sync for RollingMean
impl Unpin for RollingMean
impl UnsafeUnpin for RollingMean
impl UnwindSafe for RollingMean
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