Skip to main content

XBarRChart

Struct XBarRChart 

Source
pub struct XBarRChart { /* private fields */ }
Expand description

X-bar and Range (X-bar-R) control chart.

Monitors the process mean (X-bar chart) and process variability (R chart) using subgroup ranges. Suitable for subgroup sizes n = 2..=10.

§Algorithm

  1. For each subgroup, compute the mean (X-bar) and range (R).
  2. Compute the grand mean (X-double-bar) and average range (R-bar).
  3. X-bar chart limits: CL = X-double-bar, UCL/LCL = CL +/- A2 * R-bar.
  4. R chart limits: CL = R-bar, UCL = D4 * R-bar, LCL = D3 * R-bar.

§Examples

use u_analytics::spc::{XBarRChart, ControlChart};

let mut chart = XBarRChart::new(5);
chart.add_sample(&[25.0, 26.0, 24.5, 25.5, 25.0]);
chart.add_sample(&[25.2, 24.8, 25.1, 24.9, 25.3]);
chart.add_sample(&[25.1, 25.0, 24.7, 25.3, 24.9]);

let limits = chart.control_limits().expect("should have limits after 3 samples");
assert!(limits.ucl > limits.cl);
assert!(limits.cl > limits.lcl);

§Reference

Montgomery, D.C. (2019). Introduction to Statistical Quality Control, 8th ed., Chapter 6: Control Charts for Variables.

Implementations§

Source§

impl XBarRChart

Source

pub fn new(subgroup_size: usize) -> Self

Create a new X-bar-R chart with the given subgroup size.

§Panics

Panics if subgroup_size is not in the range 2..=10.

Source

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

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

Source

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

Get the R chart points.

Trait Implementations§

Source§

impl ControlChart for XBarRChart

Source§

fn add_sample(&mut self, sample: &[f64])

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.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V