Skip to content

Sample Size Calculator

Pick a confidence level and margin of error to see how many people you need to survey. Add the population size if it is small. Margin of error works backwards from a sample you already have. Advanced adds means, response rates, design effect, A/B tests and two-group studies.

Means, A/B tests, response rate, design effect
What do you want to work out?
Confidence level

95% is the usual choice. Higher confidence needs a bigger sample.

± %
%
people
%
people
%
pts
Power (chance of spotting a real effect)
Significance level (α)
Test
/ day
%

Online surveys often get 10–30%. We work out how many to invite.

Cluster samples (whole schools, streets) often use 1.5–2.

ResultUpdates as you type—Sample size—Before rounding—Critical z—Margin you’ll get

How your sample size is worked out

Your numbers, step by step: the z for your confidence, the spread, divide by the margin squared, then round up.

  1. 1

    Find z

    95% → z = 1.959964

  2. 2

    Spread of answers

    0.5 × 0.5 = 0.25

  3. 3

    Divide by margin²

    3.8415 × 0.25 ÷ 0.0025 = 384.15

  4. 4

    Round up

    384.15 → 385 people

Read more: the formula, worked examples, A/B tests, and how big a population really matters

A sample size calculator tells you how many people (or items, or visitors) you need so that your result is close enough to the truth for the whole population. Three things drive it: how sure you want to be (the confidence level), how close you need to be (the margin of error) and how varied the answers are likely to be.

The formula

Survey (a proportion): n₀ = z² × p × (1 − p) ÷ e²
Small population: n = n₀ ÷ (1 + (n₀ − 1) ÷ N), then round up
Margin of error: e = z × √(p × (1 − p) ÷ n) × √((N − n) ÷ (N − 1))
A mean: n₀ = (z × σ ÷ E)²
Design effect and response rate: n × deff, then invitations = n ÷ response rate
A/B test, per group (pooled): n = [zα × √(2 × p̄ × (1 − p̄)) + zβ × √(p₁(1 − p₁) + p₂(1 − p₂))]² ÷ (p₂ − p₁)², with p̄ = (p₁ + p₂) ÷ 2
Two means, per group: n = 2 × σ² × (zα + zβ)² ÷ Δ²

z is the number of standard deviations that covers your confidence level on a bell curve (1.959964 for 95%). zα is the same for your significance level (two-sided α 0.05 → 1.959964) and zβ comes from the power (80% → 0.841621). p is the expected proportion as a decimal, e is the margin of error as a decimal and N is the population. With unequal groups (group B = k × group A), the A/B formula uses (1 + 1/k) in place of 2 and p₂(1 − p₂) ÷ k, and the two-means formula uses (1 + 1/k) σ².

Worked example

A survey at 95% confidence, ±5% margin of error, expected proportion 50%, very large population.

  • z for 95% is 1.959964, so z² = 3.841459.
  • p × (1 − p) = 0.5 × 0.5 = 0.25.
  • e² = 0.05² = 0.0025.
  • n₀ = 3.841459 × 0.25 ÷ 0.0025 = 384.15, which rounds up to 385 people.
  • If the population is only 1,000: 384.15 ÷ (1 + 383.15 ÷ 1,000) = 384.15 ÷ 1.38315 = 277.73, so 278 people.
  • If only 20% reply, invite 385 ÷ 0.20 = 1,925 people.

Margin of error for 400 replies at 95% with a 50% result: √(0.25 ÷ 400) = 0.025, and 1.959964 × 0.025 = 0.049 = ±4.90%, so the true figure is likely between 45.10% and 54.90%.

A mean: with σ = 15 and a margin of ±3 at 95%, (1.959964 × 15 ÷ 3)² = 9.79982² = 96.04, so 97 people.

An A/B test from 10% to 12% with 80% power and α = 0.05 two-sided, using the standard pooled formula: p̄ = 0.11, √(2 × 0.11 × 0.89) = 0.442493 and √(0.10 × 0.90 + 0.12 × 0.88) = 0.442267. Then 1.959964 × 0.442493 + 0.841621 × 0.442267 = 0.867270 + 0.372220 = 1.239490. Squared that is 1.536336, and ÷ 0.02² = ÷ 0.0004 gives 3,840.85, so 3,841 visitors per group (7,682 in total). The unpooled formula, (zα + zβ)² × (p₁q₁ + p₂q₂) ÷ Δ², gives 3,838.10 → 3,839, and Fleiss’s continuity correction raises it to 3,941.

