Sample Size for Mean Calculator
When designing a study to estimate a continuous outcome (such as blood pressure, income, or test score), you need to decide on a sample size before collecting data. This calculator determines the minimum sample size needed to achieve a specified margin of error at a given confidence level. You need to estimate the standard deviation of the measurement. Enter the confidence level, desired margin of error, and the standard deviation estimate to get the required n. The result is always rounded up because you cannot survey a fraction of a person.
Sample size formula
n = (z × s / E)²
Where z is the critical z-value (1.645 for 90%, 1.960 for 95%, 2.576 for 99%), s is the estimated standard deviation, and E is the acceptable margin of error in the same units as the measurement. The result is rounded up to the next whole number.
Sensitivity of sample size to inputs
- Doubling the standard deviation quadruples the required sample size (n scales as s squared).
- Halving the margin of error quadruples the required sample size (n scales as 1/E squared).
- Moving from 95% to 99% confidence increases n by about 73% (from z = 1.960 to 2.576, ratio squared = 1.73).
- Example: s = 20, E = 5, 95% confidence: n = (1.960 times 20 / 5) squared = (7.84) squared = 61.47, rounded up to 62.
Frequently asked questions
What is the formula for sample size when estimating a mean?
n = (z times s divided by E) squared, where z is the critical z-value for the chosen confidence level, s is the population or estimated standard deviation, and E is the desired margin of error (the maximum allowable error in the estimate).
What standard deviation should I use?
Use the population standard deviation if known. If unknown, use a pilot study estimate, a historical estimate from similar data, or a conservative estimate (such as the range divided by 4 or 6). The required sample size is very sensitive to s, so overestimating is safer than underestimating.
What margin of error should I choose?
The margin of error depends on the context. For clinical studies, practical significance determines an acceptable error. For quality control, tolerance limits drive the choice. For surveys, the margin of error is often expressed as an absolute value (for example, estimate the mean to within plus or minus 5 units).
How does confidence level affect the required sample size?
Higher confidence levels require larger samples because the critical z-value is larger. At 95% confidence, z = 1.960; at 99% confidence, z = 2.576. Because n is proportional to z squared, going from 95% to 99% confidence increases the required sample size by about 73%.
Is the result always rounded up?
Yes. Sample sizes must be whole numbers, and rounding down would give a sample smaller than required, so the formula result is always rounded up to the next whole number.
Official sources
- NIST/SEMATECH e-Handbook of Statistical Methods: Sample Sizes Required for Estimating a Mean.
- NIST/SEMATECH e-Handbook: Engineering Statistics Handbook.
Reviewed by the CalculatorHub team, edited by James Graham, 15 June 2026. See our methodology.