Sub topic 9
p Charts: Proportion of Defective Items
This chapter assumes that you know how to calculate a mean, a range, and a standard deviation. You should also understand that a process produces output over time. Basic probability for proportions is helpful. The code example assumes basic Python and NumPy.
What a p chart measures
A p chart tracks the proportion of defective items in each sample. A defective item is an item that fails a defined requirement. Each item is counted once, even if it has several defects.
For period \(i\):
\[ pi = \frac{di}{n_i} \]
where:
- \(d_i\) is the number of defective items.
- \(n_i\) is the number of items inspected.
- \(p_i\) is the observed defective proportion.
A p chart is an attribute chart because it uses classifications such as defective or acceptable rather than continuous measurements such as length or weight.
Use a p chart when:
- Each item has a binary result: defective or not defective.
- You inspect a sample during each time period.
- The sample size may change from period to period.
- You want to monitor the fraction of defective items.
Do not use a p chart to count every flaw. If one item can contain several defects and you need to track defects per item, use a u chart instead.
Center line and control limits
The center line is the overall defective proportion. It must be weighted by the number inspected:
\[ \bar p = \frac{\sumi di}{\sumi ni} \]
Do not calculate the simple average of the period proportions when sample sizes differ. That gives a small sample the same weight as a large sample.
For each period, the estimated standard error is:
\[ \sigma{pi} = \sqrt{\frac{\bar p(1-\bar p)}{n_i}} \]
The three-sigma limits are:
\[ UCLi = \bar p + 3\sigma{p_i} \]
\[ LCLi = \bar p - 3\sigma{p_i} \]
A proportion cannot be less than zero, so set a negative lower limit to zero. With very small samples, an upper limit can exceed one. Since a proportion cannot exceed one, display that limit at one or document the unbounded calculation separately.
import numpy as np
# Defectives and inspected items for eight time periods
d = np.array([4, 6, 3, 8, 5, 7, 4, 6])
n = np.array([100, 120, 90, 150, 110, 130, 100, 125])
p = d / n
p_bar = d.sum() / n.sum()
sigma_p = np.sqrt(p_bar * (1 - p_bar) / n)
ucl = p_bar + 3 * sigma_p
lcl = np.maximum(0.0, p_bar - 3 * sigma_p)
print("Center line:", p_bar)
print("Observed proportions:", p)
print("Lower limits:", lcl)
print("Upper limits:", ucl)
print("Beyond limits:", np.where((p < lcl) | (p > ucl))[0].tolist())The limits vary because the sample sizes vary. A larger sample has a smaller standard error, so its limits are closer to the center line. A smaller sample has wider limits.
Interpreting signals
A point beyond its period-specific control limit is evidence that the process may contain a special cause, such as a changed supplier, an inspection error, or a machine problem. Investigate the process at that time rather than changing the limits immediately.
A run rule can also signal a shift. For example, eight consecutive points above the center line suggest that the process may have moved upward, even when no individual point exceeds a limit.
The chart describes process stability. It does not determine whether the process meets customer requirements.
Exercise
Exercise
Eight samples contain 20 defectives among 400 inspected items in total. What is the p-chart center line, and why should the total counts be used?
Show answer
The center line is 20 / 400 = 0.05, or 5%. Total counts weight each item equally. Averaging the eight sample proportions could give the wrong result when sample sizes differ.