Means: One and Two Groups
Calculate the required sample size for comparing two independent population means when the population variances are known. Supports one-sided and two-sided tests, unequal known variances, and equal or unequal allocation between the two groups. Runs entirely in your browser.
This calculator implements the two-sample z-test for two independent means when the population variances are known. The null hypothesis is H0: μ1 − μ2 = 0, with either a two-sided alternative or a one-sided alternative.
When the population variances are known, the standard error of the difference between two independent sample means is
For the usual superiority calculation, the null difference δ0 is zero. The sample-size calculation uses the anticipated difference δ = |μ1 − μ2| as the effect to be detected.
Under the anticipated alternative, the standardized effect is
For a two-sided test with significance level α, the exact normal approximation used here is
For a one-sided test, the corresponding expression is
where Φ is the standard normal cumulative distribution function. Rather than relying on a rounded closed-form approximation, the calculator searches over integer sample sizes and returns the first allocation whose calculated power is at least the requested target.
With equal allocation, N1 = N2. With ratio allocation, the calculator uses N2 = R × N1 and searches over integer N1, rounding N2 upward to the next whole participant when necessary.
For equal allocation, the familiar approximate closed-form expression follows directly from the standardized effect:
The actual implementation performs the power calculation directly and searches for the smallest integer sample size, which also accounts for the small contribution of the opposite tail in a two-sided test.
this method provides a validation example using a two-sided two-sample z-test with 90% target power, α = 0.05, equal allocation, a mean difference of 2, and known standard deviations of 4.1 and 5.3. Equivalently, the known variances entered here are σ₁² = 16.81 and σ₂² = 28.09.
The JavaScript implementation below reproduces this validation result: 117 participants per group gives power below 0.90, whereas 118 per group gives power approximately 0.90013. Thus 118 per group is the smallest integer allocation satisfying the target.
the software, LLC. (2023).
Two-Sample Z-Tests Allowing Unequal Variance.
this method Sample Size Software, Chapter 428. the relevant methodological literature describes
sample-size and power calculations for one- and two-sided two-sample
z-tests with known unequal variances and provides the worked validation
example used above.
this method procedure documentation
the software, LLC. (2023).
Two-Sample Z-Tests Assuming Equal Variance.
this method Sample Size Software, Chapter 426. This documentation gives the
corresponding known-common-variance two-sample z-test and cites Julious
(2010) and Chow, Shao, and Wang (2008) as references for the power and
sample-size methodology.
this method equal-variance procedure documentation
Julious, S. A. (2010). Sample Sizes for Clinical Trials. Boca Raton: CRC Press/Taylor & Francis. Chapter 3 covers sample-size calculations for parallel-group superiority trials with normal data.
Julious, S. A., Tan, S. B., & Machin, D. (2010). Sample Size Calculations for Clinical Trials. In An Introduction to Statistics in Early Phase Trials, pp. 37–53. Wiley. DOI: 10.1002/9780470686164.ch3 .
Statsols /.
Advanced User Manual, Section 7.2.5.1,
“Two Means (GST1).” The documentation expresses the maximum
information for an inequality two-sample z-test in terms of
σ₁²/N₁ + σ₂²/N₂ and relates the
information to the standardized mean difference.
Advanced User Manual