pub struct RuleSet { /* private fields */ }Expand description
A chosen subset of the eight run tests.
Each test reports exactly one ViolationType, so a rule is named by what
it would report rather than by a parallel enum that would have to be kept in
step with this one.
nelson and western_electric
are the two named sets in the literature; any other combination is built from
the tests a process actually warrants. A rule that a process is known to
trigger for a benign reason – a deliberately drifting tool, a bimodal
fixture – otherwise has to be filtered out downstream, after it has already
been counted as an out-of-control signal.
§Examples
use u_analytics::spc::{RuleSet, RunRule, ChartPoint, ControlLimits, ViolationType};
// Only the 3-sigma test, and nothing else.
let rules = RuleSet::from_iter([ViolationType::BeyondLimits]);
let limits = ControlLimits { ucl: 28.0, cl: 25.0, lcl: 22.0 };
let points: Vec<ChartPoint> = (0..12)
.map(|i| ChartPoint { value: 26.0, index: i, violations: vec![] })
.collect();
// Twelve points above the centre line would trip Nelson rule 2, but that
// test is not in this set.
assert!(rules.check(&points, &limits).is_empty());
assert!(RuleSet::nelson().check(&points, &limits).len() > 0);Implementations§
Source§impl RuleSet
impl RuleSet
Sourcepub fn nelson() -> Self
pub fn nelson() -> Self
All eight tests – Nelson (1984). This is what every chart applies unless told otherwise, so the default behaviour is unchanged.
Sourcepub fn western_electric() -> Self
pub fn western_electric() -> Self
The four Western Electric tests: Nelson rules 1, 2, 5 and 6.
Sourcepub fn none() -> Self
pub fn none() -> Self
The empty set: no run test is applied.
Useful as a base to add to, and as the honest way to say “limits only”.
Sourcepub fn contains(&self, rule: ViolationType) -> bool
pub fn contains(&self, rule: ViolationType) -> bool
Whether this set applies the test that reports rule.
Sourcepub fn with(self, rule: ViolationType) -> Self
pub fn with(self, rule: ViolationType) -> Self
This set with rule added.
Sourcepub fn without(self, rule: ViolationType) -> Self
pub fn without(self, rule: ViolationType) -> Self
This set with rule removed.
Sourcepub fn iter(&self) -> impl Iterator<Item = ViolationType> + '_
pub fn iter(&self) -> impl Iterator<Item = ViolationType> + '_
The tests in this set, in Nelson’s numbering.
Trait Implementations§
impl Copy for RuleSet
Source§impl Default for RuleSet
impl Default for RuleSet
Source§fn default() -> Self
fn default() -> Self
RuleSet::nelson – the behaviour every chart had before rule
selection existed.