One of the most common questions researchers ask is: "How many participants do I need?" Too few participants and your study won't be able to detect real effects. Too many and you waste time, money, and resources. Getting the sample size right is one of the most important decisions in study design.
This guide walks you through a practical, step-by-step process for determining the right sample size for your study, whether it's a clinical trial, a survey, an A/B test, or an academic experiment.
Ready to calculate? Use our Sample Size & Power Analysis Calculator to compute the exact sample size for your study parameters.
Sample size directly impacts the reliability and validity of your study's conclusions. Here's what can go wrong:
The goal is to find the minimum sample size that gives your study enough statistical power to detect a meaningful effect. This is where power analysis comes in.
Before you can calculate a sample size, you need to clearly define what you're testing. Your research question determines the type of analysis you'll perform, which in turn determines the sample size formula.
"Does a new tutoring program improve math test scores compared to the standard curriculum?" This is a comparison of two independent group means, so you'd use a two-sample t-test for the sample size calculation.
Different statistical tests have different sample size formulas. The table below helps you match your research design to the right test:
| Research Design | Outcome Type | Statistical Test |
|---|---|---|
| 2 independent groups | Continuous (means) | Independent t-test |
| 2 paired/matched groups | Continuous (means) | Paired t-test |
| 3+ independent groups | Continuous (means) | One-way ANOVA |
| 2 independent groups | Proportions | Two-proportion z-test |
| Categorical association | Frequencies | Chi-square test |
| Predictive model | Continuous | Multiple regression |
Every sample size calculation requires three core parameters. Together with the statistical test, these four elements form the "power analysis quartet" — knowing any three lets you solve for the fourth.
The probability of rejecting the null hypothesis when it is actually true (a Type I error).
Common choice: 0.05 (5%). Use 0.01 for more conservative testing or 0.10 for exploratory research.
The probability of correctly detecting an effect when one truly exists. Higher power means a lower chance of a Type II error (missing a real effect).
Common choice: 0.80 (80%). Use 0.90 or 0.95 for critical studies like clinical trials.
The magnitude of the difference or relationship you expect to find. This is often the hardest parameter to specify. You can estimate it from:
| Test | Small | Medium | Large |
|---|---|---|---|
| t-test (Cohen's d) | 0.2 | 0.5 | 0.8 |
| ANOVA (Cohen's f) | 0.10 | 0.25 | 0.40 |
| Chi-square (Cohen's w) | 0.10 | 0.30 | 0.50 |
| Regression (Cohen's ) | 0.02 | 0.15 | 0.35 |
Learn more about effect sizes in our Effect Size tutorial.
With your test type, significance level, power, and effect size determined, you can now calculate the required sample size. There are three ways to do this:
The easiest approach. Our Sample Size Calculator supports t-tests, proportion tests, ANOVA, chi-square, and regression, and generates power curves automatically.
from statsmodels.stats.power import TTestIndPower
analysis = TTestIndPower()
sample_size = analysis.solve_power(
effect_size=0.5, # Cohen's d
alpha=0.05, # Significance level
power=0.8, # Desired power
alternative='two-sided'
)
print(f"Required sample size per group: {int(sample_size) + 1}")
# Output: Required sample size per group: 64library(pwr)
result <- pwr.t.test(
d = 0.5, # Cohen's d
sig.level = 0.05, # Significance level
power = 0.8, # Desired power
type = "two.sample",
alternative = "two.sided"
)
cat("Required sample size per group:", ceiling(result$n))
# Output: Required sample size per group: 64For a two-sample t-test with equal groups:
See our Sample Size Formula tutorial for detailed formulas for all test types with worked examples.
The calculated sample size is the minimum needed under ideal conditions. In practice, you should inflate it to account for real-world issues:
Participants may withdraw, miss follow-ups, or provide unusable data. Adjust with:
For example, if you need 100 participants and expect 20% dropout: 100 / (1 - 0.20) = 125 participants to recruit.
If you need to reduce the sample size, consider:
Scenario: Testing whether a new blood pressure medication reduces systolic BP by at least 5 mmHg more than the standard treatment (SD = 15 mmHg).
Scenario: Testing whether a new checkout flow increases conversion from 3% to 4% (a 1 percentage point lift).
Scenario: Comparing job satisfaction scores between remote and in-office workers, expecting a medium effect (d = 0.5).
The following table shows approximate sample sizes per group for common study designs at 80% power and (two-sided). These are rough estimates; always run a proper power analysis for your specific study.
| Test | Small Effect | Medium Effect | Large Effect |
|---|---|---|---|
| Independent t-test | 394 | 64 | 26 |
| Paired t-test | 199 | 34 | 15 |
| ANOVA (3 groups) | 322 | 53 | 22 |
| Chi-square (df=1) | 785 | 88 | 32 |
Use our Sample Size & Power Analysis Calculator to get exact numbers for your specific parameters, complete with power curves.
These practice problems will help reinforce your understanding of sample size determination. Try to work through each one before revealing the answer.
One of the most common questions researchers ask is: "How many participants do I need?" Too few participants and your study won't be able to detect real effects. Too many and you waste time, money, and resources. Getting the sample size right is one of the most important decisions in study design.
This guide walks you through a practical, step-by-step process for determining the right sample size for your study, whether it's a clinical trial, a survey, an A/B test, or an academic experiment.
Ready to calculate? Use our Sample Size & Power Analysis Calculator to compute the exact sample size for your study parameters.
Sample size directly impacts the reliability and validity of your study's conclusions. Here's what can go wrong:
The goal is to find the minimum sample size that gives your study enough statistical power to detect a meaningful effect. This is where power analysis comes in.
Before you can calculate a sample size, you need to clearly define what you're testing. Your research question determines the type of analysis you'll perform, which in turn determines the sample size formula.
"Does a new tutoring program improve math test scores compared to the standard curriculum?" This is a comparison of two independent group means, so you'd use a two-sample t-test for the sample size calculation.
Different statistical tests have different sample size formulas. The table below helps you match your research design to the right test:
| Research Design | Outcome Type | Statistical Test |
|---|---|---|
| 2 independent groups | Continuous (means) | Independent t-test |
| 2 paired/matched groups | Continuous (means) | Paired t-test |
| 3+ independent groups | Continuous (means) | One-way ANOVA |
| 2 independent groups | Proportions | Two-proportion z-test |
| Categorical association | Frequencies | Chi-square test |
| Predictive model | Continuous | Multiple regression |
Every sample size calculation requires three core parameters. Together with the statistical test, these four elements form the "power analysis quartet" — knowing any three lets you solve for the fourth.
The probability of rejecting the null hypothesis when it is actually true (a Type I error).
Common choice: 0.05 (5%). Use 0.01 for more conservative testing or 0.10 for exploratory research.
The probability of correctly detecting an effect when one truly exists. Higher power means a lower chance of a Type II error (missing a real effect).
Common choice: 0.80 (80%). Use 0.90 or 0.95 for critical studies like clinical trials.
The magnitude of the difference or relationship you expect to find. This is often the hardest parameter to specify. You can estimate it from:
| Test | Small | Medium | Large |
|---|---|---|---|
| t-test (Cohen's d) | 0.2 | 0.5 | 0.8 |
| ANOVA (Cohen's f) | 0.10 | 0.25 | 0.40 |
| Chi-square (Cohen's w) | 0.10 | 0.30 | 0.50 |
| Regression (Cohen's ) | 0.02 | 0.15 | 0.35 |
Learn more about effect sizes in our Effect Size tutorial.
With your test type, significance level, power, and effect size determined, you can now calculate the required sample size. There are three ways to do this:
The easiest approach. Our Sample Size Calculator supports t-tests, proportion tests, ANOVA, chi-square, and regression, and generates power curves automatically.
from statsmodels.stats.power import TTestIndPower
analysis = TTestIndPower()
sample_size = analysis.solve_power(
effect_size=0.5, # Cohen's d
alpha=0.05, # Significance level
power=0.8, # Desired power
alternative='two-sided'
)
print(f"Required sample size per group: {int(sample_size) + 1}")
# Output: Required sample size per group: 64library(pwr)
result <- pwr.t.test(
d = 0.5, # Cohen's d
sig.level = 0.05, # Significance level
power = 0.8, # Desired power
type = "two.sample",
alternative = "two.sided"
)
cat("Required sample size per group:", ceiling(result$n))
# Output: Required sample size per group: 64For a two-sample t-test with equal groups:
See our Sample Size Formula tutorial for detailed formulas for all test types with worked examples.
The calculated sample size is the minimum needed under ideal conditions. In practice, you should inflate it to account for real-world issues:
Participants may withdraw, miss follow-ups, or provide unusable data. Adjust with:
For example, if you need 100 participants and expect 20% dropout: 100 / (1 - 0.20) = 125 participants to recruit.
If you need to reduce the sample size, consider:
Scenario: Testing whether a new blood pressure medication reduces systolic BP by at least 5 mmHg more than the standard treatment (SD = 15 mmHg).
Scenario: Testing whether a new checkout flow increases conversion from 3% to 4% (a 1 percentage point lift).
Scenario: Comparing job satisfaction scores between remote and in-office workers, expecting a medium effect (d = 0.5).
The following table shows approximate sample sizes per group for common study designs at 80% power and (two-sided). These are rough estimates; always run a proper power analysis for your specific study.
| Test | Small Effect | Medium Effect | Large Effect |
|---|---|---|---|
| Independent t-test | 394 | 64 | 26 |
| Paired t-test | 199 | 34 | 15 |
| ANOVA (3 groups) | 322 | 53 | 22 |
| Chi-square (df=1) | 785 | 88 | 32 |
Use our Sample Size & Power Analysis Calculator to get exact numbers for your specific parameters, complete with power curves.
These practice problems will help reinforce your understanding of sample size determination. Try to work through each one before revealing the answer.