Math

How Confidence Intervals and Sample Size Work

A confidence interval is mean ± critical value × standard deviation ÷ √n, and the sample size for a proportion is n = z² × p(1 − p) ÷ e². A mean of 50, standard deviation 10 and n = 100 give a 95% interval of 48.04 to 51.96. A survey with a ±5% margin at 95% confidence needs 385 responses.

By CalculatorHub Editorial TeamPublished December 2, 2026Updated December 2, 20267 min read
Run the numbers yourself. Try our free Confidence Interval Calculator and see the result with your own figures.

From a sample to a range

A sample mean is only an estimate of the population mean. A confidence interval turns it into a range that is likely to contain the true value. The ingredients are the sample mean, the standard deviation s, the sample size n and the confidence level.

  1. Standard error = s ÷ √n. For s = 10 and n = 100 that is 1.
  2. Critical value: 1.96 for 95% confidence (z).
  3. Margin of error = 1.96 × 1 = 1.96.
  4. Interval = 50 ± 1.96 = 48.04 to 51.96.

What 95% confidence means

If you repeated the sampling many times and built an interval each time, about 95% of those intervals would contain the true mean. It does not mean there is a 95% probability that the true mean lies in your one interval. Raising the confidence level widens the interval: the critical value is 1.645 for 90%, 1.96 for 95% and 2.576 for 99%.

z or t?

Use the z value when the population standard deviation is known or the sample is large. When you estimate it from a small sample, use the t distribution with n − 1 degrees of freedom. For n = 12 the 95% critical value is 2.201, compared with 1.96 for z, so the interval is wider. At n = 100 the t value is 1.984, almost the same as z.

How the sample size matters

The margin of error shrinks with the square root of n. To halve it you need four times the sample, which is why precision gets expensive.

Planning a survey: the sample size formulas

EstimatingFormulaExample
A proportionn = z² × p(1 − p) ÷ e²95%, e = 5%, p = 50%: 385
A meann = (z × σ ÷ e)²95%, σ = 15, e = 2: 217

Use p = 50% if you have no estimate, because it gives the largest sample. Always round up. For a small population N, adjust: n ÷ (1 + (n − 1) ÷ N). With N = 10,000 the 385 above becomes 370.

Typical margins of error (95%, p = 50%)

  • ±10%: 97 responses.
  • ±5%: 385 responses.
  • ±3%: 1,068 responses.
  • ±1%: 9,604 responses.

Practical advice

  • Divide the target by your expected response rate to decide how many people to contact.
  • The formulas assume a random sample. A biased sample stays biased however large it is.
  • If you need results for subgroups, each subgroup needs its own sample.

Run your numbers with the confidence interval calculator and the sample size calculator, and explore critical values with the z-score calculator.

Key terms

  • Standard error: The standard deviation of the sample mean.
  • Margin of error: Half the width of a confidence interval.
  • Critical value: The multiplier for the confidence level.
  • Confidence level: How often the method captures the true value.
  • Degrees of freedom: n − 1 for a single sample mean.

Practice questions

Try each one before you read the answer.

  1. s = 20, n = 100. Standard error?
    Answer: 2.
  2. Mean 80, margin of error 3. Interval?
    Answer: 77 to 83.
  3. To halve the margin of error, how much larger must the sample be?
    Answer: Four times larger.

Frequently asked questions

Why does a bigger sample give a narrower interval?

The standard error is s ÷ √n, so it falls as n rises. Quadrupling the sample halves the margin of error.

How many survey responses do I need?

About 385 for a ±5% margin at 95% confidence from a large population, and about 1,068 for ±3%.

What is the difference between standard deviation and standard error?

The standard deviation measures the spread of individual values. The standard error measures the spread of the sample mean, which is smaller by a factor of √n.

Try the calculators

Keep reading