To estimate a mean, the sample size is n = (z x σ / E)^2. To estimate a proportion, it is n = z^2 x p x (1 minus p) / E^2. Round up in both cases. Here z is 1.960 for 95% confidence and E is the margin of error you can live with. Pick the kind of estimate below, enter the precision you want and the confidence you need, and the calculator gives the sample size with the formula it used. Free, no sign-up, nothing leaves your browser.

Sample Size Calculator

What are you estimating?

When to use it

Use it before you collect data, when the question is “how many do I need?” Use the mean version for measured data such as cycle time, weight or length. Use the proportion version for pass/fail data such as defect rate or on-time rate. It sizes a sample for an estimate with a confidence interval. It does not size a hypothesis test with a power target.

The formulas

For a mean (continuous data, σ known or estimated):

n = (z x σ / E)^2, rounded up

  • z is the two-sided standard normal value for your confidence level: 1.645 for 90%, 1.960 for 95%, 2.576 for 99%
  • σ is the process standard deviation (historical data or a pilot run)
  • E is the margin of error, half the width of the confidence interval you want, in the same units as σ

For a proportion (pass/fail data):

n = z^2 x p x (1 minus p) / E^2, rounded up

  • p is your best guess at the proportion; 0.5 is the conservative choice because p(1 minus p) peaks there
  • E is the margin of error as a proportion (plus or minus 5 points is 0.05)

Finite population correction, when you know the population size N and the sample is a noticeable share of it:

n(corrected) = n / (1 + (n minus 1) / N), rounded up

Worked examples

A mean. Cycle time has a standard deviation of about 15 minutes. You want the average known to plus or minus 3 minutes at 95% confidence.

n = (1.960 x 15 / 3)^2 = (9.80)^2 = 96.04, so collect 97 cycle times.

A proportion. You want a defect rate to plus or minus 5 percentage points at 95% confidence and have no prior estimate, so p = 0.5.

n = 1.960^2 x 0.5 x 0.5 / 0.05^2 = 384.1, so inspect 385 parts.

The same proportion from a lot of 1,000. The population is finite, so the correction applies.

n = 384.1 / (1 + 383.1 / 1,000) = 277.7, so inspect 278 parts.

What moves the number

  • Halving the margin of error quadruples the sample size. Precision is expensive.
  • Going from 95% to 99% confidence raises n by about 73% (2.576^2 / 1.960^2).
  • A guess of p = 0.5 is the worst case. If you know the rate is near 5%, p(1 minus p) drops from 0.25 to 0.0475 and n falls by about 80%.
  • The population correction only matters when the sample would be more than about 5% of the population. For a continuous process there is no N; use the uncorrected number.

The assumptions behind every number, and all the formulas in one place, are on the calculator assumptions and formulas page.

Go deeper

Studying for an exam? Sampling and sample size are on the Green Belt and Black Belt bodies of knowledge. The practice questions are in the study guide courses.