Sample size calculator for a proportion
Enter the confidence level, the margin of error you can accept and your best guess of the rate, such as a defect rate. The calculator returns the sample size needed to estimate that proportion, n = z² p(1 − p) / E², rounded up, and reduces it with the finite population correction if you give a population size.
Sample size
- Sample size
- -
- Before population adjustment
- -
The formulas
n₀ = z² × p(1 − p) / E²
with a population N: n = n₀ / (1 + (n₀ − 1) / N)
z is 1.645 for 90% confidence, 1.960 for 95% and 2.576 for 99%. p is the expected rate and E the margin of error, both as fractions. Round up: a sample of 384.1 needs 385.
Worked example
You want to estimate the share of returned units with a cosmetic defect, within plus or minus 5 points at 95% confidence, and you have no idea of the rate, so you use 50%.
- n₀ = 1.96² × 0.5 × 0.5 / 0.05² = 384.1, so sample 385.
- If there are only 2,000 returned units in total: n = 384.1 / (1 + 383.1 / 2,000) = 322.4, so sample 323.
What the margin of error means
If you found 40 defective in a sample of 385, the estimate is 10.4%, and with this sample size the true rate is likely to lie within about 5 points of the estimate at the confidence you chose. The margin is widest at 50%, so for rates far from 50% the real margin will be tighter than the one you entered.
Questions
Why is 50% the default expected rate?
Because p times (1 minus p) is largest at 50%, so it gives the biggest, safest sample when you have no idea what the rate is. If you know the rate is near 2%, entering 2 gives a much smaller sample for the same margin.
Is this the right tool for accepting or rejecting a lot?
No. This sizes a sample to estimate a rate within a margin of error. To decide whether to accept a lot against an AQL, use a sampling plan from the AQL calculator, and check its OC curve.
When should I enter the population size?
When the sample would be a noticeable share of the whole, roughly 5% or more. The finite population correction then reduces the sample. For a large or continuous process, leave it blank.
Revision 24 Nov 2026: the margin and rate are entered as percentages, and the population correction was added.
Next frame Yours
Tell me what you are building.
A website for your business, an app, a tool your team needs, or a calculator that should exist. I read every message myself and reply within one business day.
Or write to me directly:
corey@forgedev.studio