pub struct Cusum { /* private fields */ }Expand description
One-sided upper Page CUSUM detector with Welford running statistics.
ref_shift_k is the reference shift in units of the running standard
deviation (the smallest sustained mean shift worth flagging),
alarm_h is the alarm threshold in the same units, and startup is
the number of initial observations during which alarms are suppressed
while the running statistics settle.
Implementations§
Source§impl Cusum
impl Cusum
Sourcepub fn new(ref_shift_k: f64, alarm_h: f64, startup: usize) -> Result<Self>
pub fn new(ref_shift_k: f64, alarm_h: f64, startup: usize) -> Result<Self>
Build a detector; fails when ref_shift_k is negative or
non-finite, alarm_h is non-positive or non-finite.
Sourcepub fn variance(&self) -> f64
pub fn variance(&self) -> f64
Running sample variance (M2 / (n - 1); 0 with fewer than 2 points).
Sourcepub fn status(&self) -> bool
pub fn status(&self) -> bool
Whether the detector is currently alarmed.
Live (not latched): re-evaluated on every Cusum::update as
count > startup && statistic > h * std.
Sourcepub fn update(&mut self, x: f64) -> bool
pub fn update(&mut self, x: f64) -> bool
Feed one observation; returns the resulting alarm Cusum::status.
Non-finite inputs are ignored (no state change) so a corrupt sample cannot poison the running statistics.