Sample Size Calculator Formula

Understand the math behind the sample size calculator. Each variable explained with a worked example.

Formulas Used

Sample Size (exact)

sample_size_raw = pow(z * sigma / moe, 2)

Standard Error at This n

se_achieved = sigma / sqrt(pow(z * sigma / moe, 2))

Variables

VariableDescriptionDefault
zZ-Value (e.g., 1.96 for 95%)1.96
sigmaPopulation Standard Deviation15
moeDesired Margin of Error3

How It Works

How to Calculate Required Sample Size

Formula

n = (z * sigma / E)^2

where E is the desired margin of error, z is the critical value for the confidence level, and sigma is the population standard deviation. Always round up to the next whole number since you cannot have a fractional observation.

Worked Example

You want a 95% CI with margin of error 3 and estimated SD 15. How many observations are needed?

z = 1.96sigma = 15moe = 3
  1. 01n = (z * sigma / E)^2
  2. 02n = (1.96 * 15 / 3)^2
  3. 03n = (9.8)^2
  4. 04n = 96.04
  5. 05Round up: n = 97 observations needed

Ready to run the numbers?

Open Sample Size Calculator