Two means: σ = 10, a difference of 5, 80% power and α = 0.05 two-sided: (1.959964 + 0.841621)² = 7.848880, and 2 × 10² × 7.848880 ÷ 5² = 62.79, so 63 per group.

z for each confidence level

Confidencez
80%1.281552
85%1.439531
90%1.644854
95%1.959964
98%2.326348
99%2.575829

How much population size matters (95%, ±5%, p = 50%)

PopulationSample needed
10080
500218
1,000278
5,000357
10,000370
100,000383
1,000,000384
Very large385

Notes

  • Use 50% if unsure. p(1 − p) is largest at 50%, so it gives the biggest, safest sample. If a past survey found 20%, using 20% gives a smaller sample.
  • The sample must be random. A big sample from a biased list (only your fans, only people online at noon) is still biased. The maths assumes everyone had a fair chance of being picked.
  • Design effect allows for cluster or multi-stage sampling, where people in the same group answer alike. Multiply n by it before the population correction.
  • A/B tests: decide the sample size before you start and don’t stop early when it “looks significant”, or your false-positive rate goes up. Run for whole weeks so weekday and weekend visitors are both in.
  • Normal approximation: these are the standard z-based formulas. For very small samples or rates near 0% or 100%, exact methods may need a few more people.

Common questions

How do I work out a sample size?

For a survey, n = z² × p(1 − p) ÷ e², where z comes from your confidence level (1.96 for 95%), p is the expected proportion (use 50% if you don’t know) and e is the margin of error as a decimal. At 95% and ±5% that is 1.959964² × 0.25 ÷ 0.0025 = 384.15, so you need 385 people. For a small population, divide by 1 + (n − 1) ÷ N.

Why is 385 the magic number for surveys?

It is the sample you need for a ±5% margin of error at 95% confidence when you assume a 50/50 split and the population is large. 50% gives the biggest p(1 − p), so it is the safe choice. For any population over about 100,000, the answer barely changes.

Does population size matter?

Only when the sample is a big share of the population. For 95% and ±5%, a population of 1,000 needs 278, 10,000 needs 370, and a million needs 385. Above about 20,000 people you can treat the population as unlimited.

What margin of error should I use?

±5% is the usual choice for general surveys and ±3% for polls that need to be more precise. Halving the margin of error roughly quadruples the sample: ±2.5% needs 1,537 people at 95%.

How many visitors do I need for an A/B test?

It depends on your current conversion rate and the smallest lift you care about. To spot a change from 10% to 12% with 80% power at a 5% two-sided significance level, you need 3,841 visitors in each group (7,682 in total) using the standard pooled formula. Smaller lifts need far more: the size goes up with one over the gap squared.

How do I allow for people who don’t reply?

Divide the sample size by the response rate. If you need 385 replies and expect 20% of people to answer, send 385 ÷ 0.20 = 1,925 invitations. Advanced does this for you.

Related calculators

Z-score calculatorZ-score from a value, value from a z-score, percentiles, the area under the bell curve (left, right, between, outside), p-values and a z-table.Statistics calculatorEverything about a data set in one go: mean, median, mode, quartiles, outliers, SD, skewness, percentiles, z-scores, box plot and histogram, plus correlation and regression for two sets.Standard deviation calculatorStandard deviation, variance, mean, median, mode, quartiles, outliers and confidence intervals from a list or a frequency table.Probability calculatorTwo events (and, or, not, neither), repeated tries, Bayes’ theorem, odds, dice, coins and cards, with exact fractions and the working.

Made by Zulu Calculator, part of AlphaZulu LLC. Formulas are shown in full and rule figures are checked against official sources; see how we build calculators.

Embed this calculator on your site

Free to use on your website or blog. Paste this code where you want the calculator to appear. Please keep the credit link.

Sample size calculator by Zulu Calculator ↗