A p-chart monitors a binary outcome share and changes its limits with each period’s eligible count, because a small day is noisier than a large one.
P-charts with changing daily denominators
Pool the baseline by cases
For five baseline support days, late and eligible counts are (5,100), (7,120), (6,110), (4,90) and (8,130). The pooled baseline late share is 30/550, about 0.0545. Averaging five daily percentages equally would give small days the same weight as large days and answer a different question. The pooled share is the center line when each eligible case is the Bernoulli unit and baseline periods are comparable. Eligibility rules belong in the chart contract.
Recompute limits by day size
For a new day with n eligible cases, the simple three-sigma p-chart upper limit is center plus three times the square root of center times (one minus center) divided by n. The lower limit subtracts the same term, clipped at zero; the upper limit is clipped at one. With 140 cases, 12 late responses yield about 0.0857, below the illustrative upper limit. Twenty-one late responses yield 0.15 and exceed it. A 40-case day needs wider limits than a 140-case day.
State the distribution assumptions
The basic calculation treats cases in a subgroup as Bernoulli trials with a common baseline probability and enough independence for the binomial variance. Repeated contacts from one customer, different queue mixes, and day-level common shocks can produce overdispersion. If those dominate, a simple p-chart may alert too often. Segment comparable queues or use a model that reflects the dependence, and validate the resulting false-alarm behavior on held-out baseline periods.
Distinguish early warning from root cause
A point above the upper limit is a signal to inspect, not a verdict that staff performed badly. First reconcile eligible counts, missing event timestamps, case creation times and routing versions. Then look at queue mix and known incidents. A rate below the lower limit also matters: it may reflect improvement or a logging outage that stopped recording late cases. The investigation lesson preserves the evidence trail.
Freeze parameters for monitoring
Estimate the center from a designated baseline and store its version. During monitoring, hold that center fixed while each new day’s n changes its limits. Recomputing the center after every alert can absorb a real shift into the baseline and erase evidence. Periodically review the model with a documented change process, especially after policy or instrumentation changes. EWMA monitoring asks a different question about smaller sustained shifts.
Implementation
from math import sqrt
def pooled_late_rate(baseline_days):
if not baseline_days or any(total <= 0 or not 0 <= late <= total
for late, total in baseline_days):
raise ValueError("invalid baseline")
return sum(late for late, _ in baseline_days) / sum(total for _, total in baseline_days)
def p_chart_signal(late_cases, eligible_cases, baseline_rate):
if eligible_cases <= 0 or not 0 <= late_cases <= eligible_cases:
raise ValueError("invalid daily counts")
if not 0 <= baseline_rate <= 1:
raise ValueError("invalid baseline rate")
spread = 3 * sqrt(baseline_rate * (1 - baseline_rate) / eligible_cases)
lower = max(0.0, baseline_rate - spread)
upper = min(1.0, baseline_rate + spread)
rate = late_cases / eligible_cases
return rate, lower, upper, rate < lower or rate > upper
baseline = [(5, 100), (7, 120), (6, 110), (4, 90), (8, 130)]
center = pooled_late_rate(baseline)
assert center == 30 / 550
assert not p_chart_signal(12, 140, center)[3]
assert p_chart_signal(21, 140, center)[3]Performance and operating cost
Pooling B baseline days is O(B) time and O(1) additional space. Scanning D monitoring days is O(D). The simple limits can misbehave with tiny expected counts, clustering or changing case mix; validating the chart model costs more than the arithmetic.
Common Mistakes
- Do not average daily percentages equally when estimating a case-level center.
- Do not reuse a fixed daily limit when eligible counts change.
- Do not assume a binomial model remains valid under strong within-day dependence.
