p Chart Calculator — Fraction Defective, Variable Sample Size
Paste the number inspected and the number defective per subgroup and get the fraction-defective chart, with limits recomputed at every subgroup size — a real staircase, not one flat limit averaged from unequal samples — and the lower limit clamped at zero, and said so.
When a p chart is the right chart
Use it when each inspected item is judged pass or fail and you want the proportion that failed: invoices with an error on them, castings scrapped, shipments delivered late, patients readmitted. One item contributes at most one to the count, however many things are wrong with it. That is what makes the statistic binomial and the limits p̄ ± 3√(p̄(1−p̄)/nᵢ).
If you are counting faults rather than failures — three scratches on one panel counting as three — the count is Poisson, not binomial, and the c chart or the u chart is the instrument. The distinction is not pedantry: it changes the variance, and therefore every limit on the page.
If your inspection quantity is genuinely fixed and the shop floor would rather read "eleven rejects" than "0.022", the np chart plots the same information as a count. It is only defined when n is constant, which is the one thing the p chart does not require.
Data
Paste straight from Excel, Minitab or a CMM export — include the header row and the columns are matched by name, in any order.
| # | Sample(opt) | Inspected | Defective | |
|---|---|---|---|---|
| 1 | ||||
| 2 | ||||
| 3 | ||||
| 4 |
0 rows of data
Loading the calculation engine…
Enter data on the left to chart it
SVG is vector — it stays sharp at any size in a report. PNG 4× is roughly 600 dpi at figure width. Every export carries the estimator, the constants and the rule set drawn inside the figure, so the file is readable on its own.
Downloads carry a small “made with spcplot.com” credit along the bottom edge. The chart on screen is never watermarked, and the credit is a credit rather than a licence restriction — the figures are yours to publish either way. A Pro or Lifetime licence removes it.
Options
This plot has no adjustable options yet.
Your measurements are processed entirely in this browser tab. Nothing you type here is uploaded, so confidential production data stays confidential.
Unequal sample sizes, and the mistake this page exists to prevent
The standard error of a proportion is √(p̄(1−p̄)/nᵢ). It depends on the size of the subgroup, so a week in which you inspected two hundred items gets wider limits than a week in which you inspected five hundred. The control limit is a step function, one step per point, and drawing it any other way is drawing a different chart.
The common wrong implementation is to take the average of the nᵢ and draw one flat pair of limits from it. It is offered as a setting by several commercial packages, it is what most spreadsheet templates do, and it is visually indistinguishable from the correct answer on tidy data — which is exactly why it survives. What it costs is false alarms on your small subgroups and missed signals on your large ones.
This tool will not draw it. What it does instead is compute what that flat limit would have been and print, on the figure, how many points it would have judged differently. On the invoice dataset the page opens with, the answer is one: a short week of 198 invoices that ran at 6.1%, comfortably inside its own limit of 6.7% and comfortably outside a flat one at 5.7%. A false alarm on a week when nothing happened.
When the lower limit hits zero
p̄ − 3√(p̄(1−p̄)/nᵢ) goes below zero whenever nᵢ is smaller than about 9(1−p̄)/p̄ — at a 3% defective rate, that is any subgroup under about three hundred items. A proportion cannot be negative, so the limit is zero, and zero is a floor rather than a control limit.
The consequence is worth stating plainly, because most tools do not: where the lower limit is clamped, the chart cannot detect an improvement. No subgroup, however good, can fall below zero. If you are running an improvement project and want to see it succeed on the chart, you need bigger subgroups.
A second consequence is arithmetical. The zone tests — Nelson 5 through 8, and the Western Electric equivalents — work in the ±1σ and ±2σ bands. Below the centre line those bands now fall outside the range the statistic can take, so those tests cannot fire for a reason that has nothing to do with your process. This tool suppresses them and prints which ones, rather than reporting them as passed.
How the centre line is computed, and why it is not the average of the pᵢ
p̄ = ΣDᵢ / Σnᵢ, pooled over the whole study. Once the subgroup sizes differ, that is not the same number as the mean of the individual pᵢ: the pooled version weights a week of five hundred invoices more heavily than a week of two hundred, which is the point. The unweighted average is a different statistic and a worse estimate of a common p.
If you already hold a value — a validated baseline, a contract level, a target agreed with a customer — set the centre line to Given and enter it. That is the "p known" case the published formulas start with, and the figure says the centre did not come from the data in front of it.
Set a baseline count to freeze the limits on the first N subgroups and judge everything after that against them. Recomputing the limits every time data arrives is how a chart is taught to absorb a shift instead of reporting it.
Reading the figure
A solid line is the centre line; dashed lines are the control limits; a point drawn in red with a number beside it has failed the test with that number. A limit segment drawn in faint grey rather than dark is a clamp, not a limit — it is the floor at zero, and the chart cannot signal past it.
The active rule set is printed under the chart, because Nelson, Western Electric and ISO 7870-2 flag different points on identical data — nine consecutive points on one side of the centre line, eight, and seven respectively. The default is Nelson test 1 alone, which is what Minitab applies out of the box, so a chart compared against an existing output should agree point for point on the first try.
Every subgroup size is printed under its own point, because on a chart with unequal subgroups that is the only thing that explains why one limit sits higher than its neighbour.
Common questions
- What is the p chart formula?
- Centre line p̄ = ΣDᵢ/Σnᵢ. Limits p̄ ± 3√(p̄(1−p̄)/nᵢ), computed separately for each subgroup size nᵢ, with the lower limit floored at 0 and the upper capped at 1. No Shewhart constant is involved — d₂ and c₄ exist to estimate σ for a normally distributed measurement, and a count of defective items is binomial, so its standard error is a known function of p̄ and nᵢ.
- Can I use a p chart when the sample size changes every time?
- Yes — that is the situation it is built for, and it is the only one of the two defectives charts that is defined then. Each point gets its own limits from its own nᵢ, which is why the limits look like a staircase. If the sizes vary enormously the chart is still correct but becomes hard to read, and some practitioners then standardise the statistic instead; this tool draws the staircase, which keeps the axis in units a reader recognises.
- Why is there no lower control limit on my p chart?
- Because p̄ − 3σᵢ came out negative and a fraction cannot be. That happens when the subgroup is small relative to the defective rate — below roughly 9(1−p̄)/p̄ items. The figure prints how far below zero the arithmetic actually went, so you can see how far from having a usable lower limit you are.
- p chart or np chart?
- If the number inspected varies at all, the p chart, because raw counts from different sample sizes are not comparable. If it is genuinely constant, either will do and they will flag exactly the same points — the np limits are the p limits multiplied by n. Choose the one whose axis your audience reads more easily.
- How many subgroups does a p chart need?
- Shewhart’s guidance is at least 25, and the figure warns below that. There is a second requirement specific to attribute charts: the subgroups have to be big enough that the expected number of defectives is at least about five, or the normal approximation behind ±3σ has nothing to stand on. The tool warns about that too rather than drawing limits whose real tail areas are nothing like the nominal ones.
- Is my data uploaded anywhere?
- No. The whole calculation runs as JavaScript in this browser tab, and nothing on this site accepts a measurement — the only server code here takes a payment. That is why the tool is usable on data you are contractually barred from putting in a cloud service.