pub struct XBarSChart { /* private fields */ }Expand description
X-bar and Standard Deviation (X-bar-S) control chart.
Monitors the process mean (X-bar chart) and process variability (S chart) using subgroup standard deviations. Preferred over X-bar-R for larger subgroups where range is a less efficient estimator.
§Algorithm
- For each subgroup, compute the mean (X-bar) and sample standard deviation (S).
- Compute the grand mean (X-double-bar) and average S (S-bar).
- X-bar chart limits: CL = X-double-bar, UCL/LCL = CL +/- A3 * S-bar.
- S chart limits: CL = S-bar, UCL = B4 * S-bar, LCL = B3 * S-bar.
§Reference
Montgomery, D.C. (2019). Introduction to Statistical Quality Control, 8th ed., Chapter 6: Control Charts for Variables.
Implementations§
Source§impl XBarSChart
impl XBarSChart
Sourcepub fn with_rules(self, rules: RuleSet) -> Self
pub fn with_rules(self, rules: RuleSet) -> Self
Apply only the given run tests when computing limits.
Defaults to RuleSet::shewhart – the 3-sigma test alone; the
supplementary tests raise the false alarm rate and are asked for here.
Existing points are re-evaluated, so the call may be made at any time.
§Examples
use u_analytics::spc::{XBarSChart, ControlChart, RuleSet, ViolationType};
let chart = XBarSChart::new(5).expect("5 is within range")
.with_rules(RuleSet::nelson().without(ViolationType::FourteenAlternating));Sourcepub fn new(subgroup_size: usize) -> Result<Self, ControlChartError>
pub fn new(subgroup_size: usize) -> Result<Self, ControlChartError>
Create a new X-bar-S chart with the given subgroup size.
§Errors
Returns ControlChartError::SubgroupSizeOutOfRange when
subgroup_size is outside MIN_SUBGROUP_SIZE..=MAX_SUBGROUP_SIZE.
The size is data in most callers – it comes from the measurements a
user supplied – so rejecting it is an ordinary outcome rather than a
contract violation, and a boundary that cannot unwind (WebAssembly, C)
needs it as a value.
Sourcepub fn sigma_hat(&self) -> Option<f64>
pub fn sigma_hat(&self) -> Option<f64>
Short-term (within-subgroup) sigma estimated from this chart:
sigma-hat = S-bar / c4(n).
The S-chart counterpart of XBarRChart::sigma_hat, and the estimator
preferred for larger subgroups. Returns None if there is not enough
data for control limits.
§Examples
use u_analytics::spc::{ControlChart, XBarSChart};
let mut chart = XBarSChart::new(5).expect("subgroup size is in range");
for g in [[9.9, 10.1, 10.0, 9.8, 10.2], [10.3, 9.7, 10.0, 10.1, 9.9]] {
chart.add_sample(&g).unwrap();
}
let sigma = chart.sigma_hat().expect("limits available");
assert!(sigma > 0.0);Sourcepub fn sigma_hat_df(&self) -> Option<f64>
pub fn sigma_hat_df(&self) -> Option<f64>
Degrees of freedom of sigma_hat, for Cp/Cpk
intervals: S-bar of m subgroups has squared coefficient of variation
(1 - c4^2) / (m c4^2), turned into degrees of freedom by David’s
approximation – a little under the m (n - 1) of a pooled standard
deviation.
Returns None if there is not enough data for control limits.
Sourcepub fn s_limits(&self) -> Option<ControlLimits>
pub fn s_limits(&self) -> Option<ControlLimits>
Get the S chart control limits, or None if insufficient data.
Sourcepub fn s_points(&self) -> &[ChartPoint]
pub fn s_points(&self) -> &[ChartPoint]
Get the S chart points.
Trait Implementations§
Source§impl Clone for XBarSChart
impl Clone for XBarSChart
Source§impl ControlChart for XBarSChart
impl ControlChart for XBarSChart
Source§fn add_sample(&mut self, sample: &[f64]) -> Result<(), ControlChartError>
fn add_sample(&mut self, sample: &[f64]) -> Result<(), ControlChartError>
Add a subgroup sample. The sample length must equal the chart’s subgroup size.
Source§fn control_limits(&self) -> Option<ControlLimits>
fn control_limits(&self) -> Option<ControlLimits>
None if insufficient data.