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
- For each subgroup, compute the mean (X-bar) and range (R).
- Compute the grand mean (X-double-bar) and average range (R-bar).
- X-bar chart limits: CL = X-double-bar, UCL/LCL = CL +/- A2 * R-bar.
- 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
impl XBarRChart
Sourcepub fn new(subgroup_size: usize) -> Self
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.
Sourcepub fn r_limits(&self) -> Option<ControlLimits>
pub fn r_limits(&self) -> Option<ControlLimits>
Get the R chart control limits, or None if insufficient data.
Sourcepub fn r_points(&self) -> &[ChartPoint]
pub fn r_points(&self) -> &[ChartPoint]
Get the R chart points.
Trait Implementations§
Source§impl ControlChart for XBarRChart
impl ControlChart for XBarRChart
Source§fn add_sample(&mut self, sample: &[f64])
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>
fn control_limits(&self) -> Option<ControlLimits>
Get the computed control limits, or
None if insufficient data.Source§fn is_in_control(&self) -> bool
fn is_in_control(&self) -> bool
Check if the process is in statistical control. Read more
Source§fn violations(&self) -> Vec<Violation>
fn violations(&self) -> Vec<Violation>
Get all violations detected across all chart points.
Source§fn points(&self) -> &[ChartPoint]
fn points(&self) -> &[ChartPoint]
Get all chart points.
Auto Trait Implementations§
impl Freeze for XBarRChart
impl RefUnwindSafe for XBarRChart
impl Send for XBarRChart
impl Sync for XBarRChart
impl Unpin for XBarRChart
impl UnwindSafe for XBarRChart
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more