pub struct Cusum { /* private fields */ }Expand description
Page’s two-sided cumulative sum on standardised values z:
S+ = max(0, S+ + z - k) S- = max(0, S- - z - k)It alarms when a sum goes above the threshold h, then starts again from zero. The
allowance k is half the shift to detect, in standard deviations. With k = 0.5,
h = 4 it alarms about every 168 values on standard normal noise, and about 8 values
after a shift of one standard deviation; h = 5 gives about 465 and 10 (Montgomery,
Introduction to Statistical Quality Control, table 9.3).
§Examples
use backshift::{Cusum, Shift};
let mut cusum = Cusum::new(0.5, 4.0).unwrap();
assert_eq!(cusum.update(0.3), None);
let alarm = (0..10).find_map(|_| cusum.update(2.0));
assert_eq!(alarm, Some(Shift::Up));Implementations§
Source§impl Cusum
impl Cusum
Sourcepub fn new(allowance: f64, threshold: f64) -> Result<Self, FilterError>
pub fn new(allowance: f64, threshold: f64) -> Result<Self, FilterError>
A CUSUM with allowance k >= 0 and threshold h > 0, both in standard deviations.
§Errors
FilterError::InvalidParameter if k is negative or h is not positive, or either
is not finite.
Trait Implementations§
impl Copy for Cusum
impl StructuralPartialEq for Cusum
Auto Trait Implementations§
impl Forget for Cusum
impl Freeze for Cusum
impl Move for Cusum
impl RefUnwindSafe for Cusum
impl Send for Cusum
impl Sync for Cusum
impl Unpin for Cusum
impl UnsafeUnpin for Cusum
impl UnwindSafe for Cusum
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