What is a Sample Size Calculator?
A sample size calculator tells you how many responses or participants a study needs before you collect any data. To estimate a proportion or a mean, it finds the n that gives a chosen margin of error at a chosen confidence level: a survey at 95% confidence and ±5% needs 385 responses, or 323 from a population of 2,000. To compare two means or two proportions, it finds the n per group that gives a chosen power to detect a stated difference at significance level α. Results are always rounded up.
What the Sample Size Calculator does
Start with the Goal. If you want to describe a population, such as the share of customers who are satisfied or the average waiting time, choose one of the two estimation goals and enter a confidence level and margin of error. If you want to detect a difference between two groups, such as treatment versus control or version A versus version B, choose one of the two comparison goals and enter α, the power you want and the difference you expect. The calculator returns the required sample size, the per-group and total numbers for comparisons, every intermediate value, and a table showing how the answer changes with the margin of error or the power.
Use it as a survey sample size calculator, a minimum sample size calculator for a thesis, or a power analysis calculator for a statistically significant comparison. If you already have a sample and want to know how precise it is, work the other way with the Margin of Error Calculator.
The four goals cover most first-pass planning for surveys, experiments and A/B tests. The estimation formulas are the same normal-approximation formulas used by the Cochran’s formula calculator, which goes deeper on survey sampling. The comparison formulas are the standard normal-approximation power formulas; they give a quick, transparent answer, and exact t-based or exact binomial planning will ask for slightly more.
How to use the Sample Size Calculator
- Choose the Goal: estimate a proportion, estimate a mean, compare two means or compare two proportions.
- For estimation, enter the Confidence level and the Margin of error, plus the Expected proportion, p or the Standard deviation estimate, σ. Add the Population size, N if the population is small and known.
- For a comparison, enter the Significance level (α), the Power, 1 − β, and whether the Test is two-sided or one-sided.
- Then enter the effect: the Difference to detect, Δ and Common standard deviation, σ for means, or Group 1 proportion, p₁ and Group 2 proportion, p₂ for proportions. Leave the Allocation ratio at 1 for equal groups.
- Read the required sample size and check the table to see what a different margin or power would cost.
How to calculate sample size for a survey
A school district wants to survey its 2,000 staff about a new timetable. It wants 95% confidence and a margin of error of ±5 percentage points, and has no earlier estimate of the answer, so it uses p = 50%.
- Find the critical value: z = 1.96 for 95% confidence.
- Apply the proportion formula for a very large population: n₀ = 1.96² × 0.5 × 0.5 / 0.05² = 384.15.
- Apply the finite population correction, because the 2,000 staff are a small, known population: n = 384.15 / [1 + (384.15 − 1) / 2,000] = 322.39.
- Round up: 323 completed responses. Without the correction the answer would be 385.
- Allow for non-response: at an expected 30% response rate, invite 323 / 0.30 ≈ 1,077 staff.
Sample size formulas
All four formulas come from the normal approximation. z is the critical value for the confidence level; z_α is z(α/2) for a two-sided test or z(α) for a one-sided test; z_β is the z value for the chosen power.
| Symbol | Meaning |
|---|---|
| e, E | margin of error (as a proportion for e; in data units for E) |
| p, p₁, p₂ | expected proportions |
| σ | standard deviation of the measurement (within each group for a comparison) |
| Δ | difference in means to detect |
| k | allocation ratio n₂ / n₁ |
| N | population size |
| z_β | Φ⁻¹(power): 0.8416 for 80%, 1.2816 for 90%, 1.6449 for 95% |
Every result is rounded up, and for a comparison each group is rounded up separately (n₂ is the rounded-up value of k × the unrounded n₁).
The two-sided comparison formulas ignore the negligible chance of rejecting H₀ in the wrong direction. Software that includes it, such as statsmodels’ NormalIndPower, returns a value a fraction of an observation smaller.
Worked example
Worked example: planning a two-group experiment
Problem. A team wants to compare a new tutoring method with the usual one on a test whose scores have a standard deviation of about 10 points. They want 80% power to detect a difference of 5 points with a two-sided test at α = 0.05, using equal groups. How many students are needed?
- 01z values: z(α/2) = z(0.025) = 1.96 and z(β) = Φ⁻¹(0.80) = 0.8416, so z_α + z_β = 2.8016.
- 02Effect size: d = Δ / σ = 5 / 10 = 0.5.
- 03Formula with k = 1: n₁ = 2 × 10² × 2.8016² / 5² = 2 × 100 × 7.8489 / 25 = 62.79.
- 04Round up: 63 per group, 126 in total. With 63 per group the power is 80.13%.
- 05Allowing for the t-test: 62.79 + 1.96² / 4 = 63.75, so 64 per group is the safer plan.
Answer. The normal-approximation answer is 63 students per group (126 in total). Because the data will be analysed with a t-test, 64 per group is the figure most power software reports. Halving the detectable difference to 2.5 points would quadruple the requirement to 252 per group.
Sample size table by margin of error and confidence level
This sample calculation table gives the survey sample size for a proportion from a very large population, using the worst case p = 50% (Cochran’s n₀ = z²p(1 − p) / e², rounded up). The 95% column is the one most surveys use.
| Margin of error | 90% confidence | 95% confidence | 99% confidence |
|---|---|---|---|
| ±1% | 6,764 | 9,604 | 16,588 |
| ±2% | 1,691 | 2,401 | 4,147 |
| ±3% | 752 | 1,068 | 1,844 |
| ±4% | 423 | 601 | 1,037 |
| ±5% | 271 | 385 | 664 |
| ±10% | 68 | 97 | 166 |
Sample size by population size
Population size only matters when the sample would be a sizeable share of it. Above roughly 20,000 people the requirement is almost the same as for an unlimited population; below a few thousand the finite population correction n = n₀ / [1 + (n₀ − 1) / N] lowers it noticeably. If you do not know the total population size, leave the field blank: the uncorrected figure is the safe, slightly larger answer.
| Population size, N | ±3% | ±5% | ±10% |
|---|---|---|---|
| 100 | 92 | 80 | 50 |
| 500 | 341 | 218 | 81 |
| 1,000 | 517 | 278 | 88 |
| 2,000 | 697 | 323 | 92 |
| 5,000 | 880 | 357 | 95 |
| 10,000 | 965 | 370 | 96 |
| 100,000 | 1,056 | 383 | 96 |
| Very large | 1,068 | 385 | 97 |
Which goal matches my study?
The right formula depends on what the study has to deliver. An estimation study is finished when the confidence interval is narrow enough. A comparison study is finished when a real difference of the size you care about would probably reach statistical significance. Mixing these up is the most common planning mistake: a survey sized for a ±5% margin is usually far too small to compare two of its subgroups.
| Goal | Typical question | What you must supply | Related calculator |
|---|---|---|---|
| Estimate a proportion | What share of customers would recommend us? | Confidence, margin of error, rough p | Cochran’s Formula Calculator |
| Estimate a mean | What is the average delivery time? | Confidence, margin of error, σ | Margin of Error Calculator |
| Compare two means | Does the new method raise the average score? | α, power, difference Δ, σ | Effect Size Calculator |
| Compare two proportions | Does version B convert better than version A? | α, power, p₁ and p₂ | Two Proportion Z-Test Calculator |
Quick reference: sample size per group for two means
Per-group sample sizes for a two-sided test at α = 0.05 with equal groups, by standardized difference d = Δ / σ (normal approximation; add one per group for a t-test). Cohen’s conventional labels are small (0.2), medium (0.5) and large (0.8), but the difference that matters in your field should drive the choice.
| Effect size, d | 80% power | 90% power | 95% power |
|---|---|---|---|
| 0.2 (small) | 393 | 526 | 650 |
| 0.3 | 175 | 234 | 289 |
| 0.5 (medium) | 63 | 85 | 104 |
| 0.8 (large) | 25 | 33 | 41 |
| 1.0 | 16 | 22 | 26 |
Why two-proportion calculators disagree: unpooled, pooled and arcsine
There are three widely used normal-approximation formulas for comparing two proportions, and they differ in how they model the variance. This calculator uses the unpooled formula, which uses each group’s own variance p(1 − p) throughout. The pooled formula uses the combined proportion p̄ for the null-hypothesis part, matching the usual two-proportion z-test. The arcsine formula first transforms each proportion with 2·asin√p, which makes the variance the same for every p; the transformed difference is Cohen’s h, and this is what statsmodels’ NormalIndPower computes when it is given proportion_effectsize.
For 40% versus 55% at α = 0.05 (two-sided) and 80% power the three give 171, 173 and 173 per group. The gap widens when a proportion is close to 0 or 1: for 2% versus 6% they give 373, 376 and 353, with the arcsine formula noticeably smaller. None is exact, so when the methods disagree by more than a few observations take the larger figure, or confirm with exact binomial power.
From required sample to number recruited
The result is the number of observations that must be analysed. Divide by the fraction you expect to keep: if 20% of participants are likely to drop out, recruit n / 0.8; if a survey has a 25% response rate, invite n / 0.25.
Cluster sampling, where whole classes, clinics or households are sampled together, needs the result multiplied by a design effect, often between 1.5 and 2, because people in the same cluster resemble each other. And if you plan several comparisons, each one needs its own power calculation with an α adjusted for multiple testing.
Common use cases
- Surveys and polls: how many responses for a stated margin of error, with or without a small-population correction.
- Clinical and lab studies: participants per arm to detect a clinically meaningful difference in a mean outcome.
- A/B tests: visitors per variant to detect a lift in conversion rate from p₁ to p₂.
- Quality and process studies: measurements needed to pin down a mean within a tolerance.
- Grant, ethics and thesis proposals: a transparent justification of the sample size with every assumption stated.
- Planning the whole study: before sizing a study, choose its design (experiment, cohort, case-control or cross-sectional); the guide to study design and sample size walks through the steps.
Assumptions and limitations
- All four formulas assume simple random sampling (or random assignment) and independent observations. Clustered, stratified or matched designs need their own methods.
- The comparison goals use the normal approximation. For means analysed with a t-test, exact planning needs slightly more, typically one or two per group at α = 0.05. For proportions, exact or continuity-corrected methods need more, especially with small samples or rates near 0% or 100%.
- The answer is only as good as the planning values. σ, p and the difference to detect are guesses; run the calculation for a pessimistic scenario as well.
- It sizes a study for one primary estimate or comparison. Subgroup analyses, several outcomes, paired designs, more than two groups (ANOVA) and regression need different calculations.
- For survey shortcuts that need only N and a margin of error, see Slovin’s formula and Yamane’s formula, and note the fixed confidence level they assume.
Frequently asked questions
How do I calculate sample size?
What sample size do I need for 95% confidence and a 5% margin of error?
What confidence level and margin of error should I use?
Do I need to know the total population size?
What is statistical power and why is 80% the usual target?
How does the difference I want to detect affect the sample size?
Why do other calculators give a slightly different sample size?
Does a bigger population need a bigger sample?
Should the two groups be the same size?
Cite this page
Statculator. (2026, November 14). Sample Size Calculator. Retrieved November 14, 2026, from https://statculator.com/sample-size/sample-size-calculator/