acalculator

What sample size do I need?

Find how many people or items to sample for a survey or a mean, or per group to compare two groups with enough power.

Your numbers

I want to
Common values: 90, 95, 99.
Sample size
385

You need a sample size of 385 in total.

Sample size is
in total
Before rounding up
384.15
z for the confidence level
1.959964

Sample size: 385. You need a sample size of 385 in total.

How to calculate

Computes the sample size for a survey proportion or a mean at a margin of error and confidence level, with a finite population, or per group to compare two means or two proportions with a given power.

Example with the default inputs (I want to Survey a proportion, Confidence level 95%, Margin of error 5%, Expected proportion 50%): You need a sample size of 385 in total.

Method: Proportion: n₀ = z² p(1 − p) ÷ E². Mean: n₀ = (z σ ÷ E)². Finite population: n = n₀ ÷ (1 + (n₀ − 1) ÷ N). Two means: n = 2 (z(α/2) + z(β))² σ² ÷ Δ² per group. Two proportions: n = (z(α/2) + z(β))² (p₁q₁ + p₂q₂) ÷ (p₁ − p₂)² per group. Round up.

  • Simple random sampling. The z values are exact standard normal quantiles (1.959964, not 1.96).
  • The comparisons use a two-sided test at level α and groups of equal size.
  • Every sample size is rounded up to the next whole number.

Machine-readable copies: Markdown, JSON.

Worked examples

Each example is checked against the calculator on every build.

  1. I want to Survey a proportion, Confidence level 95%, Margin of error 5%, Expected proportion 50% gives Sample size 385, Before rounding up 384.145882, z for the confidence level 1.959964.Source: Israel, Determining Sample Size, University of Florida IFAS Extension PEOD6, 1992 (Cochran’s formulas). https://ask.ifas.ufl.edu/publication/PD006 (n₀ = 1.96² × 0.5 × 0.5 ÷ 0.05² = 385)
  2. I want to Survey a proportion, Confidence level 95%, Margin of error 5%, Expected proportion 50%, Population size 2,000 gives Sample size 323, For a very large population 385, Before rounding up 322.385537.Source: Israel, Determining Sample Size, University of Florida IFAS Extension PEOD6, 1992 (Cochran’s formulas). https://ask.ifas.ufl.edu/publication/PD006 (385 ÷ (1 + 384 ÷ 2000) = 323)
  3. I want to Estimate a mean, Confidence level 95%, Standard deviation (σ) 15, Margin of error 3 gives Sample size 97, Before rounding up 96.036471.Source: Israel, Determining Sample Size, University of Florida IFAS Extension PEOD6, 1992 (Cochran’s formulas). https://ask.ifas.ufl.edu/publication/PD006
  4. I want to Compare two means, Standard deviation (σ) 10, Difference to detect (Δ) 5, Significance level (α) 0.05, Power 80% gives Sample size 63, Total for both groups 126, Before rounding up 62.791038, z for the power 0.841621.Source: Noordzij et al., Sample size calculations: basic principles and common pitfalls, Nephrology Dialysis Transplantation, 2010. https://doi.org/10.1093/ndt/gfp732
  5. I want to Compare two proportions, Proportion in group 1 60%, Proportion in group 2 45%, Significance level (α) 0.05, Power 80% gives Sample size 171, Total for both groups 342, Before rounding up 170.059061.Source: Noordzij et al., Sample size calculations: basic principles and common pitfalls, Nephrology Dialysis Transplantation, 2010. https://doi.org/10.1093/ndt/gfp732
  6. I want to Estimate a mean, Confidence level 95%, Standard deviation (σ) 1, Margin of error 1 gives Sample size 4.Source: NIST/SEMATECH e-Handbook of Statistical Methods, §7.2.2.2 Sample sizes required. https://www.itl.nist.gov/div898/handbook/prc/section2/prc222.htm

How it works

All z values are standard normal quantiles of the exact tail, not table values: z with an upper tail of a is the value with P(Z > z) = a, where a is worked out exactly from the typed percent ((100 − C) ÷ 200 for a confidence level C, (100 − P) ÷ 100 for a power P). So the z for 95% confidence is 1.959964, not the table's 1.96. The quantiles are good to about 15 significant digits.

Survey a proportion (Cochran)

With confidence level C, margin of error E, and expected proportion p (E and p as fractions, so 5% is 0.05):

  • z = the z with upper tail (1 − C ÷ 100) ÷ 2
  • n₀ = z² × p × (1 − p) ÷ E²

Estimate a mean (Cochran)

With the expected standard deviation σ and the margin of error E in the same units:

  • n₀ = (z × σ ÷ E)²

