Sample size
To estimate a mean within margin E, use n = (z * sigma / E)^2. To estimate a proportion within margin E, use n = z^2 * p * (1 - p) / E^2, with p = 0.5 when unknown. Always round up to the next whole number.
Syntax
n = (z * sigma / E)^2 or n = z^2 * p * (1 - p) / E^2| Part | What it is |
|---|---|
z | 1.645 for 90%, 1.96 for 95%, 2.576 for 99% |
sigma | a planning value for the standard deviation (pilot study or past data) |
E | the desired margin of error, in the same units as the estimate |
p | a planning value for the proportion; 0.5 is the safe (largest) choice |
Examples
Mean within 3 points, sigma = 15, 95%
n = (1.96 * 15 / 3)^2 = 9.8^2 = 96.04Result: 97
Proportion within 5 points, p unknown, 95%
n = 1.96^2 * 0.25 / 0.05^2 = 0.9604 / 0.0025 = 384.16Result: 385
Same proportion at 99%
n = 2.576^2 * 0.25 / 0.05^2 = 663.6Result: 664
Proportion within 3 points, 95%
0.9604 / 0.0009Result: 1,068 (1067.1 rounded up)
Common mistakes
- Rounding down (96.04 to 96); a sample of 96 does not reach the margin, so always round up.
- Entering E as 5 for 5 percentage points in the proportion formula; it must be 0.05.
- Using a guessed sigma that is too small; the sample ends up underpowered, so take sigma from a pilot or the upper end of past values.
Practice Sample size
These drills check your answer on live data, free, no account needed.
- Sample size for a meanA planning study puts the standard deviation of customer spend at $34.00. How many customers must be sampled to estimate mean spend within $4.00 with 99% confidence? Use z* = 2.576. Give a whole number.
- Sample size for a proportionA pollster wants to estimate the share of residents who use public transit to within 2% (a margin of 0.02) with 90% confidence. There is no prior estimate, so use the conservative p = 0.5. Use z* = 1.645. How many residents must be surveyed? Give a whole number.
Questions
Why does the proportion formula use 0.5 when p is unknown?
p(1 - p) is largest at p = 0.5, so that choice gives the biggest n and guarantees the margin whatever the true proportion turns out to be.
How does sample size for a hypothesis test differ?
A test needs power as well as significance, so the formula adds a second z for the chosen power: n = (z(alpha/2) + z(beta))^2 * sigma^2 / delta^2 per group, where delta is the effect you want to detect.
Related
- Margin of errorMargin of error is the critical value times the standard error: z times sqrt(p(1 - p) / n) for a proportion, t times s over root n for a mean. Poll examples.
- Confidence interval for a proportionHow to calculate a confidence interval for a proportion with p-hat plus or minus z times sqrt(p(1 - p) / n), worked survey examples and the conditions.
- Statistical powerStatistical power is the probability a test detects a real effect, 1 - beta. What drives it, the 80% convention and sample size formulas with examples.
- Standard errorThe standard error of the mean is s / sqrt(n); for a proportion it is sqrt(p(1 - p) / n). Worked examples, SE versus standard deviation and the Excel formula.