Home / Math / Sample Size Calculator
Sample Size Calculator
Find how many responses a survey or study needs. Choose a proportion (yes/no style) or a mean, set the confidence level and margin of error, and optionally correct for a small population.
Cochran's formula for a proportion
For a yes/no question, the standard starting point is Cochran's formula: n0 = z2 × p × (1 − p) ÷ e2. Here z is the critical value for the confidence level (1.645 for 90%, 1.96 for 95%, 2.576 for 99%), p is the proportion you expect to find, and e is the margin of error written as a fraction, so 5 points becomes 0.05.
The product p × (1 − p) is largest at p = 0.5, which is why 50% is the cautious default when you have no earlier data. At 95% confidence and a 5-point margin it gives 384.16, which is rounded up to 385. Rounding always goes up, because rounding down would leave the margin slightly wider than requested.
Sample size when estimating a mean
When the quantity is a measurement such as height, test score or waiting time, the formula becomes n0 = (z × σ ÷ e)2, where σ is the standard deviation and e is the margin of error in the same units as the measurement. A wider spread in the data needs a bigger sample; a tighter margin needs far more.
The standard deviation is usually unknown before the study. Common sources are a small pilot study, earlier published work on a similar group, or a rough range-based guess. Because the result scales with the square of σ, an underestimate can leave you well short, so a modest safety allowance is sensible.
The finite population correction
Cochran's base formula assumes a population so large that sampling barely removes anyone from it. When the population is small, you can reduce the requirement with n = n0 ÷ (1 + (n0 − 1) ÷ N), where N is the population size. With n0 = 384.16 and N = 1,000 the result is about 277.7, so 278 responses suffice. For populations in the hundreds of thousands the correction is negligible.
The correction is only valid when you sample without replacement from a list of known size. If you cannot name the population size, leave the field empty and use the uncorrected figure.
What the number does not guarantee
The result is the number of completed, usable responses, not the number of invitations. Divide by the expected response rate to plan outreach. The margin of error covers random sampling variation only. It says nothing about bias from who chooses to respond, badly worded questions, or a sampling list that misses part of the population.
Results for subgroups need their own sample size: a survey sized for the whole group has a wider margin for, say, one age band. Also note that this tool uses the normal approximation, which is weak when the expected proportion is extremely close to 0 or 100 percent and the sample is small. In those cases a statistician may prefer exact binomial methods.
Worked example
A club with 1,000 members wants to estimate the share who support a change, at 95% confidence with a margin of error of 5 percentage points and no prior idea of the answer.
Inputs
| What are you estimating? | A proportion (percentage who answer yes) |
|---|---|
| Confidence level | 95% |
| Margin of error (proportion) | 5 percentage points |
| Expected proportion | 50 % |
| Population size | 1000 |
Result
Rounded up from 277.74. Plan for more if some people will not respond.
| Confidence level and z value | 95% (z = 1.96) |
|---|---|
| Formula | n0 = z² × p × (1 − p) ÷ e² = 1.96² × 0.5 × 0.5 ÷ 0.05² |
| Unrounded sample size | 384.16 |
| Population size | 1,000 |
| After finite population correction | 277.74 |
- Cochran's formula assumes simple random sampling. Clustered or stratified designs need a design-effect adjustment.
- Inflate the target by the share you expect not to respond: divide by the expected response rate.
Accuracy note: Results use standard double-precision arithmetic, so very large or very small values may be rounded. Check important results by another method.
Frequently asked questions
What sample size do I need for a 5% margin of error?
At 95% confidence with an expected proportion of 50%, you need 385 responses from a large population. A smaller expected proportion lowers the figure slightly, and a small population lowers it more.
Why is 50% used as the expected proportion?
The product p × (1 − p) peaks at 0.5, so assuming 50% gives the largest sample size. It ensures the margin of error is met whatever the true proportion turns out to be.
Does population size matter?
Only when the population is small relative to the sample. Once a population passes a few tens of thousands, the required sample barely changes, so surveying a city and a country need nearly the same number.
What is the difference between confidence level and margin of error?
The margin of error is how far the estimate may sit from the truth, while the confidence level is how often that interval method captures the truth over many repeated samples.
Should I add extra respondents for non-response?
Yes. Divide the calculated figure by your expected response rate. If you need 385 completes and expect a 40% response, invite about 963 people.
Related calculators
References and sources
- Cochran, W. G. (1977). Sampling Techniques, 3rd edition. Wiley.
- Israel, G. D. Determining Sample Size, University of Florida IFAS Extension, publication PEOD6.