Sample size (survey / A-B test) calculator

How many samples you need for a given margin of error. Enter your values and see the formula, your numbers plugged in and every step of the working. Free, no sign-up, SI and imperial units.

Formula

n = z² · p · (1 − p) / E²

Inputs

  • Confidence level (z)
  • Margin of error (E), in % or other units
  • Expected proportion (50 % if unknown) (p), in % or other units

Worked example: 95 % confidence, ±5 %, unknown proportion

  • Confidence level z = 95 % (z = 1.96)
  • Margin of error E = 5 %
  • Expected proportion (50 % if unknown) p = 50 %
  1. Convert inputs to SI units: E = 5 % = 0.05 ; p = 50 % = 0.5
  2. n = 1.96² × 0.5 × 0.5 ÷ 0.05² = 0.9604 ÷ 0.0025 = 384.16
  3. Round up: n = 385
  4. Assumes simple random sampling from a large population.

Answer: Required sample size n = 385

More data engineering calculators

Data Engineering formula sheet · All calculators · Practice problems