Quick answer: For a proportion, the sample size formula is n = z² × p(1 − p) / E². At 95% confidence (z = 1.960) with an expected proportion of 0.5 and a target margin of error of 5%, it gives n = 384.16, rounded up to 385 responses. For a mean, the formula is n = (z × σ / E)². Enter your own confidence level, margin and proportion or standard deviation above and this sample size calculator returns the required sample, with the finite population correction when your population is small.

How to use this sample size calculator

Step 1 — Pick the mode that matches your quantity. The calculator works in three directions. The first mode finds the sample size for a proportion: a share, a percentage, a yes-or-no answer. The second finds the sample size for a mean: a measured quantity such as height, spending, time or test scores, where you supply the standard deviation instead of a proportion. The third mode runs both backwards: you supply a sample size you already have, or can afford, and it returns the margin of error that sample delivers, so a plan can be judged before any fieldwork begins.

Step 2 — Set the confidence level and the margin honestly. The confidence level sets the z-value — 1.645 at 90%, 1.960 at 95% and 2.576 at 99% — and 95% is the standard choice for published work. The margin of error is the precision you are buying, in percentage points for a proportion and in the measurement's own units for a mean. If you are planning a proportion and cannot know the result in advance, leave the proportion at 50%: p = 0.5 maximises p(1 − p) and gives the largest, safest sample size.

Step 3 — Add a population size only when it earns its place. Leave the population field empty for national surveys and any population in the hundreds of thousands or more: the correction it drives is negligible and changes nothing. Enter it when the sample is a noticeable share of a small, known population — 400 staff in a firm of 600 — and the finite population correction will reduce the requirement to reflect how much of the whole you are actually measuring.

What sample size is — and why it decides what a study can claim

In short: the sample size, written n, is the number of observations a study collects, and it is the strongest single control a researcher has over the precision of the result. Every estimate drawn from a sample carries a margin of error, and that margin is set, before a single response arrives, by the sample size, the confidence level and the variability of the thing being measured. A study that collects too few responses does not merely become a bit less precise — its margin can grow so wide that the headline finding is compatible with almost any true value, and the work has been spent for nothing.

The opposite failure is quieter but just as real. Because precision improves only with the square root of the sample size, chasing a very tight margin multiplies fieldwork fast: at 95% confidence, moving from a ±5% margin to a ±1% margin raises the requirement from 385 responses to 9,604. Money spent interviewing thousands of extra people to shave a margin nobody will act on is money not spent on better questions, better sampling or a second wave of the study. Sample size calculation is therefore a budgeting discipline as much as a statistical one: it finds the smallest sample that delivers the precision the decision actually needs.

One distinction matters throughout this page. The formulas here size a study for estimation — measuring a proportion or a mean to a stated precision. Sizing a study to detect an effect, such as a difference between two groups in an experiment, is a different calculation involving statistical power, effect size and significance level. A sample that is right for estimating a proportion may be far too small to detect a small treatment effect, and the honest-limits section returns to this.

The sample size formula for a proportion, step by step

The formula: n = z² × p(1 − p) / E². It is the margin of error formula solved for n. The margin of error for a proportion is E = z × √(p(1 − p) / n); squaring both sides and rearranging isolates n, which is why the margin appears squared in the denominator and why precision is so expensive: halving E multiplies n by four. Each input does one job. The z-value prices your confidence level. The term p(1 − p) prices the variability of a proportion — largest at p = 0.5, where it equals 0.25, and smaller as the expected proportion moves toward 0 or 1. The margin E states how close the estimate must sit to the truth.

Worked through once, slowly, for the pre-filled example: 95% confidence, p = 0.5, E = 5% entered as the decimal 0.05. First square z: 1.960² = 3.8416. Multiply by p(1 − p) = 0.5 × 0.5 = 0.25, giving 0.9604. Square the margin: 0.05² = 0.0025. Divide: 0.9604 / 0.0025 = 384.16. A fractional respondent does not exist, and rounding down would miss the target, so the answer is rounded up to 385 responses. Every figure in the first mode of this calculator is produced by exactly those steps, with one optional extra: when you supply a population size N, the result is passed through the finite population correction explained in its own section below. The companion Margin of Error Calculator works the same relationship from the reporting side, turning a finished sample into its margin and confidence interval.

The sample size formula for a mean

The formula: n = (z × σ / E)², where σ (sigma) is the population standard deviation and E is the margin of error in the same units as the measurement. It comes from the margin of error for a mean, E = z × σ / √n, solved for n in the same way. The logic mirrors the proportion case with one change of cast: the variability term is no longer p(1 − p), which a proportion carries inside itself, but the standard deviation of the measured quantity, which must be supplied from outside.

That supply is the practical difficulty of the mean formula. The population standard deviation is rarely known exactly before the study runs, so researchers take it from a pilot study, from earlier waves of the same survey, or from published measurements of the same quantity. A worked example: measuring a quantity with σ = 15 to within ±3 at 95% confidence needs n = (1.960 × 15 / 3)² = 9.8² = 96.04, rounded up to 97 observations. Notice how sensitive the result is to σ: if the true standard deviation were 20 rather than 15, the same precision would need 171 observations. When the pilot estimate of σ is shaky, prudent researchers size the study with a slightly larger σ than the pilot suggested. For the spread of data you have already collected, the Standard Deviation Calculator computes σ's sample counterpart directly.

