Sample Size Calculator

Single mean

Determines the sample size required to test whether a population mean differs from a specified hypothesized or reference mean, given a chosen significance level and statistical power.

Key takeaways

  • What is calculated: Find the smallest integer n at which the exact power of the one-sample t-test reaches the target.
  • Quantities you must supply: Reference mean; Anticipated mean; Standard deviation; Significance level; Power.
  • Type of calculation: Power-based: it answers how much data is needed to detect a stated effect. Power 0.80 at α = 0.05 is the usual target; confirmatory studies use 0.90.
  • Calculation routes: 2 are available for this design; the one selected determines the formula, the quantities requested and the result.

Methods available for Single mean

  • Normal approximation (z-based) Closed-form sample size treating the population standard deviation as known. Chosen for transparency and comparability: the formula is the one tabulated in most textbooks, so a reviewer recomputing the figure will reproduce it exactly.
  • Noncentral t (exact, one-sample t-test) Iterative solution using the exact distribution of the one-sample t statistic under the alternative. Chosen because it accounts for the additional uncertainty from estimating σ, which the normal approximation ignores. This is not merely a small-sample correction: the normal formula approximates this calculation at every n.

When to use

Use when the primary objective is to determine whether a population mean differs from a specified reference or hypothesized value with adequate statistical power.

Sample size

Type I error rate.

Probability of detecting the specified effect.

A two-sided alternative splits α between both tails; a one-sided alternative places all of α in one tail, needs a smaller n, and must be pre-specified.

Final n is inflated by 1/(1 − dropout).

Reset to defaults

Awaiting inputs

Set the parameters and calculate.

Methodology — One-sample mean — noncentral t (exact)

Formula used One-sample mean — noncentral t (exact)

1β=Pr(|tn1,λ|>t1α/2,n1)
Exact power under the noncentral t; the requirement is the smallest n reaching the target
λ=δnσ
Noncentrality parameter
δ=|μ1μ0|
Minimum detectable difference
  • z1α/2(two-sided)in place ofz1α(one-sided) Two-sided alternative selected: α is split between both tails, so the larger quantile is used and the requirement rises

where —

μ₀
Hypothesised reference mean under H₀. Any value on the outcome scale
μ₁
Anticipated mean under the alternative. Must differ from μ₀
σ
Population standard deviation of the outcome. σ > 0
α
Probability of rejecting a true null hypothesis (Type I error). 0.0001 – 0.5; conventionally 0.05, or 0.025 one-sided for regulatory non-inferiority
1 − β
Probability of rejecting the null hypothesis when the specified alternative is true. 0.50 – 0.9999; conventionally 0.80 or 0.90
Expected proportion of enrolled units lost before analysis. 0 – 0.95

Formulas for the 2 methods

Calculation methodFormula
Normal approximation (z-based)
n=(z1α/2+z1β)2σ2δ2
Noncentral t (exact, one-sample t-test)
1β=Pr(|tn1,λ|>t1α/2,n1)

How this method works

When σ is estimated from the sample, the test statistic (x̄ − μ₀)/(s/√n) does not follow a normal distribution under the alternative; it follows a noncentral t distribution with n − 1 degrees of freedom and noncentrality λ = δ√n/σ. Power is computed from that distribution and n is found by search.

The test is two-sided: H₀: μ = μ₀ against H₁: μ ≠ μ₀. α is split between the two tails, so the α-quantile is z₁₋α/₂.

Selected method — noncentral t. When the population standard deviation is unknown and the planned analysis is a one-sample t-test, the test statistic follows a noncentral t distribution under the alternative, with noncentrality λ = δ√n/σ on n − 1 degrees of freedom. The smallest n attaining the target power is found by iteration.

This is the exact calculation and is the appropriate choice whenever σ is estimated from the data. It is not merely a small-sample correction: the normal formula is an approximation to it at every n, and the two converge as n grows.

Null hypothesis. H₀: μ = μ₀

Alternative hypothesis. Two-sided H₁: μ ≠ μ₀. One-sided H₁: μ > μ₀ or μ < μ₀.

Calculation procedure

  1. State μ0, μ1 and σ, giving the standardised effect d=(μ1μ0)/σ.
  2. For a candidate n, form the noncentrality λ=dn; the test statistic follows a noncentral t on n1 degrees of freedom.
  3. Compute exact power as Pr(|tn1,λ|>t1α/2,n1).
  4. Search upward for the smallest n whose power reaches the target.
  5. Round up, then inflate for dropout. This is the correct calculation whenever σ is estimated rather than known.

Exact or approximate

Exact, to the numerical tolerance of the distribution routines.

The formula shown always matches what was computed: when a one-sided test is selected the rendered quantile changes from z1−α/2 to z1−α, and where several methods exist, the formula follows the method selected in the calculator.

Advantages & limitations

Advantages

  • Correct when σ is estimated, which is the normal case in practice.
  • Accounts for degrees of freedom explicitly.
  • Agrees with G*Power and the R pwr package.

Limitations

  • No closed form; the figure cannot be reproduced by hand.
  • More sensitive to the normality assumption than the large-sample approximation.

Assumptions

  • Observations are independent and identically distributed.
  • The outcome is normally distributed — this matters more here than for the normal approximation, since the t distribution depends on it.
  • σ is unknown and estimated by the sample standard deviation.
  • Simple random sampling with no clustering.

Applicable adjustments

Supports dropout inflation. Finite population correction and clustering as for the z-based method.

Conclusion

This is the defensible figure for a protocol whose analysis is a one-sample t-test. Report it together with σ, the difference sought, α and power, since the result is conditional on all four.

References

  1. Guenther WC. Sample size formulas for normal theory t tests. The American Statistician. 1981;35(4):243–244. Link
  2. Chow S-C, Shao J, Wang H, Lokhnygina Y. Sample Size Calculations in Clinical Research. 3rd ed. Boca Raton: Chapman & Hall/CRC; 2017.
  3. Rosner B. Fundamentals of Biostatistics. 8th ed. Boston: Cengage; 2015.