pub struct ProcessCapability { /* private fields */ }Expand description
Input specification for process capability analysis.
Defines the upper and/or lower specification limits and an optional target value. At least one specification limit must be provided.
§Examples
use u_analytics::capability::ProcessCapability;
// Two-sided specification: LSL = 9.0, USL = 11.0
let spec = ProcessCapability::new(Some(11.0), Some(9.0)).unwrap();
let data = [9.5, 10.0, 10.2, 9.8, 10.1, 10.3, 9.9, 10.0];
let indices = spec.compute(&data, 0.15).unwrap();
assert!(indices.cp.is_some());
assert!(indices.cpk.is_some());Implementations§
Source§impl ProcessCapability
impl ProcessCapability
Sourcepub fn new(usl: Option<f64>, lsl: Option<f64>) -> Result<Self, &'static str>
pub fn new(usl: Option<f64>, lsl: Option<f64>) -> Result<Self, &'static str>
Creates a new process capability specification.
At least one of usl or lsl must be Some. If both are provided,
usl must be greater than lsl.
§Errors
Returns an error string if:
- Both
uslandlslareNone usl <= lslwhen both are provided- Either limit is non-finite (NaN or infinity)
§Examples
use u_analytics::capability::ProcessCapability;
// Two-sided
let spec = ProcessCapability::new(Some(10.0), Some(5.0)).unwrap();
// Upper limit only
let spec = ProcessCapability::new(Some(10.0), None).unwrap();
// Lower limit only
let spec = ProcessCapability::new(None, Some(5.0)).unwrap();
// Error: no limits
assert!(ProcessCapability::new(None, None).is_err());
// Error: USL <= LSL
assert!(ProcessCapability::new(Some(5.0), Some(10.0)).is_err());Sourcepub fn with_target(self, target: f64) -> Self
pub fn with_target(self, target: f64) -> Self
Sets the target value for Cpm.
Cpm is computed only against a declared target. Without one it is
None rather than measured against the specification midpoint: a
substituted target cannot be told apart from a declared one in the
result. A process whose target is the midpoint passes it here.
§Examples
use u_analytics::capability::ProcessCapability;
let spec = ProcessCapability::new(Some(11.0), Some(9.0))
.unwrap()
.with_target(10.0);Sourcepub fn compute(
&self,
data: &[f64],
sigma_within: f64,
) -> Option<CapabilityIndices>
pub fn compute( &self, data: &[f64], sigma_within: f64, ) -> Option<CapabilityIndices>
Computes all capability indices using the provided within-group sigma.
The sigma_within parameter represents the short-term (within-group)
standard deviation, typically estimated from a control chart as R-bar/d2
or S-bar/c4.
The overall (long-term) standard deviation is computed from the data using the sample standard deviation.
§Returns
None if:
datahas fewer than 2 elementssigma_withinis not positive or not finitedatacontains NaN or infinity values
§Examples
use u_analytics::capability::ProcessCapability;
let spec = ProcessCapability::new(Some(11.0), Some(9.0)).unwrap();
let data = [9.5, 10.0, 10.2, 9.8, 10.1, 10.3, 9.9, 10.0];
let sigma_within = 0.15; // from control chart
let indices = spec.compute(&data, sigma_within).unwrap();
assert!(indices.cp.unwrap() > 0.0);
assert!(indices.cpk.unwrap() > 0.0);
assert!(indices.pp.unwrap() > 0.0);
assert!(indices.ppk.unwrap() > 0.0);Sourcepub fn compute_overall(&self, data: &[f64]) -> Option<CapabilityIndices>
pub fn compute_overall(&self, data: &[f64]) -> Option<CapabilityIndices>
Computes the long-term (performance) indices only.
Use this when no within-subgroup sigma is available – a flat vector
with no rational subgrouping. Pp/Ppk/Ppu/Ppl come from the overall
sample standard deviation, and Cpm from the spread about the target,
as in ProcessCapability::compute. The short-term quartet
(cp, cpk, cpu, cpl) and std_dev_within are None: filling
them from the overall sigma would make cp equal pp for every
input, a long-term number under a short-term name. To report Cp/Cpk,
estimate the within sigma from a control chart (R-bar/d2, S-bar/c4 or
MR-bar/d2) and call ProcessCapability::compute.
§Returns
None if:
datahas fewer than 2 elementsdatacontains NaN or infinity values
§Examples
use u_analytics::capability::ProcessCapability;
let spec = ProcessCapability::new(Some(11.0), Some(9.0)).unwrap();
let data = [9.5, 10.0, 10.2, 9.8, 10.1, 10.3, 9.9, 10.0];
let indices = spec.compute_overall(&data).unwrap();
assert!(indices.pp.unwrap() > 0.0);
// No within sigma, so no short-term index is claimed.
assert!(indices.cp.is_none());
assert!(indices.std_dev_within.is_none());