Sample Size Calculator
Calculate the required sample size for your survey or study to achieve a desired level of precision. Determine how many observations you need based on your confidence level, margin of error, and expected variability. See also our Margin of Error Calculator, Confidence Interval Calculator, and Standard Error Calculator.
How to Use the Sample Size Calculator
Determining the right sample size is one of the most important steps in planning a research study or survey. Too small a sample may fail to detect meaningful effects (low statistical power), while too large a sample wastes resources. This calculator helps you find the minimum sample size needed to achieve your desired precision, measured by the margin of error at a given confidence level.
For proportion-based studies (surveys, polls, A/B tests), enter the desired confidence level, target margin of error as a percentage, and your best estimate of the population proportion. If you have no prior estimate, use p = 0.5 for the most conservative (largest) sample size. For studies measuring continuous variables (means), enter the confidence level, desired margin of error in the same units as your measurement, and an estimate of the population standard deviation from pilot studies or previous research.
If your population is finite and relatively small, enter the population size to apply the finite population correction (FPC). This reduces the required sample size because sampling a larger fraction of the population provides more information. The FPC is most impactful when the sample would be more than 5% of the population. For very large populations (over 100,000), the correction is negligible and can be ignored.
Sample Size Formulas
For Proportion:
n = z² × p(1-p) / E²
where E is the margin of error as a decimal
For Mean:
n = (z × σ / E)²
where E is the margin of error in measurement units
Finite Population Correction:
n_adj = n / (1 + (n-1)/N)
where N is the population size
Maximum Sample Size (p=0.5):
n_max = z² / (4E²)
This gives the largest possible n for any proportion
Example Calculation
A market researcher wants to estimate the proportion of customers who prefer a new product design with a margin of error of ±3% at 95% confidence. No prior estimate of the proportion is available.
Given: confidence = 95%, E = 3% = 0.03, p = 0.5 (conservative)
z* for 95% confidence = 1.960
n = z² × p(1-p) / E²
n = 1.960² × 0.5 × 0.5 / 0.03²
n = 3.8416 × 0.25 / 0.0009
n = 0.9604 / 0.0009
n = 1067.11 → round up to 1068
Required sample size: 1,068 respondents
If population = 10,000:
n_adj = 1068 / (1 + 1067/10000) = 1068/1.1067 = 965
Required Sample Sizes Reference Table (p=0.5)
| Margin of Error | n (95% CI) | n (99% CI) |
|---|---|---|
| ±1% | 9604 | 16587 |
| ±2% | 2401 | 4147 |
| ±3% | 1068 | 1844 |
| ±4% | 601 | 1037 |
| ±5% | 385 | 664 |
| ±7% | 196 | 339 |
| ±10% | 97 | 166 |
Real-World Applications
Clinical Trial Design
Before a drug trial begins, researchers calculate the minimum sample size needed to detect a clinically meaningful effect. Under-powered trials waste resources and may miss real effects. A trial expecting a 5-point blood pressure reduction with SD = 12 at 80% power needs about 90 patients per group.
Survey Planning
Market researchers determine how many respondents are needed for reliable results. For a population of 100,000 with desired MOE of 3% at 95% confidence, approximately 1,068 respondents are needed - regardless of whether the population is 100,000 or 10 million.
A/B Testing in Technology
Tech companies calculate sample sizes before running website experiments. To detect a 2% improvement in conversion rate (from 5% to 7%) with 80% power, each variant needs about 1,500 visitors. Running the test shorter produces unreliable results.
Additional Solved Examples
Example: Sample Size for Estimating a Mean
A researcher wants to estimate average study hours within +/-1 hour at 95% confidence. Prior studies suggest SD = 6 hours. What sample size is needed?
n = (z* x sigma / MOE)^2
n = (1.96 x 6 / 1)^2
n = (11.76)^2 = 138.3
Round up: n = 139
Answer: At least 139 students must be surveyed. Always round up because rounding down would yield a slightly larger MOE than desired.
Example: Sample Size for a Proportion
An election poll wants MOE of 2% at 95% confidence. No prior estimate of the proportion is available. Calculate the required sample size.
Use p = 0.5 (most conservative, maximizes sample size)
n = (z*/MOE)^2 x p(1-p)
n = (1.96/0.02)^2 x 0.5 x 0.5
n = (98)^2 x 0.25 = 9604 x 0.25 = 2401
Answer: The poll needs 2,401 respondents for a +/-2% margin of error. Using p = 0.5 is the safe choice when no prior estimate exists, as it maximizes the required sample size.
Common Mistakes
Rounding down the calculated sample size
If the formula gives n = 384.16, you need 385 subjects, not 384. Rounding down means your MOE will be slightly larger than specified. Always round UP to the next whole number.
Not accounting for non-response
If you need 400 completed surveys and expect a 60% response rate, send surveys to 400/0.60 = 667 people. Failure to account for attrition or non-response leaves you with an underpowered study.
Using an unrealistic standard deviation estimate
Sample size formulas require an estimate of SD (or proportion). If your SD estimate is too low, the actual MOE will exceed your target. Use pilot studies, prior research, or conservative estimates to avoid underpowering.
Key Takeaways
- Sample size is determined BEFORE data collection based on desired precision, confidence level, and expected variability.
- Doubling precision (halving MOE) requires quadrupling the sample size due to the square root relationship.
- For proportions, use p = 0.5 when no prior estimate is available (gives the largest, most conservative n).
- Increasing confidence level from 95% to 99% increases required sample size by about 78%.
- For finite populations, apply the finite population correction: n_adj = n / (1 + (n-1)/N).
Frequently Asked Questions
How do I estimate the standard deviation for sample size calculation?
You can estimate the standard deviation from: (1) Pilot studies or preliminary data, (2) Previous research on similar populations, (3) The range rule: σ ≈ range/4 for roughly normal data, (4) Expert judgment. If unsure, it's better to overestimate σ (which gives a larger, more conservative sample size) than to underestimate it and end up with insufficient precision.
Should I account for non-response in my sample size?
Yes. The calculated sample size assumes all selected participants respond. In practice, response rates are often 20-60% for surveys. Divide the required sample size by the expected response rate to determine how many people to contact. For example, if you need n=400 and expect a 50% response rate, you should contact 800 people. Also consider whether non-respondents differ systematically from respondents.
What if I need to compare two groups?
For comparing two proportions or means, you need the sample size per group, not total. The formula for comparing two proportions is: n = (z_α/2 + z_β)² × [p₁(1-p₁) + p₂(1-p₂)] / (p₁-p₂)². For comparing two means: n = 2(z_α/2 + z_β)² × σ² / δ², where δ is the minimum detectable difference. These formulas incorporate statistical power (typically 80%).
What is statistical power and how does it relate to sample size?
Statistical power is the probability of detecting a true effect (rejecting H₀ when it's false). Power = 1 - β, where β is the Type II error rate. Standard practice is to aim for 80% power. Larger sample sizes increase power. The relationship between sample size and power depends on the effect size — smaller effects require larger samples to detect. Power analysis should be conducted before data collection to ensure adequate sample size.
Why does halving the margin of error quadruple the sample size?
Because sample size is inversely proportional to the square of the margin of error: n ∝ 1/E². If you want half the MOE (E/2), you need n ∝ 1/(E/2)² = 4/E², which is 4 times the original sample size. This quadratic relationship means that achieving very high precision becomes increasingly expensive. Going from ±5% to ±2.5% MOE requires 4× the sample, and from ±5% to ±1% requires 25× the sample.
Is there a minimum sample size I should always use?
While there is no universal minimum, practical guidelines suggest: (1) At least 30 observations for the Central Limit Theorem to apply, (2) At least 10 successes and 10 failures for proportion estimates (np ≥ 10 and n(1-p) ≥ 10), (3) At least 15-20 per group for t-tests, (4) At least 5 expected observations per cell for chi-square tests. These are minimums — larger samples are always better for precision and power.