Skip to main content

XBarSChart

Struct XBarSChart 

Source
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

  1. For each subgroup, compute the mean (X-bar) and sample standard deviation (S).
  2. Compute the grand mean (X-double-bar) and average S (S-bar).
  3. X-bar chart limits: CL = X-double-bar, UCL/LCL = CL +/- A3 * S-bar.
  4. 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

Source

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));
Source

pub fn rules(&self) -> RuleSet

The run tests this chart applies.

Source

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.

Source

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);
Source

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.

Source

pub fn s_limits(&self) -> Option<ControlLimits>

Get the S chart control limits, or None if insufficient data.

Source

pub fn s_points(&self) -> &[ChartPoint]

Get the S chart points.

Trait Implementations§

Source§

impl Clone for XBarSChart

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ControlChart for XBarSChart

Source§

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>

Get the computed control limits, or None if insufficient data.
Source§

fn is_in_control(&self) -> bool

Check if the process is in statistical control. Read more
Source§

fn violations(&self) -> Vec<Violation>

Get all violations detected across all chart points.
Source§

fn points(&self) -> &[ChartPoint]

Get all chart points.
Source§

impl Debug for XBarSChart

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.