Worked examples you can check by hand

Four examples pin the calculator down, and every one can be reproduced with a pencil or a spreadsheet. Example 1 is the pre-filled case: 95% confidence, p = 0.5, a 5% margin — n = 384.16, rounded up to 385, as worked step by step above. Example 2 adds a population: keep everything the same but set N = 10,000. The correction divides the unrounded requirement by 1 + (384.16 − 1) / 10,000, giving 369.98, rounded up to 370 responses. Sampling a twenty-sixth of the whole population genuinely does tell you more per respondent, and the correction is the size of that saving.

Example 3 raises the confidence level and tightens the margin together: 99% confidence, p = 0.5, a 3% margin. Then n = 2.576² × 0.25 / 0.03² = 6.6358 × 0.25 / 0.0009 = 1,843.27, rounded up to 1,844 responses. Compare it with the same 3% margin at 95% confidence, which needs 1,068, and the price of the stronger guarantee is visible in a single pair of numbers. Example 4 uses the mean mode: σ = 15, a margin of 3, 95% confidence — n = 96.04, rounded up to 97, as worked in the mean section. Run all four examples in the calculator above and each figure is reproduced exactly, which is the honest way to decide whether to trust a tool with your real study.

Confidence levels and z-values: 90%, 95% or 99%

The confidence level is a promise about the method, not about any single result. A 95% level means that if the same study were repeated many times with the same sample size, about 95% of the intervals built the same way would contain the true population value. It does not mean there is a 95% probability that this one interval contains it — for the interval you computed, the true value is either inside or outside, and the 95% describes how trustworthy the procedure is. That is exactly where the everyday phrase “19 times out of 20” comes from.

In practice the choice is a trade between confidence and cost. At 90% confidence (z = 1.645) samples are smallest and one procedure in ten misses — acceptable where a wrong call is cheap. At 95% (z = 1.960) the procedure misses one time in twenty, and the level is the default for published polling, academic reporting and this calculator. At 99% (z = 2.576) only one procedure in a hundred misses, but every requirement grows: a 5% margin at p = 0.5 needs 271 responses at 90%, 385 at 95% and 664 at 99%. Choose the level before you look at any results, and report it alongside the sample size every time: a sample size quoted without its confidence level and margin is only a third of a figure. The z-values come from the standard normal distribution — the curve the Z-Score Calculator works with.

Choosing the margin of error

The margin of error is the decision input, and it should be set by the use the result will be put to, not by habit. Ask what difference would change the decision. If a finding of 52% against 48% would be acted on, a ±5% margin is useless, because the interval around either figure swallows the gap; the study needs a margin nearer ±2%, and the table below shows what that costs. If the study is a pilot checking whether a proportion is nearer 20% or 80%, a ±10% margin at a cost of 97 responses answers the question perfectly well.

Two habits keep margin choices honest. First, set the margin before fieldwork and write it into the plan: choosing it afterwards, to fit the sample that happened to be affordable, reverses the logic of the calculation. Second, remember that subgroup findings live on subgroup samples. A survey sized for ±3% overall rests its youngest subgroup on perhaps 150 respondents, whose own margin is near ±8% — if subgroup readings will be reported, size the study for the smallest subgroup that matters, or accept and disclose the wider margins.

The finite population correction

The basic formulas quietly assume the population is so large that sampling barely dents it. When that assumption fails, the unadjusted requirement overstates how many responses are needed, because a sample that covers a noticeable share of everyone plainly knows more than a sample that covers a millionth. The finite population correction adjusts the requirement: n adjusted = n / (1 + (n − 1) / N), computed from the unrounded n and rounded up only at the end. It leaves large-population plans untouched, and bites exactly where it should: the worked example on this page, a 5% margin at 95% confidence, falls from 385 responses to 370 when the population is 10,000, and a survey of a 600-person company needs far fewer than 385 completed responses for the same precision.

A working rule: apply the correction whenever the unadjusted sample exceeds about 5% of the population. Below that share the saving is a handful of responses and most published work ignores it safely. Above it, ignoring the correction means buying fieldwork the mathematics says you do not need. This calculator applies the correction in the two sample-size modes, using the unrounded requirement, so a small-population plan is not over-bought out of caution.

Required sample sizes at common settings

The table below is computed from the same formula this calculator uses — a proportion with p = 0.5, no population correction — and every cell can be reproduced above by entering the margin and confidence level. It is the fastest way to develop a feel for what precision costs, and to sanity-check any sample size quoted to you: if a plan promises a ±2% margin at 95% confidence from 800 responses, something other than this formula produced that promise.

Target margin of errorn at 90%n at 95%n at 99%What it is typically used for
±10%6897166A rough pilot or classroom exercise
±5%271385664The classic planning point for surveys and coursework
±4%4236011,037A mid-size published poll
±3%7521,0681,844The standard national poll target
±2%1,6922,4014,148A large study with subgroup reporting
±1%6,7669,60416,590Government and large academic surveys

