Sample Size Calculator — Step-by-Step Solutions
The Sample Size Calculator determines how many observations you need for a statistically valid study. Calculate the required sample size for proportion-based surveys, mean-based studies, or find the margin of error for a given sample size.
Select your confidence level, enter your parameters, and get the required sample size instantly with step-by-step formula breakdowns.
Your calculations will appear here
How to Use the Sample Size Calculator
- Pick what you need: Sample Size (Proportion) for yes/no survey questions, Sample Size (Mean) for measured quantities, or Margin of Error if you already have a sample size and want to know how precise it is.
- Choose the confidence level from the list (80%, 85%, 90%, 95% or 99%). 95% is the usual choice for surveys and research.
- For a proportion, enter the margin of error as a decimal (0.05 means plus or minus 5 percentage points) and your estimated proportion. If you have no idea what the proportion will be, use 0.5, which gives the largest and safest sample.
- For a mean, enter the margin of error in the same units as your measurement and the population standard deviation, taken from a pilot study or earlier research. The result is always rounded up to the next whole person.
Formula and Theory
A sample size calculation answers one question: how many responses do you need so that your estimate is within a chosen margin of error, with a chosen level of confidence. A narrower margin or a higher confidence level both demand a larger sample, and the cost grows quickly: halving the margin of error needs about four times as many responses.
For a proportion, n = z^2 x p x (1 - p) / E^2, where z is the critical value for the confidence level (1.96 for 95%), p is the expected proportion and E is the margin of error. The product p(1 - p) is largest at p = 0.5, so 0.5 is the conservative choice when nothing is known.
For a mean, n = (z x sigma / E)^2, where sigma is the population standard deviation. A noisier measurement (larger sigma) needs a bigger sample for the same precision.
These formulas assume simple random sampling from a large population. Sample size does not depend much on population size unless the sample is a large share of it. Expect real surveys to need extra invitations to allow for people who do not respond.
Worked Examples
Example 1: Survey sample size for a proportion
Problem: How many people must you survey to estimate a proportion within plus or minus 5% at 95% confidence, with no prior estimate?
Solution: Use z = 1.96, E = 0.05 and p = 0.5. n = 1.96^2 x 0.5 x 0.5 / 0.05^2 = 3.8416 x 0.25 / 0.0025 = 384.16. Round up to the next whole person.
Answer: n = 385
Example 2: Sample size for a mean
Problem: You want to estimate average task time within 2.5 minutes at 95% confidence. Earlier studies suggest a standard deviation of 15 minutes.
Solution: n = (z x sigma / E)^2 = (1.96 x 15 / 2.5)^2 = (11.76)^2 = 138.30. Round up.
Answer: n = 139
Example 3: Margin of error for a given sample
Problem: You already have 400 responses. What margin of error does that give at 95% confidence for a proportion near 50%?
Solution: E = z x sqrt(p(1 - p) / n) = 1.96 x sqrt(0.25 / 400) = 1.96 x 0.025 = 0.049.
Answer: Margin of error = plus or minus 4.9 percentage points
Example 4: A known proportion needs fewer responses
Problem: You expect about 20% of people to say yes and want a margin of 3% at 99% confidence.
Solution: z for 99% is 2.5758. n = 2.5758^2 x 0.2 x 0.8 / 0.03^2 = 6.6347 x 0.16 / 0.0009 = 1179.5, which rounds up to the next whole person.
Answer: n = 1,180
Frequently Asked Questions
How many survey responses do I need?
Why use 0.5 when I do not know the proportion?
Does the population size matter?
What is a margin of error?
How do I get the standard deviation before I run the study?
Is this sample size for a hypothesis test?
Related Statistics Calculators
Probability Calculator
Calculate probability of events, complements, unions, and intersections. Free online probability calculator for statistics.
Standard Deviation Calculator
Calculate standard deviation, variance, mean, and more for any dataset. Supports population and sample statistics. Free online tool.
Z-Score Calculator
Calculate z-scores, find values from z-scores, and determine probabilities. Free online z-score calculator with bell curve visualisation.
Binomial Calculator
Calculate binomial probabilities, cumulative distributions, and expected values. Free online binomial distribution calculator with bar chart.
Normal Distribution Calculator
Calculate probabilities for normal distributions. Find areas under the bell curve, percentiles, and inverse values. Free online tool.
Correlation Calculator
Calculate Pearson correlation coefficient, R-squared, and regression line. Free online correlation calculator with scatter plot.