From a standard deviation or a survey proportion
From a standard deviation or a survey proportion
Sample size is the number of observations you need so that an estimate from the sample lands within a chosen distance of the true population value, with a chosen level of confidence. Too few and the result is noise; too many and you have paid for precision you did not need.
Three things set the answer: how confident you want to be, how much error you can tolerate, and how variable the thing you are measuring is.
When the goal is to estimate an average — a mean weight, delivery time or test score — and you have an estimate of the population standard deviation σ:
n = (z × σ ÷ E)²
Here z is the z-score for the confidence level, σ is the standard deviation and E is the margin of error in the same units as the measurement. Always round the result up.
Worked example: test scores have a standard deviation of about 15 points and you want the sample mean within 3 points of the true mean at 95% confidence. n = (1.96 × 15 ÷ 3)² = 9.8² = 96.04, so you need 97 people.
Notice the squared term. Halving the margin of error to 1.5 points does not double the sample — it quadruples it, to 385.
When the result is a percentage — the share who answer yes, the defect rate, a conversion rate:
n = z² × p × (1 − p) ÷ E²
p is the proportion you expect, as a decimal. If you have no idea, use 0.5: it maximises p(1 − p) and so gives the largest, safest sample. At 95% confidence and a ±5% margin that is 1.96² × 0.25 ÷ 0.05² = 384.16, rounded up to 385 — the figure quoted for most opinion surveys.
| Confidence level | z-score | n for ±5% (p = 0.5) | n for ±3% (p = 0.5) |
|---|---|---|---|
| 90% | 1.645 | 271 | 752 |
| 95% | 1.960 | 385 | 1,068 |
| 99% | 2.576 | 664 | 1,844 |
The formulas above assume the population is very large. When you are sampling from a small, known group — 800 employees, 2,000 customers — you need fewer responses, because each one covers a meaningful share of the whole:
n = n₀ ÷ (1 + (n₀ − 1) ÷ N)
n₀ is the uncorrected sample size and N is the population. For N = 2,000 and n₀ = 384.16 the corrected sample is 384.16 ÷ 1.1916 = 322.4, so 323. For populations above roughly 20,000 the correction barely changes the answer, which is why a national poll needs about the same sample as a city poll.
The formula needs σ before any data has been collected, which looks circular. In practice there are three sources: a previous study of the same measurement, a small pilot sample (calculate it with the standard deviation calculator), or the range rule of thumb — roughly (largest plausible value − smallest) ÷ 4.
If you are unsure, overestimate. A standard deviation that is too large only costs a few extra observations; one that is too small leaves you with a margin of error wider than you planned.
Sample size controls random sampling error only. It does nothing for a biased sample: 5,000 responses from a self-selected group can be less accurate than 400 chosen at random. Also allow for non-response — if you expect 30% of people to reply, invite n ÷ 0.30. For clinical trials and A/B tests, which compare two groups and need a power calculation, use a method designed for that purpose and consult a statistician.
Use n = (z times sigma divided by E) squared, where z is the z-score for your confidence level, sigma is the standard deviation and E is the margin of error. Round the result up to the next whole number.
385 for a large population, using the proportion formula with p = 0.5. For a smaller, known population the finite population correction reduces it, for example to 323 for a population of 2,000.
Because p times (1 minus p) is largest at 0.5, which produces the largest required sample. Any other true proportion would need fewer responses, so 0.5 is the safe choice.
Only up to a point. Once the population is above about 20,000 the required sample barely changes, because sampling error depends on the size of the sample, not the size of the population.
Rounding down would give a margin of error slightly wider than the one you specified. Rounding up guarantees the target precision is met.