Read the table from the cost side too. Tightening the target from ±5% to ±3% at 95% confidence raises the fieldwork from 385 to 1,068 responses — nearly triple, for two extra points of precision. That arithmetic, not laziness, is why professional surveys cluster near those two margins: beyond them, the same money usually buys more accuracy spent on better sampling and better questions than on raw size.

Finding the margin of error from a sample you already have

Sometimes the sample size is fixed first — by a budget, a class list, or fieldwork that has already happened — and the honest question runs the other way: what margin does this sample deliver? The third mode answers it, for a proportion with E = z × √(p(1 − p) / n) and for a mean with E = z × σ / √n, applying the finite population correction when a population size is supplied. The landmarks are worth memorising: at 95% confidence with p = 0.5, a sample of 100 delivers ±9.80%, 385 delivers ±5.00%, 1,000 delivers ±3.10% and 9,604 delivers ±1.00%.

Used before fieldwork, this mode is a reality check on a budget: if the affordable sample delivers ±9.80% and the decision needs ±3%, the choices are to find more budget, narrow the population, or change the decision the study is meant to inform — not to field the study and quote its findings as if the margin were smaller. Used after fieldwork, it is the figure that belongs next to every reported result. The dedicated Margin of Error Calculator extends this direction with the full confidence interval around an observed result.

Spreadsheets and code: Excel, Sheets and Python

Every serious tool implements the same steps, so cross-checking is easy. In Excel and Google Sheets, with a target margin as a decimal in A1 and a proportion in A2, the required sample size at 95% confidence is =ROUNDUP(1.96^2*A2*(1-A2)/A1^2, 0) — the ROUNDUP enforces the always-round-up rule. For a mean, with the standard deviation in A3, use =ROUNDUP((1.96*A3/A1)^2, 0). Swap 1.96 for 1.645 or 2.576 for the other confidence levels.

In Python the same calculation is three lines with the standard library alone: import math, then n = math.ceil(1.96**2 * p * (1 - p) / e**2) for a proportion, and n = math.ceil((1.96 * sigma / e)**2) for a mean. Small last-decimal differences between tools are rounding, while a difference in the first figures almost always means a different quantity was computed — most often a margin entered as 5 where the formula expected 0.05, or a sample size rounded down instead of up.

Common mistakes

Entering the margin or proportion as a whole number in the formula by hand. The formulas want decimals: a 5% margin is 0.05 and an even split is p = 0.5, not 50. Using whole numbers inflates the result by orders of magnitude. This calculator takes percentages at the door and converts them for you; a spreadsheet will not.

Rounding the required sample size down. Sample sizes round up, always. 384.16 rounds to 385; fielding 384 delivers a margin fractionally wider than the target you set, which matters exactly when a client, an examiner or a methods chapter checks.

Planning with an optimistic proportion. Sizing a study at p = 0.2 because a result near 20% is expected, then watching the true proportion land near 0.5, leaves the achieved margin wider than planned. Without strong prior evidence, p = 0.5 is the safe planning value precisely because it cannot be beaten by events.

Forgetting non-response. The formulas give completed responses. If a third of the people invited typically reply, the invitations must number roughly three times the required sample — and if the people who reply differ systematically from those who do not, no sample size repairs that bias.

Using an estimation formula to size an experiment. Detecting a difference between groups needs a power calculation with an effect size, not a margin-of-error formula. The two calculations answer different questions, and substituting one for the other is the most consequential mistake on this list.

Honest limits: what this calculator does not do

The central limit deserves plain words: these formulas assume simple random sampling and the stated proportion or standard deviation. A simple random sample — every member of the population equally likely to be chosen, independently — is a textbook ideal that real studies approximate rather than achieve. Real surveys sample in clusters, stratify by region and demographics, and then weight the responses so the sample matches the population. Clustered or stratified designs need a design-effect adjustment this tool does not make: clustering typically inflates the true requirement, commonly by a factor between 1.1 and 2, so a clustered design fielded at exactly the number this calculator returns will usually deliver a wider margin than targeted. Researchers using such designs should multiply the requirement by their expected design effect before fieldwork.

Three further limits belong on the record. The calculator does not inflate the sample for expected non-response — that allowance depends on your population and contact method, and must be added by you. It does not size studies for statistical power, subgroup analysis beyond the simple warning in the margin section, or finite-population means beyond the same correction applied to the requirement. And its standard-deviation input is only as good as the pilot or published figure behind it. What it does promise: the standard textbook calculations for a proportion and a mean, with the finite population correction, computed exactly as the worked examples show, in your browser, free, with nothing uploaded.

Sources and References

Sources note: all seven sources above were verified live on 24 November 2026 and returned HTTP 200 to a direct request, including the Boston University teaching modules and the NIST/SEMATECH handbook pages. No source needed substitution, and none is included on the strength of a search-result snippet alone. Note on the 99% worked example: with z = 2.576 exactly, a 3% margin at p = 0.5 gives 1,843.27, which rounds up to 1,844 — the figure this page and calculator use.