Quick answer
For a proportion, n = z² × p(1 − p) ÷ E²; for a mean, n = (zσ ÷ E)². At 95% confidence (z = 1.96), a 5% margin of error and p = 0.5, n = 3.8416 × 0.25 ÷ 0.0025 = 384.15, so you need 385 responses.
Choose whether you estimate a proportion or a mean, then enter the confidence level, margin of error and expected proportion or standard deviation. The calculator returns the required sample size.
Related tools: Confidence Interval Calculator: Confidence interval for a mean (t or z). Z-Score Calculator: Standardize a value using a mean and standard deviation. Standard Deviation Calculator: Sample or population standard deviation with variance and mean.
How to use the Sample Size Calculator
- Choose estimate a: Mean and Proportion.
- Enter confidence level (%) (between 0 and 99.999). It starts at 95.
- Enter margin of error (above 0).
- Enter σ (mean) or expected proportion p (0–1) (above 0). It starts at 0.5.
- Press Calculate to see the result, and use Reset to start again.
| Input | What to enter | Allowed values |
|---|---|---|
| Estimate a | Choose one: Mean; Proportion | Starts at Proportion |
| Confidence level | A number, in % | > 0, ≤ 99.999, starts at 95 |
| Margin of error | A number | > 0 |
| σ (mean) or expected proportion p (0–1) | A number | > 0, starts at 0.5 |
Formula and method
Formula
n = (z* σ ÷ E)²; n = z*² p(1 − p) ÷ E²
IEEE-754 double precision; shown to at most 6 decimal places.
Rounded up to the next whole respondent. p = 0.5 is the most conservative choice.
Worked examples
These examples are verified: each one is an automated test case that the live calculator must reproduce exactly.
Example 1
Inputs: Estimate a = Proportion; Confidence level = 95; Margin of error = 0.05; σ (mean) or expected proportion p (0–1) = 0.5.
| Result | Value |
|---|---|
| Required sample size | 385 |
| Unrounded | 384.145882 |
Example 2
Inputs: Estimate a = Mean; Confidence level = 95; Margin of error = 2; σ (mean) or expected proportion p (0–1) = 15.
| Result | Value |
|---|---|
| Required sample size | 217 |
| Unrounded | 216.082059 |
The first line is the headline result (required sample size). Below it the sample Size Calculator lists unrounded, which describe the same case from other angles. IEEE-754 double precision; shown to at most 6 decimal places.
Why p = 0.5
p(1 − p) is largest at p = 0.5, so using 0.5 gives the most conservative (largest) sample when you have no prior estimate. A known proportion of 0.1 needs only 139 responses at the same settings.
What it assumes
The formula assumes a simple random sample from a large population. A finite-population correction reduces n for small populations, and design effects, non-response and subgroup analysis raise it; this page does not apply them.
How the result changes with margin of error
Holding every other input at the first worked example, this table changes only margin of error. It shows how sensitive the answer is to that one value; each row was produced by running this calculator.
| Margin of error | Required sample size | Unrounded |
|---|---|---|
| 0.025 | 1537 | 1,536.583528 |
| 0.05 | 385 | 384.145882 |
| 0.1 | 97 | 96.036471 |
| 0.2 | 25 | 24.009118 |
What happens with invalid input
These messages are produced by the calculator itself, so you know what to fix.
- σ (mean) or expected proportion p (0–1): entering "1" shows "A proportion must be between 0 and 1." beside that field and no result.
Choosing between the Sample Size Calculator and similar calculators
Each row shows what a related calculator on this site asks for and what it returns, so you can pick the one that matches your question.
| Calculator | You enter | It returns |
|---|---|---|
| [Confidence Interval Calculator](/statistics/confidence-interval-calculator/) | sample mean, standard deviation and sample size | Confidence interval |
| [Z-Score Calculator](/statistics/z-score-calculator/) | value, mean and standard deviation | Z-score |
| [Standard Deviation Calculator](/statistics/standard-deviation-calculator/) | data set and data type | Population standard deviation (σ) |
| [Mean Median Mode Calculator](/statistics/mean-median-mode-calculator/) | data set | Mean |
| [Effect Size (Cohen's d) Calculator](/statistics/effect-size-calculator/) | mean 1, sD 1 and n₁ | Cohen's d |
Background: hypothesis testing and inference
A hypothesis test compares a test statistic with what the null hypothesis predicts. The decision rule is to reject the null hypothesis when the p-value is at or below the significance level α, which you should choose before seeing the data (0.05 is conventional, not special). For a two-tailed z test the p-value is 2 × (1 − Φ(|z|)); for a one-sample t test the statistic is (x̄ − μ₀) ÷ (s ÷ √n) with n − 1 degrees of freedom.
Failing to reject the null hypothesis does not prove it true, and a statistically significant result can still be too small to matter in practice.
Assumptions and limitations
- Proportion below 1
If a required value is empty, not a number, or outside its allowed range, the form marks that field with a message and shows no result instead of a misleading number. The automated checks deliberately try invalid entries for σ (mean) or expected proportion p (0–1) to confirm this.
Frequently asked questions
What confidence level should I choose?
95% is the most common default.
What happens if I halve the margin of error?
The sample size roughly quadruples.
Why round up?
A fraction of a respondent cannot be sampled, and rounding down would miss the target.
What does the Sample Size Calculator calculate?
Sample size for estimating a mean or a proportion. It returns Required sample size and Unrounded.
What formula does the Sample Size Calculator use?
n = (z* σ ÷ E)²; n = z*² p(1 − p) ÷ E². Rounded up to the next whole respondent.
What do I need to enter in the sample Size Calculator?
You enter Estimate a, Confidence level (%), Margin of error and σ (mean) or expected proportion p (0–1).
How is the result rounded or limited?
IEEE-754 double precision; shown to at most 6 decimal places. Proportion below 1.
What does the “Estimate a” option change?
It sets how the sample Size is worked out. The choices are Mean and Proportion.
What is an example of a sample Size result?
With estimate a Proportion, confidence level 95, margin of error 0.05 and σ (mean) or expected proportion p (0–1) 0.5, the required sample size is 385.
Related calculators
- Confidence Interval Calculator — Confidence interval for a mean (t or z).
- Z-Score Calculator — Standardize a value using a mean and standard deviation.
- Standard Deviation Calculator — Sample or population standard deviation with variance and mean.
- Mean Median Mode Calculator — Mean, median and mode of a data set.
- Effect Size (Cohen's d) Calculator — Cohen's d for two groups.
- Point Estimate Calculator — Point estimates of a proportion (MLE, Laplace and Wilson).
- Standard Error Calculator — Standard error of a mean or a proportion.
- Margin of Error Calculator — Margin of error for a mean or a proportion.
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods (itl.nist.gov/div898/handbook)
- Standard textbook definitions (e.g. Moore, McCabe & Craig, Introduction to the Practice of Statistics)
Content last reviewed 2026-11-04. Formulas and worked examples are checked by automated tests against independently computed values.