Sample Size Calculator
Updated How we review
Offline — showing the version cached on .
Unresolved errors (0)
Results
Subjects needed per group is 8. The requirement before rounding up is 7.849.
- Subjects needed per group
- The requirement before rounding up
Your recent calculations
Stored only on this device.
| Solved for | What are you comparing? | Which direction matters? | Significance level | Power you want | Standard deviation you expect | Difference you want to detect | Rate you expect now, as a decimal between zero and one | Rate you want to be able to detect, as a decimal between zero and one | Subjects needed per group | The requirement before rounding up |
|---|
* computed under superseded data
How to use this calculator
- Choose What are you comparing?Choose whether you have one group to check against a fixed target, or two groups to compare with each other, and whether you are measuring an average or a rate.
- Choose Which direction matters?Choose one-sided only if you care about a difference in a single specific direction; choose two-sided if a difference either way would matter to you.
- Enter Significance levelEnter your significance level as a decimal, such as 0.05 for a 5 percent risk of rejecting a true hypothesis. This page accepts values from 0.0001 to 0.9999, its own limit.
- Enter Power you wantEnter the power you want as a decimal, such as 0.9 for a 90 percent chance of detecting a real difference. This page accepts values from 0.5 to 0.9999, its own limit.
- Enter Standard deviation you expectEnter the standard deviation you expect for what you are measuring, in the same units as your difference. This page accepts values from 0.000001 to 100000, its own limit.
- Enter Difference you want to detectEnter the difference or shift you want to detect, in the same units as your standard deviation; accepted values run from 0.000001 to 100000 1.
- Enter Rate you expect now, as a decimal between zero and oneEnter the rate you expect now, as a decimal between zero and one, such as 0.1 for 10 percent. This page accepts values from 0.000001 to 0.999999, its own limit.
- Enter Rate you want to be able to detect, as a decimal between zero and oneEnter the rate you want to detect, as a decimal between zero and one; accepted values run from 0.000001 to 0.999999 2.
- Read The requirement before rounding up
The requirement before rounding up () vs Significance level ()
The requirement before rounding up () Significance level ()
Normal distribution and rejection region
Shaded α: rejection region under the null hypothesisLight β: the alternative's area that would NOT rejectDark power: the alternative's area that rejectsMarked: your test statistic
The left curve is the sampling distribution of the test statistic if there is no real difference (the null hypothesis); the right curve is the same distribution if the difference you entered is real. The shaded tail under the left curve is the rejection region — its area is your significance level alpha, split across both tails for a two-sided test. Under the right curve, the area beyond the critical value is the power you asked for (1−β), the chance the study detects a real difference, and the area before it is β, the chance it misses one. The sample size shown is rounded up, so the study reaches at least this power.
What this calculates
Deciding how many subjects a study needs is not a single fixed calculation. The right number depends on choices only you can make, plus what you already know about your data. There is no correct answer without additional information or assumptions. 1
This calculator covers four comparisons: one group against a fixed average or rate, or two groups compared with each other. The method for testing a rate is similar to the method for testing an average. Proportions strictly follow a binomial distribution, but both methods use the normal approximation. 2
Choosing what you're comparing
Start by asking whether you have one group to check against a known target. Or ask whether you have two groups to compare with each other. Either way, you are deciding how large a difference or shift you want to be able to detect. 1
Next ask whether you are measuring an average, like a weight or a score. Or ask whether you are measuring a rate, like a proportion defective. For a rate, picture the change in the proportion defective that you are interested in detecting. 2
Error rates, power, and one-sided vs two-sided tests
Alpha, power, and how much your data vary all shape the sample size here. Alpha is the risk of rejecting a true hypothesis. The gap below your chosen power is a risk too: accepting a false null hypothesis when an alternative is true. 1
Whether alpha applies fully or is split in half depends on test direction. The value of alpha prime is alpha for a one-sided test and alpha divided by two for a two-sided test. 3
One group, against a target average
When you compare one group's average against a known target, the formula uses critical values from the normal distribution. A two-sided test combines z at 1 minus alpha over 2 with z at 1 minus beta. A one-sided test uses z at 1 minus alpha instead. The sum of the two critical values is then squared and multiplied by sigma over delta, squared. 1
Take alpha of 0.05, power of 0.9, a one-sided test, a standard deviation of 1, and a difference of 1. The requirement is 9 subjects, or 8.563847350667967 before rounding up. 1
One group, against a target rate
When you compare one group's rate against a known target, the formula again relies on the normal approximation. It squares a ratio comparing the two rates. The top adds each rate's own spread, weighted by its critical z value. The bottom is the difference between the two rates, p1 minus p0. 2
Take alpha 0.05, power 0.9, one-sided, a current rate of 0.1, and a target rate of 0.2. The requirement is 102 subjects, or 101.21903550632865 before rounding up. This matches a published example using the same one-sided alpha, beta, and rates. 2
Two groups, comparing their averages
Comparing the averages of two separate groups needs a formula close to double the one-group version. Take twice sigma squared, times the squared sum of two z values, divided by delta squared. Add a quarter of the alpha-based z value squared, and your study was probably large enough. 3
Take alpha 0.05, power 0.8, one-sided, a pooled standard deviation of 1.4676, and a difference of 2.5. The requirement is 5 subjects, or 4.94 before rounding up. This matches a published example comparing two areas. Seven samples came from one area and eight from the other, with equal variances. 3
Two groups, comparing their rates
Comparing rates between two groups uses a similar doubled formula, built around the average of the two rates. Take twice the squared sum of two z values, times that average rate times one minus the average rate. Divide by the squared difference between the two rates. 3
Take alpha 0.1, power 0.95, one-sided, with rates of 0.0775 and 0.1775. The requirement is 191 subjects, or 190.53489874317398 before rounding up. This matches a published example at a hazardous waste site, comparing a possibly contaminated area with a reference area. 3
Reading sample_size and sample_size_exact
The exact figure is the raw formula result, before rounding. The rounded figure adds enough to cover a fractional subject, since you cannot enroll part of a person. When you're testing a mean, both figures assume your standard deviation is known. If you only have an estimate from an earlier experiment, treat the result as a starting point. 1
Why this calculator limits your inputs
The formulas here rely on the normal approximation, which needs enough events to behave well. A common check multiplies each rate by its sample size, and one minus the rate by that same size. Both products should be at least 5, or an exact test is safer. This page restricts its numeric inputs to a chosen range and refuses to answer outside it. That range is this page's own choice, not a property of the formulas. 3
What Your Random Sample Actually Gives You
When you take a random sample, you don't get the population's true standard deviation. You get an estimate computed from that sample. If you don't have an exact value, the best you can do is use an estimate from a previous experiment and treat it as a starting point. 1
Because that estimate comes from a sample, not the whole population, the math changes. You move from the normal distribution to the t distribution, and you iterate: compute a sample size, then recompute using the degrees of freedom that size implies. 1
You can also compute statistics directly from two random samples you've already collected. In one worked example, 7 samples from one area and 8 from another were used to compute a pooled standard deviation of about 1.4676, which then fed into the sample size formula. 3
What This Calculator Doesn't Tell You
What the sources behind this calculator do say is narrower. There is no correct answer without additional information or assumptions: you supply your own risk levels and your own estimate of variability, and a sample size follows from those. Anything beyond that isn't covered here. 1
If You're Sampling From a Fixed Population
You might be drawing your sample from a small, fixed population — a finite list of records, batches, or customers — rather than an endless stream. The formulas behind this calculator's sample size results come from the standard derivations for testing a mean or a proportion: critical values from the normal or t distribution combined with a standard deviation (or proportion) and the difference you want to detect. The sources behind this calculator don't mention correcting for population size. 1
Key facts
- One group against a target average, two-sided, alpha 0.01, power 0.9, standard deviation 1, difference 1: 15 subjects per group. 1 1
- One group against a target rate, two-sided, alpha 0.05, power 0.9, rates 0.1 and 0.2: 122 subjects per group. 2 2
- Two groups compared on their averages, two-sided, alpha 0.05, power 0.9, standard deviation 1, difference 1: 22 subjects per group. 3 3
- Detecting a rate increase from 0.10 to 0.20 with a two-sided test at a 5 percent significance level and 90 percent power takes 268 subjects per group 3. 3
How this is calculated
Use the formula for your selected comparison to estimate the subjects needed. Significance level, power and the difference you want to detect determine the result. Round up to a whole subject.
Subjects needed per group
ceil((Za + Zp) ^ 2 × (S ÷ D) ^ 2)- Za = Significance multiplier
- Zp = Power multiplier
- S = Standard deviation
- D = Detectable difference
- test_type = What are you comparing?: 0 = One group, against a target average, 1 = One group, against a target rate, 2 = Two groups, comparing their averages, 3 = Two groups, comparing their rates
- tail = Which direction matters?: 0 = A difference in either direction (two-sided), 1 = A difference in one direction only (one-sided)
- alpha = Significance level ()
- power = Power you want ()
- sigma = Standard deviation you expect ()
- delta = Difference you want to detect ()
- p0 = Rate you expect now, as a decimal between zero and one ()
- p1 = Rate you want to be able to detect, as a decimal between zero and one ()
- sample_size = Subjects needed per group
- sample_size_exact = The requirement before rounding up
- ceil = rounded up to the next whole number
- normal_ppf = the standard normal value with this probability at or below it
Understand each part
These names are shorthand for the exact calculations below, not different formulas.
- Significance multiplier (Za)
The standard normal quantile for your significance level and test direction.
See the definition of Za
normal_ppf(1 - alpha / 2) - Power multiplier (Zp)
The standard normal quantile for the requested power.
See the definition of Zp
normal_ppf(power) - Standard deviation (S)
Expected spread in the measured quantity.
See the definition of S
sigma - Detectable difference (D)
The difference you want the study to detect, in the same units as the standard deviation.
See the definition of D
delta
Follow the calculation with your values
- Subjects needed per group: 8
Show arithmetic
ceil((normal_ppf(1 - 0.05 / 2) + normal_ppf(0.8)) ^ 2 * (1 / 1) ^ 2)Full branch logic
ceil((0 == 0 ? (normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) + normal_ppf(0.8)) ^ 2 * (1 / 1) ^ 2 : (0 == 1 ? ((normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) * (0.1 * (1 - 0.1)) ^ 0.5 + normal_ppf(0.8) * (0.2 * (1 - 0.2)) ^ 0.5) / (0.2 - 0.1)) ^ 2 : (0 == 2 ? 2 * 1 ^ 2 * (normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) + normal_ppf(0.8)) ^ 2 / 1 ^ 2 + normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) ^ 2 / 4 : 2 * (normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) + normal_ppf(0.8)) ^ 2 * (0.1 + 0.2) / 2 * (1 - (0.1 + 0.2) / 2) / (0.2 - 0.1) ^ 2)))) - The requirement before rounding up: 7.849
Show arithmetic
(normal_ppf(1 - 0.05 / 2) + normal_ppf(0.8)) ^ 2 * (1 / 1) ^ 2Full branch logic
0 == 0 ? (normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) + normal_ppf(0.8)) ^ 2 * (1 / 1) ^ 2 : (0 == 1 ? ((normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) * (0.1 * (1 - 0.1)) ^ 0.5 + normal_ppf(0.8) * (0.2 * (1 - 0.2)) ^ 0.5) / (0.2 - 0.1)) ^ 2 : (0 == 2 ? 2 * 1 ^ 2 * (normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) + normal_ppf(0.8)) ^ 2 / 1 ^ 2 + normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) ^ 2 / 4 : 2 * (normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) + normal_ppf(0.8)) ^ 2 * (0.1 + 0.2) / 2 * (1 - (0.1 + 0.2) / 2) / (0.2 - 0.1) ^ 2))
Full formulas, symbols and sources
sample_size = ceil((normal_ppf(1 - alpha / 2) + normal_ppf(power)) ^ 2 * (sigma / delta) ^ 2)
One group, against a target average
sample_size = ceil((normal_ppf(1 - alpha / 2) + normal_ppf(power)) ^ 2 * (sigma / delta) ^ 2)
One group, against a target rate
sample_size = ceil(((normal_ppf(1 - alpha / 2) * (p0 * (1 - p0)) ^ 0.5 + normal_ppf(power) * (p1 * (1 - p1)) ^ 0.5) / (p1 - p0)) ^ 2)
Two groups, comparing their averages
sample_size = ceil(2 * sigma ^ 2 * (normal_ppf(1 - alpha / 2) + normal_ppf(power)) ^ 2 / delta ^ 2 + normal_ppf(1 - alpha / 2) ^ 2 / 4)
Two groups, comparing their rates
sample_size = ceil(2 * (normal_ppf(1 - alpha / 2) + normal_ppf(power)) ^ 2 * (p0 + p1) / 2 * (1 - (p0 + p1) / 2) / (p1 - p0) ^ 2)
The requirement before rounding up
sample_size_exact = (normal_ppf(1 - alpha / 2) + normal_ppf(power)) ^ 2 * (sigma / delta) ^ 2
- test_type
- What are you comparing?: 0 = One group, against a target average, 1 = One group, against a target rate, 2 = Two groups, comparing their averages, 3 = Two groups, comparing their rates
- tail
- Which direction matters?: 0 = A difference in either direction (two-sided), 1 = A difference in one direction only (one-sided)
- alpha
- Significance level ()
- power
- Power you want ()
- sigma
- Standard deviation you expect ()
- delta
- Difference you want to detect ()
- p0
- Rate you expect now, as a decimal between zero and one ()
- p1
- Rate you want to be able to detect, as a decimal between zero and one ()
- sample_size
- Subjects needed per group
- sample_size_exact
- The requirement before rounding up
- ceil
- rounded up to the next whole number
- normal_ppf
- the standard normal value with this probability at or below it
Worked examples
Example using the starting values: Subjects needed per group 8
See inputs and calculation
Starting values
- What are you comparing?
- One group, against a target average
- Which direction matters?
- A difference in either direction (two-sided)
- Significance level
- 0.05
- Power you want
- 0.8
- Standard deviation you expect
- 1
- Difference you want to detect
- 1
- Subjects needed per group: 8
Show arithmetic
ceil((normal_ppf(1 - 0.05 / 2) + normal_ppf(0.8)) ^ 2 * (1 / 1) ^ 2)Full branch logic
ceil((0 == 0 ? (normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) + normal_ppf(0.8)) ^ 2 * (1 / 1) ^ 2 : (0 == 1 ? ((normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) * (0.1 * (1 - 0.1)) ^ 0.5 + normal_ppf(0.8) * (0.2 * (1 - 0.2)) ^ 0.5) / (0.2 - 0.1)) ^ 2 : (0 == 2 ? 2 * 1 ^ 2 * (normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) + normal_ppf(0.8)) ^ 2 / 1 ^ 2 + normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) ^ 2 / 4 : 2 * (normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) + normal_ppf(0.8)) ^ 2 * (0.1 + 0.2) / 2 * (1 - (0.1 + 0.2) / 2) / (0.2 - 0.1) ^ 2)))) - The requirement before rounding up: 7.849
Show arithmetic
(normal_ppf(1 - 0.05 / 2) + normal_ppf(0.8)) ^ 2 * (1 / 1) ^ 2Full branch logic
0 == 0 ? (normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) + normal_ppf(0.8)) ^ 2 * (1 / 1) ^ 2 : (0 == 1 ? ((normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) * (0.1 * (1 - 0.1)) ^ 0.5 + normal_ppf(0.8) * (0.2 * (1 - 0.2)) ^ 0.5) / (0.2 - 0.1)) ^ 2 : (0 == 2 ? 2 * 1 ^ 2 * (normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) + normal_ppf(0.8)) ^ 2 / 1 ^ 2 + normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) ^ 2 / 4 : 2 * (normal_ppf(1 - (0 == 1 ? 0.05 : 0.05 / 2)) + normal_ppf(0.8)) ^ 2 * (0.1 + 0.2) / 2 * (1 - (0.1 + 0.2) / 2) / (0.2 - 0.1) ^ 2))
Frequently asked questions
What is sample size?
How do I calculate sample size?
What sample size is too small?
What is a good sample size?
What data do I need before I can work out a sample size?
What should I watch for when calculating a sample size?
What is statistical power, and how is the power level chosen?
What is a confidence level?
How does the sample size change the confidence interval?
Limitations & common mistakes
- This calculator only reports what your own numbers imply; it cannot tell you whether those numbers are realistic for your situation.
- The results are computed only from the numbers you enter, and are only as exact as those numbers; they are not a substitute for a measurement taken on site or for a professional's judgement where one is required.
- The one-group formulas assume the standard deviation is known; if it is only an estimate from an earlier sample, the true requirement may differ.
- The rate formulas rely on the normal approximation, which works best when the rate times the sample size, and one minus the rate times the sample size, are not too small.
- Outside the ranges this page accepts for each input, it will not compute a result at all, by this page's own choice.
Formula, sources, and review
This calculation follows the formula published on this page and rests on 4 cited sources, listed under Sources below. Checked by the Editorial Team on . No reviewer with a statistics credential has signed this page.
Sources & methodology
Sources
- 1 NIST/SEMATECH e-Handbook of Statistical Methods, 7.2.2.2. Sample sizes required — last verified
- 2 NIST/SEMATECH e-Handbook of Statistical Methods, 7.2.4.2. Sample sizes required — last verified
- 3 EPA QA/G-9S, Data Quality Assessment: Statistical Methods for Practitioners, Boxes 3-20 to 3-28 — last verified
- 4 NIST/SEMATECH e-Handbook of Statistical Methods, 1.3.6.7.1. Cumulative Distribution Function of the Standard Normal Distribution — last verified