Sample Size Calculator

Offline — showing the version cached on .

Show all explainers, focus on one, or collapse them. You can also open or close each section directly.

Results

Subjects needed per group is 8. The requirement before rounding up is 7.849.

Subjects needed per group
The requirement before rounding up
Find
Did this solve your problem?

How to use this calculator

  1. 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.
  2. 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.
  3. Enter Significance level
    Enter 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.
  4. Enter Power you want
    Enter 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.
  5. Enter Standard deviation you expect
    Enter 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.
  6. Enter Difference you want to detect
    Enter 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.
  7. Enter Rate you expect now, as a decimal between zero and one
    Enter 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.
  8. Enter Rate you want to be able to detect, as a decimal between zero and one
    Enter the rate you want to detect, as a decimal between zero and one; accepted values run from 0.000001 to 0.999999 2.
  9. Read The requirement before rounding up

The requirement before rounding up () vs Significance level ()

22.390.70850.00010.9999

The requirement before rounding up () Significance level ()

Normal distribution and rejection region

Normal distribution and rejection region Normal distribution with the rejection region shaded in both tails at α = 0.05 (critical values ±1.96); the alternative curve, shifted by 2.80, shows power 0.8 to the right of the upper critical value and β = 0.2 to its left. 1.96 −1.96 δ = 2.80 α α β power

Shaded α: rejection region under the null hypothesisLight β: the alternative's area that would NOT rejectDark power: the alternative's area that rejects

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
  • ceil = rounded up to the next whole number
Understand each part

These names are shorthand for the exact calculations below, not different formulas.

  1. Significance multiplier (Za)

    The standard normal quantile for your significance level and test direction.

    See the definition of Zanormal_ppf(1 - alpha / 2)
  2. Power multiplier (Zp)

    The standard normal quantile for the requested power.

    See the definition of Zpnormal_ppf(power)
  3. Standard deviation (S)

    Expected spread in the measured quantity.

    See the definition of Ssigma
  4. Detectable difference (D)

    The difference you want the study to detect, in the same units as the standard deviation.

    See the definition of Ddelta
Follow the calculation with your values
  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 logicceil((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))))
  2. The requirement before rounding up: 7.849
    Show arithmetic
    (normal_ppf(1 - 0.05 / 2) + normal_ppf(0.8)) ^ 2 * (1 / 1) ^ 2
    Full branch logic0 == 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
      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 logicceil((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))))
      2. The requirement before rounding up: 7.849
        Show arithmetic
        (normal_ppf(1 - 0.05 / 2) + normal_ppf(0.8)) ^ 2 * (1 / 1) ^ 2
        Full branch logic0 == 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?
      Sample size is the minimum number of subjects a test needs to reach a decision at your chosen error rates. The tables and formulas behind this page assume the normal approximation applies, meaning the standard deviation or rate behaves predictably. That assumption is what makes a simple formula possible. 1
      How do I calculate sample size?
      Pick your comparison, your error rates, and your expected variability or rates, then apply the matching formula above. This page uses a normal-based formula throughout. Some references give a version based on the t-distribution for one-group averages. It helps when your standard deviation only comes from a small earlier sample. 1
      What sample size is too small?
      A sample size based on a rough standard deviation estimate can be too small. In one worked example, an initial estimate of 9 subjects was called low. Redoing the calculation with degrees of freedom from that sample raised the estimate toward 11. 1
      What is a good sample size?
      A good sample size already reflects known refinements to the raw formula. For one-group rate tests, some sources recommend a continuity correction, adding one divided by delta to the formula's result. 2
      What data do I need before I can work out a sample size?
      You need your chosen error rates. You also need either your expected standard deviation and difference, or your two rates. The critical z-values these combine with come from standard tables of the normal distribution. Those same tables are used across significance tests generally. 4
      What should I watch for when calculating a sample size?
      Watch for extra corrections some sources add on top of the raw formula. In one published rate example, adding a continuity correction changed the requirement from about 102 subjects to 112 subjects. 2
      What is statistical power, and how is the power level chosen?
      Power is your chance of correctly detecting a real difference when one truly exists. Sources here don't settle on one typical level; the choice trades against the risk of a false rejection (alpha) and depends on the standard deviation used in the sample-size formula 1. In one worked example, alpha of 0.05 paired with a beta of 0.10 (90 percent power) gives a minimum sample size of about 9 1.
      What is a confidence level?
      The excerpts do not define a separate term called confidence level. They describe a table of area under the standard normal curve. That same curve lies behind the z-values this calculator uses. It shows how to read a probability, such as 0.93699 for a value of 1.53. 4
      How does the sample size change the confidence interval?
      The excerpts here compute a fixed sample size for a chosen difference and chosen error rates. They do not describe confidence intervals for these calculations. They do note that stating your difference in units of the standard deviation simplifies the calculation. 1

      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.

      How we review

      Sources & methodology

      ConstantValueUnitSource
      sample_size_study_calculator_c121
      sample_size_study_calculator_c243

      Sources