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 calculation.
If not set, the target defaults to the midpoint (USL + LSL) / 2
when both limits are available. Cpm is not computed for one-sided
specifications without an explicit target.
§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 capability indices using overall sigma for both short-term and long-term estimates.
Use this when no within-group sigma estimate is available (e.g., no rational subgrouping). Both Cp/Cpk and Pp/Ppk will use the same sigma, so Cp == Pp and Cpk == Ppk.
§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();
// When using overall sigma for both, Cp == Pp
assert!((indices.cp.unwrap() - indices.pp.unwrap()).abs() < 1e-15);