Normalize nonconformity counts by inspected units and compute exposure-specific limits from a frozen baseline.
U charts: monitor defect counts when inspection exposure changes
Count defects, not defective units
A U chart monitors the rate of counted nonconformities per inspection unit when the number of inspected units changes by period. One unit can carry more than one defect. If the question instead asks whether each unit is defective at least once, count units with any defect and consider a proportion chart; the numerator cannot exceed the denominator there. Define an inspection unit consistently: one shipment, one component or one fixed area. A day with more inspected shipments naturally has more total findings even at an unchanged defect rate, which is why a raw-count line misleads. Record defect definitions, inspection coverage, sampling plan and the exposure denominator alongside each point. P charts treat a binary outcome per unit, while grain and denominator rules secure the rate.
Pool the baseline by exposure
Estimate the reference rate as total baseline defects divided by total baseline inspected units. Do not average the individual period rates without weights; a shift inspecting 47 units should not count as much as one inspecting 131 units. Under the illustrative Poisson-count model, each period's rate has an upper limit of center plus three times the square root of center divided by that period's exposure. The lower limit is the same subtraction clipped to zero. Limits widen with smaller exposure, so drawing a single horizontal upper line across changing sample sizes gives the wrong alert rule. Freeze baseline periods and limits before monitoring; the later signal should not teach the baseline to accept itself. Individuals charts monitor a different continuous-measure situation, and export metadata should retain the baseline revision.
Check the count model before operational alarms
The simple limits assume approximately independent defects at a stable rate with Poisson-like variation after exposure normalization. Clusters, batches, changing severity mix, repeated inspection of the same unit or overdispersion can make the nominal limits too narrow. Very low expected counts also make symmetric three-standard-deviation approximations rough; a calibrated count method may be preferable. Inspect residual patterns, baseline stability and known process changes before deploying alerts. A point beyond a limit is an investigation signal, not proof that its batch fails a customer specification. A rate can fall below the lower limit because inspection has changed or a real improvement has occurred; do not automatically suppress lower-side signals. CUSUM and EWMA can be considered for sustained small shifts after their assumptions are checked.
Make every alert traceable
The chart should expose period ID, defects counted, units inspected, observed defects per unit, center, lower and upper limit and the exact rule used. Include an annotation when inspection policy or defect taxonomy changes. One unusually high day should prompt a check of source counts and exposure before a process explanation. Compare groups only if the inspection unit and coverage are compatible; a warehouse with twice the inspection depth can appear worse because it detects more issues, not because it generates more. Use a table and explicit alert label so a reader need not rely on color. Accessible text and gap handling help keep the chart auditable.
Worked contract
from math import isfinite, sqrt
def defect_rate_ledger(baseline: list[tuple[str, int, int]],
monitoring: list[tuple[str, int, int]]):
if len(baseline) < 5:
raise ValueError("baseline needs at least five periods for this demonstration")
seen = set()
for period_id, defects, inspected_units in baseline + monitoring:
if (not period_id or period_id in seen or
not isinstance(defects, int) or defects < 0 or
not isinstance(inspected_units, int) or inspected_units <= 0):
raise ValueError("period IDs, counts and exposure must be valid")
seen.add(period_id)
center = sum(row[1] for row in baseline) / sum(row[2] for row in baseline)
if not isfinite(center) or center <= 0:
raise ValueError("a positive baseline defect rate is required")
plotted = []
for period_id, defects, inspected_units in monitoring:
observed = defects / inspected_units
spread = 3 * sqrt(center / inspected_units)
lower, upper = max(0.0, center - spread), center + spread
plotted.append((period_id, defects, inspected_units,
observed, lower, upper,
observed < lower or observed > upper))
return center, plotted
reference = [("shift-47", 2, 47), ("shift-59", 3, 59),
("shift-83", 1, 83), ("shift-97", 4, 97),
("shift-131", 2, 131)]
new_shifts = [("shift-149", 8, 47), ("shift-173", 3, 131)]
center, points = defect_rate_ledger(reference, new_shifts)
assert abs(center - 12 / 417) < 1e-12
assert points[0][-1] is True and points[1][-1] is False
assert points[0][5] > points[1][5]
assert points[0][4] == points[1][4] == 0.0Performance and operating cost
With B baseline periods and M monitoring periods, validation, pooled-rate calculation and alert generation take O(B + M) time. The identifier set uses O(B + M) space and the returned plot ledger O(M); a trusted unique-ID stream could reduce additional state. The sample pools 12 findings over 417 inspected units, then flags eight findings among 47 units while three among 131 units remains within its narrower exposure-specific limits. Five baseline periods are an arithmetic demonstration, not a reliable operating baseline. Validate enough stable history and the Poisson dispersion assumption before turning a flag into an alert.
Common Mistakes
- Counting nonconforming units as defects when one unit can have several findings.
- Averaging daily defect rates without weighting by inspected units.
- Using one fixed upper limit while exposure changes substantially.
- Interpreting a statistical signal as proof of product failure or a named cause.
Validation drill
Freeze 47 stable inspection shifts and monitor 83 later shifts with changing unit counts. Reconcile every defect and exposure value, plot each point's own limits, and log investigations for signals after checking for clustered findings.
