Skip to main content

    Method document

    Sample size for a two-sample t-test

    How many participants are needed in each of two independent groups to show that their means differ, with chosen significance and power. The usual design for a parallel-group trial with a continuous outcome. Covers unequal allocation, a baseline covariate, clustering, non-adherence and dropout.

    Engine version 1.0.0 · Reviewed 1 October 2026

    https://statwisely.com/methods/means-two-sample/

    When to use it

    • A randomised trial or comparative study with two independent groups and a continuous outcome.

    Not for

    • Groups expected to vary very differently, especially with unequal group sizes. Use Welch’s t-test.
    • More than two groups. Use one-way ANOVA, or the multi-arm comparison against a shared control.
    • Showing that a new treatment is not worse than, or equivalent to, another. Use non-inferiority or equivalence.

    Notation

    n1, n2n_1,\ n_2
    Participants in groups 1 and 2
    rar_a
    Allocation ratio n₂ / n₁
    Δ\Delta
    Difference between the group means
    σ\sigma
    Common standard deviation
    dd
    Standardised effect, Δ / σ
    λ\lambda
    Noncentrality of the t distribution
    α\alpha
    Significance level: the chance of a false positive
    1−β1-\beta
    Power: the chance of detecting the effect if it is real
    τ\tau
    Number of tails: 2 for a two-sided test, 1 for one-sided
    rbr_b
    Correlation between the outcome and a baseline covariate
    ρ\rho
    Intracluster correlation coefficient (ICC)
    mm
    Average number of participants per cluster
    CV\mathrm{CV}
    Coefficient of variation of cluster size
    CC
    Clusters per group
    ℓ\ell
    Expected loss of whole clusters
    dt, dcd_t,\ d_c
    Share of the treatment arm not taking treatment, and of the control arm receiving it
    qq
    Expected dropout, overall or for each arm (q₁, q₂)

    Formulas

    The smallest n with enough power

    Pr⁡ ⁣(Tν,λ′>tν, 1−α/τ)≥1−β,λ=dn1n2n1+n2,ν=n1+n2−2,n2=ra n1\Pr\!\left(T'_{\nu,\lambda} > t_{\nu,\,1-\alpha/\tau}\right) \ge 1-\beta, \qquad \lambda = d\sqrt{\frac{n_1 n_2}{n_1 + n_2}}, \quad \nu = n_1 + n_2 - 2, \quad n_2 = r_a\,n_1

    Student’s t-test with a pooled standard deviation. When the effect is real its statistic follows a noncentral t distribution, and n₁ is the smallest whole number whose power reaches the target; the lower rejection region is included for a two-sided test [1].

    For intuition: the normal approximation

    n1≈(1+1ra)(z1−α/τ+z1−βd)2n_1 \approx \left(1 + \frac{1}{r_a}\right)\left(\frac{z_{1-\alpha/\tau} + z_{1-\beta}}{d}\right)^{2}

    Not what the calculator uses, but it shows that equal groups are the most efficient, and that halving the effect quadruples the sample.

    Adjusting for a baseline covariate

    n′=⌈n (1−rb2)⌉+1n' = \left\lceil n\,(1 - r_b^{2}) \right\rceil + 1

    Analysing with a baseline measurement as a covariate (ANCOVA) removes the share r_b² of the outcome’s variance the test would otherwise have to overcome. One participant per group is added back for the degree of freedom the covariate uses [3].

    Clustering

    DE=1+[(CV2+1) m−1]ρ\mathrm{DE} = 1 + \left[(\mathrm{CV}^{2} + 1)\,m - 1\right]\rho

    When participants are recruited or randomised in clusters, observations within a cluster repeat information, and the sample is multiplied by the design effect. With equal clusters (CV = 0) this is 1 + (m − 1)ρ [4, 5].

    Few clusters

    Ft=(t2(C−1), 1−α/τ+t2(C−1), 1−βz1−α/τ+z1−β)2F_t = \left(\frac{t_{2(C-1),\,1-\alpha/\tau} + t_{2(C-1),\,1-\beta}}{z_{1-\alpha/\tau} + z_{1-\beta}}\right)^{2}

    Optional. A cluster trial is analysed on cluster-level summaries, so its critical values come from t on 2(C − 1) degrees of freedom rather than the normal distribution. With few clusters this costs participants; because C depends on the sample, it is iterated until it settles [6].

    Non-adherence and crossover

    n′=n(1−dt−dc)2n' = \frac{n}{(1 - d_t - d_c)^{2}}

    An intention-to-treat analysis keeps everyone in the arm they were allocated to, so participants who do not receive their allocated treatment dilute the difference. Lachin’s correction restores the power [7].

    All adjustments together

    nadj=⌈n(1−rb2) DE  Ft 1(1−dt−dc)2⌉+1n_{\text{adj}} = \left\lceil n (1 - r_b^{2})\,\mathrm{DE}\;F_t\,\frac{1}{(1 - d_t - d_c)^{2}} \right\rceil + 1

    The adjustments multiply, in this order, and the result is rounded up once. Any adjustment not used contributes a factor of 1.

    Dropout

    nrecruit,i=⌈nadj1−qi⌉,i=1,2n_{\text{recruit},i} = \left\lceil \frac{n_{\text{adj}}}{1 - q_i} \right\rceil, \qquad i = 1, 2

    Applied last, to the participants actually recruited. The rate can differ between the arms; when it does not, q₁ = q₂ = q.

    Clusters to recruit

    C=⌈nrecruitm⌉,Crecruit=⌈C1−ℓ⌉C = \left\lceil \frac{n_{\text{recruit}}}{m} \right\rceil, \qquad C_{\text{recruit}} = \left\lceil \frac{C}{1 - \ell} \right\rceil

    Per group. Losing a whole cluster loses every participant in it, so an expected loss of clusters inflates the clusters recruited rather than the participants.

    Parameters

    Difference to detectΔ\Delta

    Values: Not zero, in the measurement’s units

    The smallest difference that would matter, clinically or practically. Not the difference you hope for: a study sized for an optimistic effect is underpowered for a real but smaller one.

    Standard deviationσ\sigma

    Values: Above 0, in the measurement’s units

    From a comparable published study, a pooled SD from several studies, or pilot data. The sample size grows with its square, so check a larger value too.

    Cohen’s d, instead of the two aboveddOptional

    Values: Above 0

    The difference in standard-deviation units. Cohen’s benchmarks of 0.2, 0.5 and 0.8 for small, medium and large are a last resort; a difference and SD from your own field are better [1].

    Significance levelα\alpha

    Values: Between 0 and 1; usually 0.05

    The false-positive rate you accept. A smaller α, for example to allow for several primary outcomes, needs a larger sample.

    Power1−β1-\beta

    Values: Between 0 and 1; usually 0.80 or 0.90

    The chance of a significant result if the assumed effect is real. Funders and ethics committees commonly expect at least 0.80.

    One- or two-sidedτ\tau

    Values: 2 (two-sided) or 1 (one-sided)

    Two-sided is the default. A one-sided test is justified only when an effect in the other direction would be treated exactly as no effect, and should be stated in advance.

    Allocation ratiorar_aOptional

    Values: Above 0; 1 for equal groups

    The planned size of group 2 divided by group 1. Equal groups need the fewest participants in total; unequal allocation can be worth it when one arm is cheaper or more acceptable.

    Expected dropoutqqOptional

    Values: 0% up to, but not including, 100%

    The share of participants expected to provide no outcome, from comparable studies. Recruiting more restores the numbers, not the comparability of the groups: if dropout is related to the outcome, the estimate can still be biased.

    Dropout in each armq1, q2q_1,\ q_2Optional

    Values: 0% up to, but not including, 100%, for each arm

    When dropout is expected to differ between arms, for example higher with an unpleasant treatment. Each arm is then inflated by its own rate.

    Baseline correlationrbr_bOptional

    Values: Between −1 and 1

    The correlation between the outcome and its baseline measurement, from previous data. Only use it if the analysis will adjust for the baseline.

    Intracluster correlation (ICC)ρ\rhoOptional

    Values: From 0 to 1

    For clustered designs only. Published ICCs for health outcomes in primary-care and community clusters are mostly small, often below 0.05 [8]; prefer an estimate from a comparable trial.

    Average cluster sizemmOptional

    Values: At least 1

    The average number of participants per cluster. Given with the ICC.

    Variation in cluster sizeCV\mathrm{CV}Optional

    Values: 0 or more; 0 for equal clusters

    The SD of cluster sizes divided by their mean. Unequal clusters cost power on their own account [5].

    Expected loss of whole clustersℓ\ellOptional

    Values: 0% up to, but not including, 100%

    Clusters, such as practices or schools, expected to withdraw entirely.

    Correction for few clustersFtF_tOptional

    Values: On or off

    Worth applying when there are few clusters per group, roughly fewer than 15–20.

    Non-adherence and crossoverdt, dcd_t,\ d_cOptional

    Values: 0% up to, but not including, 100%; the two together below 100%

    The share of the treatment arm expected not to take it, and of the control arm expected to receive it, from comparable trials.

    Assumptions

    • The groups are independent, and participants are independent of one another apart from any clustering specified.
    • The outcome is roughly normal in each group with the same standard deviation. With unequal spread, and especially unequal group sizes, use Welch’s test.
    • With clustering: clusters are independent, with the same ICC throughout, and the analysis accounts for the clustering, for example with a mixed model or cluster-level summaries [4].
    • Dropout is unrelated to the outcome; recruiting more participants restores the numbers but cannot remove bias.
    • Non-adherence is corrected for an intention-to-treat analysis, with treatment received having its full effect and no effect otherwise.

    Worked examples

    Two equal groups

    Difference 5, SD 10, so d = 0.5; α = 0.05 two-sided, 80% power: 64 per group, 128 in total.

    Group 1: 64 · Group 2: 64 · Total: 128

    Protocol statement

    To detect a difference in means of 5 with 80% power at a two-sided significance level of 0.05, using a two-sample t-test, and assuming a standard deviation of 10, the required sample size is 64 per group (128 in total). Calculated with StatWisely (statwisely.com) using: n₁ and n₂: solve noncentral-t power for d, α, 1-β, and allocation ratio. These are planning estimates; confirm the final design with a qualified statistician.

    Open this example in the calculator

    Twice as many in group 2

    With a 1 : 2 allocation, 48 and 96: 144 in total, against 128 with equal groups.

    Group 1: 48 · Group 2: 96 · Total: 144

    Open this example in the calculator

    Adjusting for the baseline

    With a baseline correlation of 0.5: 64 × (1 − 0.5²) = 48, plus 1 for the covariate, so 49 per group.

    Group 1: 49 · Group 2: 49 · Total: 98

    Protocol statement

    To detect a difference in means of 5 with 80% power at a two-sided significance level of 0.05, using a two-sample t-test, and assuming a standard deviation of 10, the test itself needs 64 per group. With adjustment for a baseline covariate (r = 0.5), the required sample size is 49 per group (98 in total). Calculated with StatWisely (statwisely.com) using: n₁ and n₂: solve noncentral-t power for d, α, 1-β, and allocation ratio; ANCOVA: n x (1 - r^2) + 1. These are planning estimates; confirm the final design with a qualified statistician.

    Open this example in the calculator

    A cluster-randomised trial

    Clusters of 10 with ICC 0.05: DE = 1 + 9 × 0.05 = 1.45, so 64 × 1.45 = 92.8, rounded up to 93 per group, in 10 clusters per group.

    Group 1: 93 · Group 2: 93 · Total: 186

    Protocol statement

    To detect a difference in means of 5 with 80% power at a two-sided significance level of 0.05, using a two-sample t-test, and assuming a standard deviation of 10, the test itself needs 64 per group. With clustering (ICC 0.05, an average of 10 per cluster; design effect 1.45), the required sample size is 93 per group (186 in total), in 10 clusters per group. Calculated with StatWisely (statwisely.com) using: n₁ and n₂: solve noncentral-t power for d, α, 1-β, and allocation ratio; clustered: n x DE, DE = 1 + (m-1)ρ. These are planning estimates; confirm the final design with a qualified statistician.

    Open this example in the calculator

    Allowing for non-adherence

    If 10% of the treatment arm will not take it and 5% of the control arm will: 64 / (1 − 0.10 − 0.05)² = 88.6, so 89 per group.

    Group 1: 89 · Group 2: 89 · Total: 178

    Protocol statement

    To detect a difference in means of 5 with 80% power at a two-sided significance level of 0.05, using a two-sample t-test, and assuming a standard deviation of 10, the test itself needs 64 per group. With non-adherence of 10% in the treatment arm and crossover of 5% in the control arm, the required sample size is 89 per group (178 in total). Calculated with StatWisely (statwisely.com) using: n₁ and n₂: solve noncentral-t power for d, α, 1-β, and allocation ratio; non-adherence: n / (1 - d_t - d_c)^2. These are planning estimates; confirm the final design with a qualified statistician.

    Open this example in the calculator

    Different dropout in each arm

    Expecting 20% dropout in group 1 and 10% in group 2: 64 / 0.8 = 80 and 64 / 0.9 = 71.1, so 80 and 72 are recruited.

    Group 1: 64 · Group 2: 64 · Total: 128 · To recruit: 80 and 72

    Protocol statement

    To detect a difference in means of 5 with 80% power at a two-sided significance level of 0.05, using a two-sample t-test, and assuming a standard deviation of 10, the required sample size is 64 per group (128 in total). Allowing for dropout of 20% in the first group and 10% in the second, 80 in the first group and 72 in the second group (152 in total) should be recruited. Calculated with StatWisely (statwisely.com) using: n₁ and n₂: solve noncentral-t power for d, α, 1-β, and allocation ratio. These are planning estimates; confirm the final design with a qualified statistician.

    Open this example in the calculator

    Validation

    • Every worked example on this page is recomputed by the StatWisely engine whenever the software is built. If a number or formula here stopped matching the calculator, the release would be stopped until this document was corrected.
    • An independent implementation in R recomputes this test every night and before each production release, and the results are compared with the engine’s.
    • The basic result agrees with G*Power’s two-sample t-test: 64 per group for d = 0.5, α = 0.05 two-sided and 80% power [2].

    How to cite

    StatWisely. Sample size for a two-sample t-test. Method document, engine version 1.0.0, reviewed 2026-10-01. https://statwisely.com/methods/means-two-sample/

    Cite the original references for the formulas your design uses as well.

    References

    1. 1.Cohen J. Statistical Power Analysis for the Behavioral Sciences. 2nd ed. Hillsdale, NJ: Lawrence Erlbaum Associates; 1988.
    2. 2.Faul F, Erdfelder E, Lang AG, Buchner A. G*Power 3: a flexible statistical power analysis program for the social, behavioral, and biomedical sciences. Behavior Research Methods. 2007;39(2):175–191.
    3. 3.Borm GF, Fransen J, Lemmens WAJG. A simple sample size formula for analysis of covariance in randomized clinical trials. Journal of Clinical Epidemiology. 2007;60(12):1234–1238.
    4. 4.Donner A, Klar N. Design and Analysis of Cluster Randomization Trials in Health Research. London: Arnold; 2000.
    5. 5.Eldridge SM, Ashby D, Kerry S. Sample size for cluster randomized trials: effect of coefficient of variation of cluster size and analysis method. International Journal of Epidemiology. 2006;35(5):1292–1300. doi:10.1093/ije/dyl129
    6. 6.Hayes RJ, Moulton LH. Cluster Randomised Trials. 2nd ed. Boca Raton: CRC Press; 2017.
    7. 7.Lachin JM. Biostatistical Methods: The Assessment of Relative Risks. New York: John Wiley & Sons; 2000.
    8. 8.Adams G, Gulliford MC, Ukoumunne OC, Eldridge S, Chinn S, Campbell MJ. Patterns of intra-cluster correlation from primary care research to inform study design and analysis. Journal of Clinical Epidemiology. 2004;57(8):785–794. doi:10.1016/j.jclinepi.2003.12.013