Sample Size Calculator
How many observations does your study actually need? Plan it before you collect a single data point.
Confidence level
How to use the sample size calculator
- Pick a mode. Proportion if you are estimating a percentage (like voter share); Mean if you are estimating an average.
- Enter your planning values. An estimated proportion or standard deviation, the margin of error you can live with, and your confidence level.
- Press Calculate. You get the minimum sample size, the z critical value used, and the formula with your values substituted.
- Read it as a minimum. Collect at least that many observations — more is fine, fewer breaks the margin-of-error guarantee.
Frequently asked questions
How do you calculate the sample size for a proportion?
n = z² · p̂(1 − p̂) / E², where z is the critical value for your confidence level and E is the margin of error. Round the answer up to the next whole number.
Why is the default estimated proportion 0.5?
p̂(1 − p̂) is largest when p̂ = 0.5, so 0.5 gives the biggest — safest — sample size. If you have a prior estimate, use it and you will need fewer observations.
How do you calculate the sample size for a mean?
n = (z · σ / E)², where σ is your estimate of the population standard deviation and E is the margin of error. Round up, since you cannot collect a fraction of an observation.
Why is the answer always rounded up?
Because 384.16 observations is impossible, and 384 is too few to hit the margin of error. The ceiling — 385 — is the smallest whole sample that actually meets the requirement.
Does a higher confidence level need a bigger sample?
Yes. A 99% confidence level uses z = 2.576 instead of 1.96, and the critical value is squared in the formula — so 99% confidence needs about 73% more observations than 95% for the same margin of error.
More from the codex
Sample Size Calculator
How many observations your study needs.
Z-Score Calculator
Z-scores, percentiles, probabilities, and critical values.
Open tool → LiveConfidence Interval Calculator
Estimate the population mean with z or t intervals.
Open tool → LiveP-Value Calculator
Exact p-values for z and t test statistics.
Open tool →Support the codex
This tool is free, with no account and no ads. If it saved you some time, consider supporting the indie dev behind it. Questions? Email [email protected].