Finite population

For both, with a population size N: n = n₀ ÷ (1 + (n₀ − 1) ÷ N). Without N, n = n₀. The page then also shows n₀ rounded up ("for a very large population") when n₀ is at most 10¹⁵.

Compare two means (per group)

With a two-sided significance level α, power P, standard deviation σ in each group, and the difference to detect Δ:

  • z(α/2) = the z with upper tail α ÷ 2, z(β) = the z with upper tail 1 − P ÷ 100
  • n = 2 × (z(α/2) + z(β))² × σ² ÷ Δ² in each group

Compare two proportions (per group)

With expected proportions p₁ and p₂ (as fractions), q₁ = 1 − p₁ and q₂ = 1 − p₂:

  • n = (z(α/2) + z(β))² × (p₁q₁ + p₂q₂) ÷ (p₁ − p₂)² in each group

Results

  • Sample size: the formula's n rounded up to the next whole number, in total (estimates) or in each group (comparisons).
  • Total for both groups: 2 × the sample size per group (comparisons).
  • Before rounding up: the unrounded n, to 2 decimal places.
  • z for the confidence level (or z(α/2)), and z for the power (z(β), comparisons).

Rules

  • Confidence level 1% to 99.9999%; margin of error 0.0001% to 50%; proportions 0.0001% to 99.9999%; σ, E, and Δ from 0.000000001 to 10¹²; population 1 to 10¹²; α 0.0000000001 to 0.5; power 50% to 99.9999%.
  • The two proportions must differ.
  • An unrounded sample size above 10¹⁵ has no answer (the margin or difference is too small for any real study). For a survey or a mean with a population size, the rule reads the unrounded size after the population correction, which is never more than N, so it always has an answer; "for a very large population" is then shown only when n₀ is at most 10¹⁵.
  • The unrounded value shows 2 decimal places and the z values up to 6, with halves rounded up.

Worked examples by hand

Survey, 95%, ±5%, p = 50%. z = 1.959964; n₀ = 1.959964² × 0.25 ÷ 0.0025 = 3.841459 × 100 = 384.15, rounded up to 385 (Israel 1992: 385).

The same survey of 2,000 people. n = 384.1459 ÷ (1 + 383.1459 ÷ 2000) = 384.1459 ÷ 1.191573 = 322.39, rounded up to 323 (Israel: 323). For a very large population: 385.

A mean within ±3 when σ = 15, 95%. n₀ = (1.959964 × 15 ÷ 3)² = 9.79982² = 96.04, rounded up to 97.

Two means, σ = 10, Δ = 5, α = 0.05, power 80%. z(α/2) = 1.959964 and z(β) = 0.841621, so (z(α/2) + z(β))² = 7.84888. n = 2 × 7.84888 × 100 ÷ 25 = 62.79, rounded up to 63 in each group, 126 in total.

Two proportions, 60% against 45%, α = 0.05, power 80%. p₁q₁ + p₂q₂ = 0.24 + 0.2475 = 0.4875. n = 7.84888 × 0.4875 ÷ 0.15² = 170.06, rounded up to 171 in each group, 342 in total.

A mean within 1 standard deviation, 95%. n₀ = 1.959964² = 3.8415, rounded up to 4.

Other questions people ask

How many people do I need to survey?

For a margin of error of ±5% at 95% confidence, with no idea of the answer (use 50%), you need 385 responses. Cochran’s formula gives n = 1.96² × 0.5 × 0.5 ÷ 0.05² = 384.1, rounded up to 385.

Why use 50% for the expected proportion?

The formula depends on p × (1 − p), which is largest at p = 50%. If you do not know the proportion in advance, 50% gives a sample big enough for any answer. If you expect something like 10%, the sample needed is smaller.

Does the population size matter?

Only when the sample would be a sizeable share of it. The finite population correction n = n₀ ÷ (1 + (n₀ − 1) ÷ N) cuts 385 to 323 for a population of 2,000, but barely changes it for a population of 1,000,000. Leave the population empty when it is very large or unknown.

What is statistical power?

Power is the chance that a study detects a difference that really exists. 80% is the usual minimum; 90% is common in clinical trials. Higher power, a smaller difference to detect, or a stricter α all need a larger sample.

How do I choose the difference to detect?

Choose the smallest difference that would matter in practice, such as a 5-point change in a test score. Detecting half the difference needs about four times the sample, because the sample size grows with 1 ÷ Δ².

Why is the answer rounded up?

You cannot sample part of a person, and rounding down would give slightly less precision or power than you asked for. The calculator always rounds up and shows the unrounded value too.