Skip to main content

ProcessCapability

Struct ProcessCapability 

Source
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

Source

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 usl and lsl are None
  • usl <= lsl when 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());
Source

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);
Source

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:

  • data has fewer than 2 elements
  • sigma_within is not positive or not finite
  • data contains 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);
Source

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:

  • data has fewer than 2 elements
  • data contains 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);

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V