Skip to main content

PChart

Struct PChart 

Source
pub struct PChart { /* private fields */ }
Expand description

Proportion nonconforming (P) chart.

Monitors the fraction of defective items in samples that may have different sizes. Control limits vary per subgroup when sample sizes differ.

§Formulas

  • CL = p-bar = total_defectives / total_inspected
  • UCL_i = p-bar + 3 * sqrt(p-bar * (1 - p-bar) / n_i)
  • LCL_i = max(0, p-bar - 3 * sqrt(p-bar * (1 - p-bar) / n_i))

§Examples

use u_analytics::spc::PChart;

let mut chart = PChart::new();
chart.add_sample(3, 100);  // 3 defectives out of 100
chart.add_sample(5, 100);
chart.add_sample(2, 100);
chart.add_sample(4, 100);

let p_bar = chart.p_bar().expect("should have p_bar after adding samples");
assert!(p_bar > 0.0);

§Reference

Montgomery, D.C. (2019). Introduction to Statistical Quality Control, 8th ed., Chapter 7, Section 7.3.

Implementations§

Source§

impl PChart

Source

pub fn new() -> Self

Create a new P chart.

Source

pub fn add_sample(&mut self, defectives: u64, sample_size: u64)

Add a sample with the number of defective items and the total sample size.

Ignores samples where defectives > sample_size or sample_size == 0.

Source

pub fn p_bar(&self) -> Option<f64>

Get the overall proportion defective (p-bar), or None if no data.

Source

pub fn points(&self) -> &[AttributeChartPoint]

Get all chart points.

Source

pub fn is_in_control(&self) -> bool

Check if the process is in statistical control.

Trait Implementations§

Source§

impl Default for PChart

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for PChart

§

impl RefUnwindSafe for PChart

§

impl Send for PChart

§

impl Sync for PChart

§

impl Unpin for PChart

§

impl UnwindSafe for PChart

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