pub struct NPChart { /* private fields */ }Expand description
Count of nonconforming items (NP) chart.
Monitors the count of defective items in samples of constant size. Simpler than the P chart when sample sizes are uniform.
§Formulas
- CL = n * p-bar
- UCL = n * p-bar + 3 * sqrt(n * p-bar * (1 - p-bar))
- LCL = max(0, n * p-bar - 3 * sqrt(n * p-bar * (1 - p-bar)))
§Reference
Montgomery, D.C. (2019). Introduction to Statistical Quality Control, 8th ed., Chapter 7, Section 7.3.
Implementations§
Source§impl NPChart
impl NPChart
Sourcepub fn new(sample_size: u64) -> Result<Self, ControlChartError>
pub fn new(sample_size: u64) -> Result<Self, ControlChartError>
Create a new NP chart with a constant sample size.
§Errors
Returns ControlChartError::ZeroSampleSize
when sample_size == 0. The size usually comes from data, so this is an
ordinary outcome rather than a contract violation – and a boundary that
cannot unwind, such as the WebAssembly entry points, needs it as a value.
Sourcepub fn add_sample(&mut self, defectives: u64) -> Result<(), ControlChartError>
pub fn add_sample(&mut self, defectives: u64) -> Result<(), ControlChartError>
Add a defective count for one subgroup.
§Errors
ControlChartError::DefectivesExceedSampleSize
if defectives exceeds the chart’s sample size. The chart is left
unchanged.
Sourcepub fn control_limits(&self) -> Option<(f64, f64, f64)>
pub fn control_limits(&self) -> Option<(f64, f64, f64)>
Get the control limits as (ucl, cl, lcl), or None if no data.
Sourcepub fn points(&self) -> &[AttributeChartPoint]
pub fn points(&self) -> &[AttributeChartPoint]
Get all chart points.
Sourcepub fn is_in_control(&self) -> bool
pub fn is_in_control(&self) -> bool
Check if the process is in statistical control.