When observed defect fractions vary more than an independent binomial model predicts, standard p-chart limits can create misleading alarms.
Process charts: test extra variation before blaming a weekly signal
Look beyond one plotted point
A weekly parcel audit may sample many parcels from the same truck, supplier lot, or route. Those parcels share handling conditions, so their defect outcomes can move together. A binomial chart that treats them as independent has limits that are too narrow. Different inspectors may also apply the damage definition differently; a sudden apparent improvement could be a labeling change. Compare subgroup composition, route mix, inspector assignments, and audit coverage before attributing a signal to operations. The p-chart lesson states the simple reference model.
Calculate a rough dispersion diagnostic
For each week, compare its defect count with n times the baseline fraction, scaled by the binomial variance n p(1-p). Summing these standardized squared residuals and dividing by a stated degrees-of-freedom value gives a rough dispersion statistic. Values well above one suggest more variation than that simple model expects. The code uses k minus one because the pooled baseline is estimated from the same k weeks; it is a screening calculation, not an automatic formal test or a license to widen limits until anomalies disappear.
Separate stable heterogeneity from a real shift
Extra variation may reflect stable route differences, an unstable process, or data collection artifacts. Stratify by prespecified operational groups or use an approach that respects clustering, then rebuild a stable baseline. If the process itself drifted throughout the baseline, a larger dispersion factor hides the instability rather than correcting it. The clustering lesson connects shared units to understated uncertainty; serial dependence matters across weeks.
Monitor the measurement process too
Audit a sample of images under one damage rubric and track disagreement by inspector and week. A process chart on defect labels cannot distinguish product quality from a new interpretation of damage without such checks. Report both the operational trend and the measurement audit. The project holds a quality claim if route clustering or a rubric switch has not been reconciled, even if a simple control chart appears favorable.
Implementation
def rough_binomial_dispersion(weekly_counts):
if len(weekly_counts) < 2 or any(n <= 0 or not 0 <= defects <= n
for defects, n in weekly_counts):
raise ValueError("at least two valid weeks required")
total_defects = sum(defects for defects, _ in weekly_counts)
total_inspected = sum(n for _, n in weekly_counts)
baseline = total_defects / total_inspected
if not 0 < baseline < 1:
raise ValueError("baseline needs both outcomes")
pearson_sum = sum((defects - n * baseline) ** 2 /
(n * baseline * (1 - baseline))
for defects, n in weekly_counts)
return pearson_sum / (len(weekly_counts) - 1)
assert rough_binomial_dispersion([(4, 100), (4, 100)]) == 0
assert rough_binomial_dispersion([(1, 100), (9, 100)]) > 1
Performance and operating cost
The diagnostic is O(w) time and O(1) extra space for w weeks. Better chart design may need route-level records and a different variance model. Inflating bands after seeing an inconvenient alarm is cheap but erases the intended monitoring rule.
Common Mistakes
- Treating many parcels from one truck as independent observations.
- Calling every out-of-limit week a process failure without checking sampling.
- Using overdispersion to justify hiding a baseline that was already drifting.
- Ignoring inspector or rubric changes when labels define the measured outcome.
Read next
- P charts: monitor defect fractions with subgroup-specific denominators
- Project: monitor parcel damage without confusing mix and measurement shifts
- Standard error and cluster bootstrap: resample the independent unit
- Serial correlation: daily rows are not daily independent evidence
- Reviewer agreement: inspect confusion cells before one kappa number
Continue the workflow: Repeatability: pool within-item variation without hiding drift.
