Skip to main content

percentile_capability

Function percentile_capability 

Source
pub fn percentile_capability(
    data: &[f64],
    lsl: Option<f64>,
    usl: Option<f64>,
) -> Result<PercentileCapabilityResult, &'static str>
Expand description

Compute percentile-based capability indices (ISO 22514-2).

Uses empirical quantiles at 0.00135 and 0.99865 (corresponding to ±3σ for normal distributions) to define the natural process spread.

§Arguments

  • data — Process observations (at least 20 data points required).
  • lsl — Lower specification limit (optional).
  • usl — Upper specification limit (optional).

§Returns

Err if:

  • Fewer than 20 data points (insufficient for extreme percentile estimation).
  • Neither usl nor lsl is provided.
  • Data contains non-finite values.
  • The percentile spread is zero or negative (degenerate data).

§Examples

use u_analytics::capability::percentile_capability;

let data: Vec<f64> = (0..100).map(|i| 10.0 + (i as f64) * 0.1).collect();
let result = percentile_capability(&data, Some(5.0), Some(15.0)).unwrap();
assert!(result.cp_star.is_some());
assert!(result.median > 0.0);