ThisCalculator

Statistics

Find Sample Size for a Confidence Interval

Updated · Standard formula, shown below

The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.

Find Sample Size for a Confidence Interval

This calculator estimates the minimum sample size needed to achieve a chosen confidence level and margin of error for a population proportion. Enter the confidence level, expected proportion, and margin of error; it returns the required sample size, rounded up to a whole person or item.

Formula

For a confidence interval estimating a population proportion, the usual large-sample planning formula is n = z²p(1 − p) / E². The calculator uses the common 95% confidence critical value, z = 1.96. Here, n is the unrounded required sample size in observations, p is the expected proportion written as a decimal from 0 to 1, and E is the margin of error written as a decimal. For example, 5% becomes 0.05. The displayed answer is rounded up to a whole number, because a sample cannot contain a fraction of an observation.

The calculator accepts confidence level as an input for clarity, but this version uses z = 1.96, so its formula applies specifically to 95% confidence. It does not change z when you enter a different confidence level. Use 95 in the confidence-level field; for another level, find the appropriate z critical value and use the general formula directly, or use a calculator designed to accept that value. Common two-sided z values are about 1.645 for 90%, 1.96 for 95%, and 2.576 for 99%.

Worked Example

Using the calculator’s default values—95% confidence, an expected proportion of 50%, and a 5% margin of error—convert the percentages to decimals: p = 0.50 and E = 0.05. The 95% critical value is z = 1.96.

Substitute into the formula:

n = 1.96² × 0.50 × (1 − 0.50) / 0.05²
= 3.8416 × 0.50 × 0.50 / 0.0025
= 0.9604 / 0.0025
= 384.16

Round up, not to the nearest integer: the required sample size is 385 observations. This is the same result the calculator displays. The 50% expected proportion is the conservative choice when you do not have a reliable prior estimate, because it produces the largest sample size for a given margin of error.

What You’ll Need

  • Confidence level: commonly 90%, 95%, or 99%. Higher confidence generally requires a larger sample.
  • Expected proportion: an estimate from prior data or a pilot study, expressed as a percentage from 0% to 100%. If unknown, use 50% for a cautious estimate.
  • Margin of error: the maximum absolute difference you want between the sample estimate and the population proportion, entered as a percentage. A smaller margin requires more observations.
  • A suitable sampling plan: the formula assumes a random, independent sample and does not correct for nonresponse, clustering, or a limited population.

Step-by-Step

  1. Confirm that you are estimating a proportion. This method is for a percentage or yes/no outcome, such as the share of respondents choosing an option. It is not the standard formula for estimating a population mean, such as average height or cost.
  2. Choose a confidence level. A 95% confidence interval is a common planning choice. In repeated sampling under the model’s assumptions, intervals built this way would cover the true proportion about 95% of the time. The calculator’s built-in formula is specifically for 95%; do not enter a different confidence level and assume the critical value has changed.
  3. Set the expected proportion. Use a defensible estimate from earlier research or a pilot. Enter it as a percentage: for example, enter 30 for 30%. If you lack an estimate, enter 50. Proportions nearer 50% have greater variability and therefore give a more conservative sample-size estimate.
  4. Choose the margin of error. Enter the desired half-width of the interval, not the full interval width. A margin of error of 5% means aiming for roughly plus or minus five percentage points. Enter 5, not 0.05, in this calculator.
  5. Read the result and round up. The output is the minimum number of usable observations under the formula’s assumptions. The calculator rounds up automatically. Do not round down or reduce the result to fit a preferred target without accepting a wider margin of error.
  6. Increase the recruitment target if needed. The formula gives the number of completed, usable observations, not necessarily the number of people to contact. If you expect a fraction r of invitees to respond, divide the required sample by r and round up. For example, a 70% response rate means r = 0.70. This adjustment handles expected nonresponse only; it does not fix biased sampling.
  7. Check the study design. If observations are clustered, weighted, or otherwise dependent, the effective sample size may be lower than the raw count. Account for the design effect or consult a statistician; simply collecting the calculated number may not deliver the intended precision.

Common Mistakes

  • Mixing up percent and decimal inputs: this calculator expects percentages such as 50 and 5. In the equation, those become 0.50 and 0.05. Using 0.05 as the input margin would mean 0.05%, not 5%.
  • Using the full interval width as the margin: a 10-percentage-point total width corresponds to a 5-point margin on either side of the estimate.
  • Rounding to the nearest whole number: always round the calculated sample size upward to ensure the target precision is met.
  • Assuming a different confidence level is supported: the calculator’s formula fixes z at 1.96. A 90% or 99% interval requires a different critical value and therefore a different calculation.
  • Treating sample size as a guarantee: the result relies on random, independent sampling and the normal approximation. Selection bias, measurement problems, and nonresponse can undermine an interval regardless of sample size.
  • Using a proportion formula for a mean: a continuous measurement needs a different calculation, usually involving an estimate of the population standard deviation.

Tips

Decide the desired precision before collecting data. Halving the margin of error roughly quadruples the required sample size, since the margin is squared in the denominator. Raising the confidence level also increases sample size because its z value is larger.

If you have no reliable estimate of the proportion, use 50% rather than guessing a value near zero or one. If your population is small and you will sample a substantial share of it without replacement, a finite population correction can reduce the needed sample, but this calculator does not apply that correction. Use a formula or tool that includes the total population size when that situation matters.

Troubleshooting

The answer seems too large: check that the margin was entered as a percentage, and remember that a very narrow margin or high confidence level requires many observations. Verify that you have not confused percentage points with relative percent error.

The answer seems too small: make sure the expected proportion is entered on a 0–100 scale and the margin is not accidentally entered as a whole number such as 5 when you intended 0.5%. Check whether your chosen confidence level needs a z value other than 1.96.

You need a different confidence level: calculate with n = z²p(1 − p)/E² using the appropriate two-sided critical value for that level, then round up. The listed z values are approximations; use a suitable statistical reference for the required precision.

Your target population is finite, or the sample is clustered: the basic result may be conservative for a small finite population, or inadequate for a clustered design. Apply the appropriate population correction or design effect rather than altering the result arbitrarily.

The result is not a whole number: that is expected before rounding. Keep the unrounded value during the calculation and round only the final sample size upward.

Frequently Asked Questions

What does n mean in a confidence interval?
It is the sample size: the number of observations used to estimate the population quantity.

Why does the calculator use 50% as its default proportion?
A proportion of 0.50 maximizes p(1 − p), so it gives the largest required sample size when the true proportion is unknown.

Why must I round the sample size up?
Rounding down could leave the sample just below the number needed to achieve the chosen margin of error.

Can I use this method for a mean?
No. This formula is for a population proportion. Estimating a mean requires a standard deviation estimate and a different sample-size formula.

Does the result include people who do not respond?
No. It is the number of usable observations. Increase the number invited to account for expected nonresponse.

Does a larger sample remove sampling bias?
No. A larger sample can reduce random sampling error, but it cannot correct a systematically unrepresentative sample or faulty measurements.

Related

Formula used
in c | Confidence level | % | 95 | 0
in p | Expected proportion | % | 50 | 0
in e | Margin of error | % | 5 | 0
out n | Required sample size | observations | (1.96^2 * (p / 100) * (1 - p / 100)) / ((e / 100)^2) | 0

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.