Skip to content
AITroveRead. Build. Understand.
Make this comfortable

P charts: monitor defect fractions with subgroup-specific denominators

Last updated: 7 Oct 20265 min read
tutorial
AdvancedBy AITrove Editorial

A p chart compares each subgroup defect fraction with limits that reflect its own inspection count under a stable binomial baseline.

Define a rational subgroup

A dispatch operation audits damaged parcels each week. The count inspected varies with volume and audit staffing, so a single fixed-width band around the weekly rate is inappropriate. Define each week, eligible parcel frame, defect rule, and inspection plan; count defective parcels, not the number of defect marks on parcels. Choose a baseline period judged stable before interpreting future points. A proportion interval answers uncertainty for a particular rate, while a control chart asks whether the process has changed relative to a historical baseline.

Use the actual denominator

With baseline defect fraction p, the usual binomial standard deviation for subgroup size n is the square root of p times one minus p divided by n. A three-standard-deviation upper limit therefore narrows in high-volume weeks and widens in low-volume weeks; the lower limit is truncated at zero. The code calculates this simple limit from a supplied baseline, not from the week being assessed. It does not account for overdispersion, autocorrelation, or a baseline estimated from very few weeks.

Separate a signal from the cause

A point beyond its limit is a prompt to inspect materials, routes, scanners, or sampling changes. It does not prove a particular employee or intervention caused the spike. A point inside the limits also does not prove the operation meets a customer specification; the process may be stable at an unacceptable defect rate. The diagnostic lesson checks whether the simple binomial bands are credible.

Keep chart rules prespecified

If several supplementary run rules are used, the false-alarm behavior changes. State the complete set before watching the chart, and retain each week even if it is inconvenient. A change in the damage definition or audited population requires a new baseline or a documented bridge, not silent continuation of one chart. The project gates a public quality claim on that measurement continuity.

Implementation

python
from math import sqrt

def p_chart_limits(baseline_fraction, inspected_count, width=3):
    if not 0 < baseline_fraction < 1 or inspected_count <= 0 or width <= 0:
        raise ValueError("valid baseline, count and width required")
    spread = width * sqrt(baseline_fraction *
                          (1 - baseline_fraction) / inspected_count)
    return max(0.0, baseline_fraction - spread),            min(1.0, baseline_fraction + spread)

low_small, high_small = p_chart_limits(0.04, 50)
low_large, high_large = p_chart_limits(0.04, 500)
assert high_small > high_large
assert low_small == 0

Performance and operating cost

A subgroup limit is O(1); computing w weekly points is O(w). The baseline and chart are cheap, but adjudicating a damage-rule change can be expensive. A three-sigma formula assumes a stable binomial process and can alarm too often when parcels are clustered by route.

Common Mistakes

  • Using the same control limits for weeks with very different inspected counts.
  • Treating a control limit as a customer specification.
  • Selecting a favorable baseline after seeing the new weeks.
  • Continuing one chart through a changed defect or sampling rule.

Read next

Continue the workflow: CUSUM alarms: set reference and threshold before reading the stream.

ai-data
applied-statistics
Storage details