AJ Designer

Sample Size Calculator

n equals Z squared times p times one minus p, divided by E squared

Required Sample Size (n) =

Share:

Sample Size for a Proportion (Cochran's Formula)

Use when you're estimating a yes/no rate — turnout, brand awareness, defect rate, infection rate. Z is the critical value for your confidence level, p is the expected (or worst-case 0.5) proportion, and E is the desired margin of error as a decimal.

n = (Z² × p × (1 − p)) / E²

Sample Size for a Mean (σ known)

Use when you're estimating an average — mean income, mean blood pressure, mean wait time — and you have a prior estimate of the population standard deviation σ. The margin of error E is in the same units as σ.

n = (Z × σ / E)²

Finite Population Correction

Apply when you can enumerate the population (a school of 1,200 students, a factory's daily output of 5,000 units). FPC shrinks the required sample as N gets smaller; for very large or unknown N the correction is negligible and you can leave the field blank.

n_adj = n / (1 + (n − 1) / N)

How It Works

Sample size depends on three things: how confident you want to be (the Z critical value), how much variability the trait has (p × (1 − p) for a proportion, or σ² for a mean), and how precise the estimate needs to be (the margin of error E). For a proportion, picking p = 0.5 maximizes the variance and gives the largest sample size — that's the 'worst case' assumption pollsters use when they don't know the true split in advance. Higher confidence (e.g., 99% instead of 95%) pushes Z up and the sample size with it; tighter margins of error (3% instead of 5%) push n up quadratically. When you can enumerate the full population, the finite population correction discounts the required sample, sometimes substantially. The calculator runs all three computations in BigNumber precision and rounds the final n up to the next integer — you can't survey 384.16 people.

Example Problem

A pollster wants to estimate the proportion of registered voters who support a ballot measure to within ±5 percentage points at the 95% confidence level. With no prior estimate of support, what is the required sample size?

  1. Identify the inputs: confidence level = 95% → Z = 1.96; no prior estimate so use p = 0.5 (worst case, maximum variance); margin of error E = 0.05 (5 percentage points expressed as a decimal).
  2. Apply Cochran's formula: n = (Z² × p × (1 − p)) / E² = (1.96² × 0.5 × 0.5) / 0.05².
  3. Compute the numerator: 1.96² = 3.8416. Then 3.8416 × 0.5 × 0.5 = 0.9604.
  4. Compute the denominator: 0.05² = 0.0025.
  5. Divide: n = 0.9604 / 0.0025 = 384.16.
  6. Round up to the next integer (you can't survey a fractional person): n = 385 respondents.
  7. If the population is known and small — say a city precinct with only 1,000 registered voters — apply the finite population correction: n_adj = 385 / (1 + 384 / 1000) = 385 / 1.384 ≈ 278.2, so n = 279.

The famous 'n ≈ 385' result is why national political polls routinely report sample sizes around 1,000–1,200 — that's enough to cut the margin of error from ±5% to about ±3% while keeping the assumption-free p = 0.5 / 95% CI design.

Key Concepts

The margin of error and the confidence interval are two views of the same statistic. The confidence interval is the range (estimate − E, estimate + E); the margin of error E is its half-width. A 95% CI means that if you repeated the survey under identical conditions, 95% of the resulting intervals would contain the true population value — it does not mean any single interval has a 95% chance of being right. Population size matters less than people expect. For an infinite (or unknown) population, n ≈ 385 buys you ±5% at 95% confidence regardless of whether the population is 10,000 or 10 billion — the sampling distribution depends on the sample size, not the population size. The finite population correction only kicks in when the sample is a substantial fraction of the population (rule of thumb: > 5%). This is why a survey of 1,000 voters can speak for an entire country, and why doubling the country's population doesn't double the survey cost.

Applications

  • Political polling and election forecasting (Gallup, YouGov, and university survey labs use these formulas to size pre-election surveys at ±3 percentage points)
  • Market research surveys for product launches, brand tracking, and customer satisfaction studies
  • A/B test sizing for landing pages, email subject lines, and conversion-funnel experiments (with proportions p₁ and p₂)
  • Clinical trial design — calculating the patient enrollment needed to detect a treatment effect at given power and significance
  • Manufacturing acceptance sampling — choosing the lot inspection count to bound the consumer's and producer's risk
  • Educational assessment — sizing standardized testing pilots to estimate item difficulty or pass rates
  • Public-health epidemiology — sizing seroprevalence studies and disease-incidence surveys

Common Mistakes

  • Entering the margin of error as 5 instead of 0.05 — the formula expects a decimal, so 5 means a margin of error of 500 percentage points and produces an absurdly small n
  • Forgetting the finite population correction when surveying a small group (a department of 50, a school of 800) — without FPC the calculator over-counts the required sample
  • Mixing up one-tailed and two-tailed Z values — 1.96 is the two-tailed 95% Z, which is the convention for confidence intervals; 1.645 is the one-tailed 95% Z used for one-sided hypothesis tests
  • Using p = 0.5 by default when you actually have a good prior estimate (e.g., historical data showing 80% support) — using the true p shrinks the required sample by a factor of p(1 − p) / 0.25
  • Computing sample size for proportions when the trait is continuous (height, income, reaction time) — use the mean formula with σ instead
  • Assuming a larger population needs a larger sample — once the population is much bigger than the sample (a country of 300 million vs a sample of 1,000), the population size effectively drops out of the math

Frequently Asked Questions

How do you calculate sample size?

For a proportion, use Cochran's formula n = (Z² × p × (1 − p)) / E², where Z is the standard-normal critical value for your confidence level (1.96 for 95% confidence), p is the expected proportion (use 0.5 if unknown — it gives the maximum variance and largest n), and E is the desired margin of error as a decimal. For a mean, use n = (Z × σ / E)² where σ is the population standard deviation. Round up to the next whole number — you can't survey a fractional person.

What is a good sample size for a survey?

For most general-population surveys, n = 385 gives a margin of error of ±5% at 95% confidence — that's why political polls report this number so often. Tightening the margin of error to ±3% requires about n = 1,068 at the same confidence level, which is the canonical 1,000-person national poll. For niche populations (a single company, a small town), apply the finite population correction; for studies where you'll break results down by subgroup, size each subgroup to the target precision separately.

What is the formula for sample size?

Two forms cover most cases. For estimating a proportion: n = (Z² × p × (1 − p)) / E². For estimating a mean when the standard deviation σ is known: n = (Z × σ / E)². If you can enumerate the population N, apply the finite population correction n_adj = n / (1 + (n − 1) / N) to shrink the requirement. The Z value comes from the standard normal distribution: 1.96 for a 95% confidence interval, 2.576 for 99%.

Why is the sample size always 384 in polls?

It's the result of the canonical settings Z = 1.96 (95% confidence), p = 0.5 (worst-case / maximum-variance assumption when you have no prior estimate), and E = 0.05 (±5 percentage points margin of error). Plugging in: n = 1.96² × 0.5 × 0.5 / 0.05² = 0.9604 / 0.0025 = 384.16, which rounds up to 385. Pollsters often round up further to 400 for cleaner reporting, and large national polls of 1,000–1,200 cut the margin of error to roughly ±3%.

How does the confidence level affect sample size?

Sample size grows quadratically with Z. Going from 95% confidence (Z = 1.96) to 99% confidence (Z = 2.576) requires about (2.576 / 1.96)² ≈ 1.73× more respondents at the same margin of error. Going from 95% to 90% (Z = 1.645) cuts n to about 70% of the 95% requirement. The trade-off is real: tighter confidence costs money and time, so most surveys settle at 95% as the conventional balance.

What's a 95% confidence interval?

A 95% confidence interval is a range — your estimate plus or minus the margin of error E — constructed so that, if you ran the same survey many times, 95% of the resulting intervals would contain the true population value. It's not a 95% probability that this one interval is right; it's a statement about the long-run reliability of the procedure. For a proportion, the interval is roughly (p̂ − 1.96·SE, p̂ + 1.96·SE) where SE = √(p̂(1 − p̂) / n).

Do I need to know the population size to calculate sample size?

Usually no. For populations large relative to the sample (more than ~20× the sample size), the population size effectively drops out of the math — a sample of 1,000 estimates a national population just as well as a global one. You only need to enter N when surveying a small, enumerable population: a 250-person department, a school of 1,200 students, a daily production lot of 500 units. In those cases the finite population correction can shrink the required sample by 20% or more.

Why use p = 0.5 when computing sample size?

The variance term p × (1 − p) is maximized at p = 0.5 (where it equals 0.25). Using p = 0.5 therefore gives the largest possible n for a given Z and E, guaranteeing your margin of error is met no matter what the true population proportion turns out to be. If you have a credible prior estimate — say 80% support based on previous polling — using the true p = 0.8 (variance 0.16) cuts the required sample by about 36%, but you take on the risk that the true value is closer to 50% than expected.

How a Sample Represents a Population

The whole point of sampling: a small random subset (n) can estimate a population (N) within a known margin of error, because the sampling distribution depends on the sample size, not the population size. The diagram below shows N members of a population with a small random sample highlighted inside it.

Sample drawn from a larger populationPopulation (N)Sample (n)

Sample Size Formulas

Three formulas cover almost every survey-sizing question:

n = (Z² × p × (1 − p)) / E²    (proportion)
n = (Z × σ / E)²    (mean, σ known)
n_adj = n / (1 + (n − 1) / N)    (finite population correction)

Where:

  • n — required sample size (always rounded up to the next whole number)
  • Z — standard-normal critical value for the desired confidence level (1.96 for 95%, 2.576 for 99%, 1.645 for 90%)
  • p — expected proportion of the trait, as a decimal between 0 and 1 (use 0.5 for the worst case when no prior estimate is available)
  • σ — known population standard deviation (mean form only — in the same units as the margin of error)
  • E — desired margin of error, as a decimal (0.05 = ±5 percentage points) for the proportion form, or in σ's units for the mean form
  • N — total population size (leave blank or omit for an effectively infinite population)

Worked Examples

Political Polling

How big should a national poll be to estimate vote share within ±3 percentage points at 95% confidence?

A polling firm wants to estimate support for a candidate within ±3 points at 95% confidence, with no prior estimate of the split.

  • Z = 1.96 (95% CI), p = 0.5 (worst case), E = 0.03.
  • n = (1.96² × 0.5 × 0.5) / 0.03²
  • n = 0.9604 / 0.0009 ≈ 1067.11

n = 1,068 respondents

This is why most national US polls report sample sizes of 1,000–1,200 — that's the sweet spot for a ±3% margin without breaking the survey budget.

Market Research

How many customers do I need to survey to estimate satisfaction within ±5% at 99% confidence?

A SaaS company has 5,000 active accounts and wants to estimate the satisfaction rate within ±5 percentage points at 99% confidence.

  • Z = 2.576 (99% CI), p = 0.5, E = 0.05, N = 5000.
  • n_raw = (2.576² × 0.25) / 0.0025 = 1.6590 / 0.0025 ≈ 663.6 → 664
  • Apply FPC: n_adj = 664 / (1 + 663 / 5000) = 664 / 1.1326 ≈ 586.3 → 587

n = 587 customers (FPC saves ~77 respondents)

The finite population correction matters here because the unadjusted sample (664) is more than 5% of the population (5,000). For a population of 5 million the FPC would have been negligible.

Healthcare / Clinical

How many patient records do I need to estimate average blood pressure within ±2 mmHg at 95% confidence?

Prior studies show σ ≈ 15 mmHg for systolic blood pressure in the target population. The research team wants the sample mean to be within ±2 mmHg of the true mean at 95% confidence.

  • Z = 1.96, σ = 15, E = 2.
  • n = (1.96 × 15 / 2)² = (14.7)²
  • n = 216.09 → 217

n = 217 patient records

Doubling σ to 30 mmHg would quadruple the requirement to ~868. Tightening E from ±2 to ±1 mmHg would also quadruple it. The σ²/E² scaling is why study planners obsess over pilot-study variance estimates.

Related Calculators

Related Sites