Sample Size Calculator
`A sample size calculator helps researchers determine how many people, observations, or measurements are needed for a study. The required sample size depends on the population being studied, the expected result, the confidence level, the margin of error, and the statistical method.
A suitable sample size can help a study produce reliable estimates and detect meaningful differences. A sample that is too small may lead to imprecise results, while collecting more data than necessary can increase research time and costs. This guide explains how to calculate sample size for surveys, cross-sectional studies, proportions, means, correlations, case-control studies, and statistical tests.
You can also use this Pace Calculator.
What Is a Sample Size Calculator?
A sample size calculator is a statistical tool used to estimate the minimum number of participants or observations required to answer a research question.
For example, a researcher may want to estimate the percentage of university students who use a particular learning app. The calculator can determine how many students should be surveyed based on the desired confidence level and margin of error.
A sample size calculator for research may use different methods depending on the study design. Common inputs include:
- Population size: The total number of people or items in the target population.
- Confidence level: The desired confidence level for estimating a population parameter.
- Margin of error: The maximum acceptable difference between the sample estimate and the population value.
- Population proportion: The expected percentage of the population with a particular characteristic.
- Standard deviation: A measure of how much individual observations vary.
- Statistical power: The probability of detecting a real effect when it exists.
- Effect size: The expected magnitude of a difference, relationship, or treatment effect.
- Significance level: The probability of rejecting a true null hypothesis, commonly set at 0.05.
Not every calculation requires all these values. A survey estimating one proportion uses different inputs from a clinical study comparing two groups.
How to Use a Sample Size Calculator Online
A sample size calculator online generally follows these steps:
- Select the type of calculation, such as estimating a proportion, estimating a mean, or comparing groups.
- Enter the population size if it is known and relevant.
- Choose the confidence level or significance level.
- Enter the expected population proportion, standard deviation, or effect size.
- Set the margin of error or desired statistical power.
- Click the calculate button to find the required sample size.
- Round the result up to the next whole number.
For a basic survey, a calculator may only require the confidence level, margin of error, expected proportion, and population size.
For an experiment or analytical study, the calculation may also require statistical power, the expected difference between groups, and the standard deviation.
Sample Size Calculator Formula
The sample size formula depends on the parameter being estimated or the hypothesis being tested.
For estimating a population proportion with a sufficiently large population, the commonly used formula is:
[
n=\frac{Z^2p(1-p)}{e^2}
]
Where:
- (n) = required sample size
- (Z) = z-score for the selected confidence level
- (p) = expected population proportion
- (e) = desired margin of error
This formula is commonly used for surveys and studies that estimate a single proportion.
Sample Size Formula Example
Suppose a researcher wants to estimate the proportion of people who prefer a particular product. The selected values are:
| Parameter | Value |
|---|---|
| Confidence level | 95% |
| Z-score | 1.96 |
| Expected proportion | 0.50 |
| Margin of error | 0.05 |
Substitute the values into the formula:
[
n=\frac{1.96^2(0.50)(1-0.50)}{0.05^2}
]
[
n=\frac{3.8416(0.25)}{0.0025}
]
[
n=384.16
]
The result must be rounded up.
Required sample size = 385 participants.
The researcher should collect responses from at least 385 participants, assuming the sample is selected using an appropriate method and the calculation’s assumptions are met.
Sample Size for a Population Proportion
A sample size calculator for proportion is useful when the goal is to estimate the percentage of a population with a specific characteristic.
Examples include:
- Estimating the percentage of customers satisfied with a service
- Finding the prevalence of a condition in a population
- Measuring the proportion of voters supporting a candidate
- Estimating the percentage of students who use online learning
- Determining the percentage of households with a particular appliance
The formula is:
[
n=\frac{Z^2p(1-p)}{e^2}
]
If the expected proportion is unknown, researchers commonly use (p=0.50). This produces the largest required sample size for a given confidence level and margin of error, making it a conservative choice.
For example, at a 95% confidence level and a 5% margin of error, using (p=0.50) results in a sample size of approximately 385.
If reliable previous research suggests that the expected proportion is 10%, the calculation can use (p=0.10) instead. The resulting sample size will be smaller.
Sample Size for Estimating a Single Proportion
A sample size calculator for estimating a single proportion is commonly used in descriptive research, surveys, and cross-sectional studies.
The basic formula is:
[
n=\frac{Z^2p(1-p)}{d^2}
]
Here, (d) represents the desired absolute precision or margin of error.
Example
A public health researcher wants to estimate the percentage of adults who exercise regularly. The expected proportion is 30%, the confidence level is 95%, and the desired margin of error is 4%.
[
n=\frac{1.96^2(0.30)(0.70)}{0.04^2}
]
[
n=\frac{3.8416(0.21)}{0.0016}
]
[
n=504.21
]
The required sample size is 505 participants.
If the study expects that some participants will not respond, the researcher should increase the recruitment target. For example, with an anticipated 10% nonresponse rate:
[
n_{\text{adjusted}}=\frac{505}{1-0.10}
]
[
n_{\text{adjusted}}\approx562
]
The researcher should aim to recruit approximately 562 participants to obtain 505 completed responses.
Sample Size With Standard Deviation
A sample size calculator with standard deviation is used when the study aims to estimate a population mean, such as average height, blood pressure, test score, or weight.
The formula for estimating a mean is:
[
n=\left(\frac{Z\sigma}{E}\right)^2
]
Where:
- (n) = required sample size
- (Z) = z-score for the confidence level
- (\sigma) = estimated population standard deviation
- (E) = desired margin of error for the mean
Example
A researcher wants to estimate the average daily screen time of students. Previous research suggests a standard deviation of 2 hours. The desired margin of error is 0.5 hours, with a 95% confidence level.
[
n=\left(\frac{1.96(2)}{0.5}\right)^2
]
[
n=(7.84)^2
]
[
n=61.47
]
The sample size should be rounded up to 62 students.
This method assumes that the standard deviation is known or can be reasonably estimated from previous research or a pilot study. For small samples, a t-based confidence interval may be more appropriate.
Sample Size for Mean and Standard Deviation
When the objective is to estimate a population mean, both the expected standard deviation and the desired precision are important.
The formula is:
[
n=\frac{Z^2\sigma^2}{E^2}
]
A larger standard deviation means that observations vary more widely. As a result, more participants are usually needed to estimate the mean with the same level of precision.
The required sample size also increases when:
- The confidence level increases
- The desired margin of error becomes smaller
- The population is more variable
For example, reducing the margin of error from 5 units to 2.5 units approximately quadruples the sample size, because the margin of error is squared in the denominator.
Sample Size for a Finite Population
When the total population is known and relatively small, a finite population correction can reduce the required sample size.
First, calculate the sample size for an effectively unlimited population:
[
n_0=\frac{Z^2p(1-p)}{e^2}
]
Then apply the finite population correction:
[
n=\frac{n_0}{1+\frac{n_0-1}{N}}
]
Where:
- (n_0) = initial sample size
- (n) = adjusted sample size
- (N) = total population size
Example
Suppose a company has 1,200 employees. A researcher wants to estimate the proportion who use public transportation, using a 95% confidence level, a 5% margin of error, and an expected proportion of 50%.
The initial sample size is approximately 385.
[
n=\frac{385}{1+\frac{385-1}{1200}}
]
[
n\approx293
]
The adjusted sample size is approximately 293 employees.
The finite population correction is appropriate when sampling without replacement from a known, finite population. It should not be used automatically for every study.
Sample Size for Two Proportions
A sample size calculator for two proportions is used when researchers compare the percentage of an outcome between two groups.
Examples include:
- Comparing customer satisfaction between two services
- Comparing recovery rates between two treatments
- Comparing the percentage of smokers in two populations
- Comparing conversion rates between two marketing campaigns
For two independent groups with equal sample sizes, a commonly used approximate formula is:
[
n=
\frac{
\left[
Z_{1-\alpha/2}\sqrt{2\bar{p}(1-\bar{p})}
+
Z_{1-\beta}\sqrt{p_1(1-p_1)+p_2(1-p_2)}
\right]^2
}{
(p_1-p_2)^2
}
]
Where:
- (n) = sample size required in each group
- (p_1) = expected proportion in group 1
- (p_2) = expected proportion in group 2
- (\bar{p}=(p_1+p_2)/2)
- (\alpha) = significance level
- (1-\beta) = statistical power
This formula assumes independent groups and is an approximation. Exact methods or specialized software may be preferred for small samples or uncommon outcomes.
The required sample size increases when the difference between the two expected proportions becomes smaller.
Sample Size for Two Means
A sample size calculator for two means is used to compare the average value of a continuous variable between two independent groups.
Examples include comparing:
- Average blood pressure between two treatment groups
- Average exam scores between two teaching methods
- Mean production output between two machines
- Average weight between two diets
For two independent groups with equal sample sizes and a common standard deviation, an approximate formula is:
[
n=
\frac{2\sigma^2(Z_{1-\alpha/2}+Z_{1-\beta})^2}{\Delta^2}
]
Where:
- (n) = sample size per group
- (\sigma) = common standard deviation
- (\Delta) = expected difference between the group means
- (\alpha) = significance level
- (1-\beta) = statistical power
Example
Suppose a study compares two teaching methods. The expected difference in average scores is 5 points, the common standard deviation is 10 points, the significance level is 5%, and the desired power is 80%.
Using (Z_{1-\alpha/2}=1.96) and (Z_{1-\beta}=0.84):
[
n=
\frac{2(10^2)(1.96+0.84)^2}{5^2}
]
[
n\approx62.72
]
The researcher should recruit approximately 63 participants per group, or 126 participants in total.
This is an approximate calculation. A more precise method may use a t-distribution, especially when the sample size is small.
Power Sample Size Calculator
A power sample size calculator is used in analytical research to determine how many participants are needed to detect a specified effect. Statistical power is the probability that a study will detect a real effect when that effect exists.
The commonly used power levels are:
| Statistical Power | Meaning |
|---|---|
| 80% | Commonly selected power for research |
| 90% | Higher chance of detecting the expected effect |
| 95% | Very high desired detection probability |
Power calculations generally require:
- Significance level, usually 0.05
- Desired statistical power
- Expected effect size
- Statistical test
- Number of groups
- Whether the groups are independent or paired
Higher power usually requires a larger sample. A smaller expected effect also requires more participants because the difference is harder to detect.
For studies involving t-tests, ANOVA, regression, or complex experimental designs, researchers may use statistical software such as G*Power.
Sample Size Calculator for T-Test
A sample size calculator for t-test determines the number of observations needed to compare means using a t-test.
The required sample size depends on the type of t-test.
Independent Samples T-Test
An independent samples t-test compares the means of two separate groups.
For equal group sizes, an approximate formula is:
[
n=
\frac{2\sigma^2(Z_{1-\alpha/2}+Z_{1-\beta})^2}{\Delta^2}
]
This formula provides an initial estimate. A t-distribution-based calculation is generally more suitable when the sample size is small or the population standard deviation is unknown.
Paired Samples T-Test
A paired t-test compares two measurements from the same participants or matched pairs. For example, a researcher may measure participants’ blood pressure before and after an intervention.
The sample size depends on the standard deviation of the within-pair differences:
[
n=
\left(
\frac{(Z_{1-\alpha/2}+Z_{1-\beta})\sigma_d}{\Delta}
\right)^2
]
Where:
- (\sigma_d) = standard deviation of the paired differences
- (\Delta) = expected mean difference
The required number of participants is based on the number of pairs, not the total number of individual measurements.
Sample Size Calculator for Correlation Study
A sample size calculator for correlation study helps estimate how many participants are needed to detect a relationship between two variables. For example, a researcher may investigate the correlation between:
- Study hours and exam scores
- Body mass index and blood pressure
- Age and a health measurement
- Advertising expenditure and sales
A common approximate formula uses Fisher’s z transformation:
[
n\approx3+
\left(
\frac{Z_{1-\alpha/2}+Z_{1-\beta}}{\operatorname{atanh}(r)}
\right)^2
]
Where:
- (n) = required sample size
- (r) = expected correlation coefficient
- (\alpha) = significance level
- (1-\beta) = statistical power
- (\operatorname{atanh}(r)) = inverse hyperbolic tangent of the expected correlation
This approximation assumes independent observations and is generally used for planning a test of correlation against zero.
A weak expected correlation usually requires a much larger sample than a strong correlation. The calculation should also reflect the planned correlation method, such as Pearson or Spearman correlation, and its assumptions.
Sample Size Calculator for Case-Control Study
A sample size calculator for case-control study is used to estimate the number of cases and controls required to investigate an association between an exposure and an outcome. For example, researchers may compare the history of a particular exposure among people with a disease and people without it.
Important inputs include:
- Expected exposure prevalence among controls
- Expected odds ratio
- Significance level
- Desired statistical power
- Ratio of controls to cases
- Whether the study uses matched or unmatched participants
An unmatched case-control study commonly uses a two-proportion calculation, where the proportions represent expected exposure prevalence among cases and controls. The sample size depends on the expected odds ratio and the control exposure prevalence. If the expected association is weak, a larger study is generally required. A matched case-control study needs a calculation that accounts for the matching design. Using a simple independent-groups formula may produce an inappropriate estimate.
Sample Size Calculator for Cross-Sectional Study
A sample size calculator for cross sectional study is often used to estimate the prevalence of a characteristic or condition in a population at a particular point in time.
For a cross-sectional study estimating one proportion, the basic formula is:
[
n=\frac{Z^2p(1-p)}{d^2}
]
Where:
- (Z) = z-score for the confidence level
- (p) = expected prevalence
- (d) = desired absolute precision
Example
A researcher wants to estimate the prevalence of a condition in a community. Previous research suggests a prevalence of 20%. The confidence level is 95%, and the desired precision is 5%.
[
n=\frac{1.96^2(0.20)(0.80)}{0.05^2}
]
[
n\approx246
]
The required sample size is 246 participants before accounting for nonresponse, clustering, or other design considerations.
For a complex cross-sectional survey, the sample size may need to be increased using a design effect. A simple formula is not always sufficient for surveys with cluster sampling or unequal selection probabilities.
Sample Size Determination in Research
Sample size determination is an important part of research planning. It should be completed before data collection whenever possible.
The process generally includes the following steps:
- Define the research objective. Determine whether the study estimates a proportion, estimates a mean, compares groups, or tests a relationship.
- Choose the study design. Identify whether it is a survey, cross-sectional study, case-control study, experiment, or another design.
- Select the statistical method. Choose the test or estimation procedure that matches the research question.
- Set the confidence level or significance level. A 95% confidence level or 5% significance level is commonly used.
- Choose the expected effect or parameter. Use previous studies, pilot data, or a reasonable assumption.
- Set the precision or statistical power. Decide how narrow the confidence interval should be or how likely the study should be to detect an effect.
- Calculate the sample size. Use the appropriate formula or statistical software.
- Adjust for practical limitations. Consider nonresponse, dropouts, clustering, and unequal group sizes.
A sample size should not be selected only because it is convenient. It should be justified by the research objective and statistical assumptions.
Raosoft Sample Size Calculator
The Raosoft sample size calculator is commonly associated with survey sample size determination. Its calculation typically considers population size, confidence level, margin of error, and response distribution.
For a survey estimating a population proportion, a 50% response distribution is often used when the true proportion is unknown. This produces a conservative estimate for the required sample size under the standard proportion formula.
When using Raosoft or another online tool, make sure the selected method matches the study. A survey calculator may not be suitable for comparing treatment groups or calculating statistical power for a t-test.
OpenEpi Sample Size Calculator
OpenEpi is a statistical tool used in epidemiology and public health research. It includes methods for several study designs and statistical calculations.
Researchers may use OpenEpi for calculations involving:
- Cross-sectional studies
- Cohort studies
- Case-control studies
- Comparing proportions
- Estimating population parameters
The appropriate calculation depends on the study design and the information available. Researchers should confirm that the selected method matches their protocol and assumptions.
G*Power Sample Size Calculator
G*Power is statistical software used to calculate statistical power and sample size for a range of tests.
It can be useful when a study involves:
- t-tests
- Correlation tests
- ANOVA
- Regression
- Other statistical procedures supported by the software
G*Power calculations typically require the researcher to specify the test, effect size, significance level, and desired power.
Unlike a basic survey sample size calculator, G*Power is designed for a range of hypothesis-testing situations. The output should be interpreted according to the selected statistical test and study design.
Factors That Affect Sample Size
Several factors can change the required number of participants.
| Factor | Effect on Sample Size |
|---|---|
| Confidence level | A higher confidence level generally requires a larger sample |
| Margin of error | A smaller margin of error requires a larger sample |
| Expected proportion | For proportion estimation, values near 50% usually require the largest sample |
| Standard deviation | Greater variability increases the sample size needed to estimate a mean |
| Statistical power | Higher power generally requires more participants |
| Effect size | Smaller expected effects require larger samples |
| Population size | A finite population correction can reduce the required sample |
| Nonresponse | The recruitment target should increase if some participants are expected not to respond |
| Study design | Clustering, matching, and repeated measurements can change the calculation |
Confidence Level and Z-Score
The confidence level determines the z-score used in many sample size formulas.
Common values include:
| Confidence Level | Z-Score |
|---|---|
| 70% | 1.036 |
| 75% | 1.150 |
| 80% | 1.282 |
| 85% | 1.440 |
| 90% | 1.645 |
| 95% | 1.960 |
| 98% | 2.326 |
| 99% | 2.576 |
| 99.9% | 3.291 |
For a two-sided confidence interval, the z-score corresponds to the selected confidence level. For example, a 95% confidence interval uses approximately 1.96.
A higher confidence level increases the range of values considered plausible, so a larger sample is generally needed to maintain the same margin of error.
Margin of Error and Sample Size
The margin of error represents the expected precision of an estimate.
For example, if a survey estimates that 40% of respondents prefer a product with a margin of error of 5 percentage points, the confidence interval may be approximately 35% to 45%, depending on the method used.
A smaller margin of error requires more observations.
For estimating a proportion:
[
n=\frac{Z^2p(1-p)}{e^2}
]
Because the margin of error is squared in the denominator, reducing it by half increases the required sample size by approximately four times, all else being equal.
Sample Size vs. Population Size
Sample size and population size are related, but they are not the same.
Population size is the total number of people or items that the research concerns.
Sample size is the number of people or items actually included in the study.
For a large population, the sample size needed to estimate a proportion with a specified confidence level and margin of error may be similar even when the population grows substantially.
For a small, finite population, the required sample can be reduced using a finite population correction.
For example, a sample of 385 may be suitable for a large population under common survey assumptions. If the population contains only 1,200 people, the finite population correction may reduce the required sample to approximately 293.
Frequently Asked Questions
What is the formula for sample size?
For estimating a population proportion in a large population, the common formula is:
[
n=\frac{Z^2p(1-p)}{e^2}
]
The formula changes depending on whether the study estimates a mean, compares groups, or tests a relationship.
What sample size is needed for a 95% confidence level and 5% margin of error?
For estimating a proportion with an assumed population proportion of 50% and a very large population, the required sample size is approximately 385.
This result may change when the population is finite or the expected proportion differs from 50%.
Why is 50% used for population proportion?
When the expected proportion is unknown, 50% is commonly used because it produces the largest sample size for a given confidence level and margin of error. It is a conservative assumption for estimating a single proportion.
How do I calculate sample size with standard deviation?
For estimating a population mean, a common formula is:
[
n=\left(\frac{Z\sigma}{E}\right)^2
]
Use the estimated standard deviation, the selected confidence level, and the desired margin of error.
How do I calculate sample size for a t-test?
A t-test sample size calculation depends on the expected difference between the means, standard deviation, significance level, statistical power, and whether the test uses independent or paired observations.
A statistical power tool can provide a more accurate result for the selected test.
What is the difference between sample size and statistical power?
Sample size is the number of observations in a study. Statistical power is the probability of detecting a real effect when it exists, assuming the specified effect and statistical model.
A larger sample generally increases power, but power also depends on effect size, variability, and significance level.
Can I use a sample size calculator for every research study?
No. Different research designs require different calculations. A basic survey calculator may be suitable for estimating one proportion, but an experiment, case-control study, correlation study, or t-test may need a specialized method.
Should I round the calculated sample size up or down?
Round the required sample size up to the next whole number. Rounding down could leave the study with fewer participants than the calculation requires.
Should I increase the sample size for nonresponse?
Yes, if some participants are expected not to complete the study. For example, if 500 completed responses are required and the expected response rate is 80%, the recruitment target is:
[
n=\frac{500}{0.80}=625
]
The researcher should aim to recruit 625 participants to obtain approximately 500 completed responses.
Is a larger sample size always better?
A larger sample can improve precision and statistical power, but it does not automatically make a study reliable. Sampling bias, measurement errors, poor study design, and inappropriate statistical methods can still affect the results.
The goal is to select a sample size that is statistically justified and suitable for the research objective.
Conclusion
A sample size calculator helps researchers plan the number of participants or observations needed for a study. The correct calculation depends on the research question, study design, confidence level, margin of error, expected proportion or standard deviation, and statistical power. For a simple survey estimating a proportion, the standard formula may be sufficient. For comparing means, proportions, correlations, or case-control groups, a study-specific calculation is more appropriate. Choose the calculation that matches your research design, use reasonable assumptions, and round the final sample size up before beginning data collection.