# Sample size calculator (power analysis)

> Power analysis for t tests, paired t, two proportions, ANOVA and correlation: n for 80% power or power for your n, with a power curve. Exact noncentral t.

URL: https://www.labcanvas.com/tools/sample-size-calculator

For a two-sample t test with a medium effect (Cohen’s d = 0.5), α = 0.05 two-sided and 80% power you need 64 participants per group, 128 in total. Choose the test (two-sample t, paired t, two proportions, one-way ANOVA or correlation), enter the expected effect as an effect size or as means and SDs, proportions or group means, and set α, power, one- or two-sided and the allocation ratio. The calculator gives the smallest sample size that reaches the target power, or the power of a sample size you already have, with a power curve. t tests use the exact noncentral t distribution, the same calculation as G*Power and R’s pwr.t.test.

## Quick answer

- **What it does:** Finds the sample size for a target power (or the power for a given n) for t tests, two proportions, one-way ANOVA and correlation.
- **Formula:** Two-sample t: power = 1 − F_t(t₁₋α/₂; ν, δ) + F_t(−t₁₋α/₂; ν, δ), with ν = n₁ + n₂ − 2 and noncentrality δ = d·√(n₁n₂/(n₁ + n₂)); n is the smallest whole number reaching the target.
- **Example:** d = 0.5, α = 0.05 two-sided, power 0.8: n = 64 per group (ν = 126, δ = 2.828, power 0.8015); with 63 per group power is 0.7952.

Free, in the browser, no account needed. Updated 2026-10-19.

## Features

- Two-sample t test (Cohen’s d, or two means and SDs), with unequal allocation \(n_2/n_1\)
- Paired t test or one-sample t test (\(d_z\), or mean and SD of the differences)
- Two independent proportions (normal approximation, optional Fleiss continuity correction)
- One-way ANOVA with \(k\) groups (Cohen’s \(f\), or expected group means and the within-group SD)
- Pearson correlation (\(\rho\)), as in R’s pwr.r.test
- Solve for sample size or for power; one- or two-sided; any \(\alpha\)
- Exact noncentral t and noncentral F distributions (checked against SciPy to 10 significant figures)
- Power curve (SVG or PNG), the sample sizes for small, medium and large effects, and a sentence for your methods section

## How to use it

1. **Choose the test**: Pick the analysis you will run: two-sample t, paired t, two proportions, one-way ANOVA or correlation, and whether to solve for n or for power.
2. **Enter the expected effect**: Type an effect size (\(d\), \(d_z\), \(f\) or \(\rho\)) or the expected means and SDs, proportions or group means from a pilot study or the literature.
3. **Set α and power**: Usually \(\alpha = 0.05\) two-sided and power 0.8 or 0.9; read off the sample size, the power curve and the sentence for your protocol.

## At a glance

| | |
| --- | --- |
| Tests | Two-sample t, paired/one-sample t, two proportions, one-way ANOVA, correlation |
| Solves for | Sample size (smallest whole n) or power |
| Distributions | Exact noncentral t (AS 243) and noncentral F; normal approximation for proportions; Fisher z for correlation |
| Options | \(\alpha\), power, one- or two-sided, allocation ratio, continuity correction |
| Check | \(d = 0.5\), \(\alpha = 0.05\), power 0.8 → 64 per group |
| Output | n per group and total, achieved power, critical value, noncentrality, power curve |

## How it works

**t tests (exact).** Under the alternative, the t statistic follows a noncentral t distribution with \(\nu\) degrees of freedom and noncentrality \(\delta\). For two independent groups \(\nu = n_1 + n_2 - 2\) and \(\delta = d \cdot \sqrt{n_1 n_2/(n_1 + n_2)}\), where \(d = (\mu_1 - \mu_2)/\sigma\); for a paired (or one-sample) test \(\nu = n - 1\) and \(\delta = d_z \cdot \sqrt{n}\), where \(d_z\) is the mean difference divided by the SD of the differences. Two-sided power is

$$\begin{aligned} 1 - \beta &= 1 - F_t(t_{1-\alpha/2,\,\nu};\, \nu, \delta) \\ &\quad + F_t(-t_{1-\alpha/2,\,\nu};\, \nu, \delta) \end{aligned}$$

and one-sided power drops the last term and uses \(t_{1-\alpha,\,\nu}\). The noncentral t distribution function is computed with Lenth’s algorithm AS 243 (as in R’s `pt`). When entering means and SDs, \(d\) uses the pooled SD \(\sqrt{(\mathrm{SD}_1^2 + \mathrm{SD}_2^2)/2}\).

**One-way ANOVA.** With \(k\) groups of \(n\), the F statistic follows a noncentral F distribution with \(k - 1\) and \(k(n - 1)\) degrees of freedom and noncentrality \(\lambda = f^2 \cdot k \cdot n\), where Cohen’s \(f\) is the SD of the group means (divided by \(k\)) over the within-group SD.

$$\text{Power} = 1 - F_F(F_{1-\alpha}; k - 1, k(n - 1), \lambda)$$

computed as a Poisson-weighted sum of incomplete beta functions. This is the convention of G*Power and R’s pwr.anova.test.

**Two proportions.** The normal approximation with the pooled proportion \(\bar{p} = (p_1 + k \cdot p_2)/(1 + k)\) under \(H_0\) and separate variances under \(H_1\) (\(n_2 = k \cdot n_1\)):

$$\begin{aligned} n_1 = \Bigl[&z_{1-\alpha/2}\sqrt{\bar{p}\bar{q}\,(1 + 1/k)} \\ &+ z_{1-\beta}\sqrt{p_1 q_1 + p_2 q_2/k}\,\Bigr]^2 \\ &\Big/ (p_1 - p_2)^2 \end{aligned}$$

The optional continuity correction is that of Fleiss, Tytun and Ury (1980):

$$n' = \frac{n}{4}\left(1 + \sqrt{1 + \frac{2(k + 1)}{n \cdot k \cdot \lvert p_1 - p_2 \rvert}}\right)^2$$

**Correlation.** The Fisher z approximation used by R’s pwr.r.test: the critical \(r\) is found from the t distribution with \(n - 2\) degrees of freedom, and \(\text{power} = \Phi\big((z_\rho - z_{r\,\mathrm{crit}})\sqrt{n - 3}\big)\) (plus the lower tail when two-sided), with \(z_\rho = \operatorname{atanh}\rho + \rho/(2(n - 1))\).

**Sample size** is the smallest whole \(n\) whose power reaches the target, found by search, so it already accounts for rounding and for the allocation ratio (\(n_2 = \lceil k \cdot n_1 \rceil\)). Cohen’s conventional effect sizes: \(d = 0.2, 0.5, 0.8\); \(f = 0.10, 0.25, 0.40\); \(\rho = 0.1, 0.3, 0.5\) (small, medium, large). They are a last resort: an effect estimated from pilot data or the smallest effect that matters is better.

**Checks.** The distribution functions agree with SciPy’s `nct` and `ncf` to at least 10 significant figures. \(d = 0.5\) gives 64 per group (G*Power and pwr.t.test: 63.77 rounded up), \(d_z = 0.5\) gives 34 pairs, \(f = 0.25\) with 3 groups gives 53 per group (159 in total), and \(\rho = 0.3\) gives 85 (pwr.r.test: 84.07 rounded up).

Sources: Cohen J. *Statistical Power Analysis for the Behavioral Sciences*, 2nd ed. Hillsdale, NJ: Lawrence Erlbaum; 1988 (reissued by Routledge, [doi:10.4324/9780203771587](https://doi.org/10.4324/9780203771587)). Faul F, Erdfelder E, Lang A-G, Buchner A. G*Power 3: a flexible statistical power analysis program for the social, behavioral, and biomedical sciences. *Behav Res Methods* 2007;39:175–191, [doi:10.3758/BF03193146](https://doi.org/10.3758/BF03193146). Lenth RV. Algorithm AS 243: cumulative distribution function of the non-central t distribution. *Appl Stat* 1989;38:185–189, [doi:10.2307/2347693](https://doi.org/10.2307/2347693). Fleiss JL, Tytun A, Ury HK. A simple approximation for calculating sample sizes for comparing independent proportions. *Biometrics* 1980;36:343–346, [doi:10.2307/2529990](https://doi.org/10.2307/2529990).

## Worked examples: t test, ANOVA and two proportions

**Two-sample t test.** You expect treated cells to differ from controls by half an SD (\(d = 0.5\)) and will test two-sided at \(\alpha = 0.05\) with 80% power. With 64 per group, \(\nu = 126\), the critical \(t\) is 1.9790 and \(\delta = 0.5 \times \sqrt{64 \times 64 / 128} = 2.828\), giving power 0.8015; with 63 per group power is 0.7952, so **64 per group (128 in total)** is the answer. Entering means 10 and 12 with SDs of 4 gives the same \(d = 2/4 = 0.5\).

- One-sided instead: 51 per group.
- Power 0.9 instead of 0.8: 86 per group.
- Twice as many in group 2 (ratio 2): \(n_1 = 48\), \(n_2 = 96\) (power 0.8021).
- With only 20 per group, power is 33.8%.

| Test | Small | Medium | Large |
| --- | --- | --- | --- |
| Two-sample t (\(d = 0.2 / 0.5 / 0.8\)), per group | 394 | 64 | 26 |
| Paired t (\(d_z = 0.2 / 0.5 / 0.8\)), pairs | 199 | 34 | 15 |
| One-way ANOVA, 3 groups (\(f = 0.10 / 0.25 / 0.40\)), per group | 323 | 53 | 22 |
| Correlation (\(\rho = 0.1 / 0.3 / 0.5\)), total | 782 | 85 | 29 |

**One-way ANOVA.** Three groups with \(f = 0.25\): with 53 per group (\(N = 159\)) the F test has 2 and 156 degrees of freedom, critical \(F = 3.054\) and \(\lambda = 0.25^2 \times 159 = 9.94\), so power is 0.8049 (52 per group gives 0.7967). Entering group means 10, 12 and 14 with a within-group SD of 6 gives \(f = 1.633 / 6 = 0.272\).

**Two proportions.** A response rate of 65% with the standard treatment and 85% expected with the new one, \(\alpha = 0.05\) two-sided, power 0.8: \(n = 72.4\), so **73 per group** (power 0.8033). With the Fleiss continuity correction it is 83 per group.

## Questions

### How do I calculate sample size for a t test?

Decide the smallest difference worth detecting and the SD you expect, and divide to get Cohen’s \(d\). With \(\alpha = 0.05\) two-sided and 80% power, \(d = 0.5\) needs 64 per group, \(d = 0.8\) needs 26 and \(d = 0.2\) needs 394. The calculator finds the smallest \(n\) whose power, from the noncentral t distribution, reaches the target.

### What sample size do I need for 80% power?

It depends on the effect size: for a two-sample t test at \(\alpha = 0.05\) two-sided, 26 per group for a large effect (\(d = 0.8\)), 64 for a medium effect (\(d = 0.5\)) and 394 for a small effect (\(d = 0.2\)). Smaller effects need many more participants because \(n\) scales roughly with \(1/d^2\).

### What is Cohen’s d and how do I estimate it?

\(d\) is the difference between the two means divided by the pooled SD. Estimate it from pilot data or published studies, or from the smallest difference that would matter in practice and the usual SD of the measurement. Cohen called 0.2, 0.5 and 0.8 small, medium and large, but those labels are only a fallback.

### Should I use a one-sided or two-sided test?

Two-sided, unless a difference in the other direction would be of no interest and you decided this before collecting data. A one-sided test needs fewer participants (51 instead of 64 per group for \(d = 0.5\)) but cannot detect an effect in the opposite direction.

### Does this give the same answer as G*Power?

For t tests and one-way ANOVA it uses the same exact noncentral t and F distributions, so the sample sizes match: 64 per group for \(d = 0.5\), 34 pairs for \(d_z = 0.5\) and 159 in total for \(f = 0.25\) with 3 groups. For correlation it uses the Fisher z method of R’s pwr.r.test, and for proportions the normal approximation; G*Power’s exact options for those can differ by a participant or two.

### How do I account for dropouts?

Divide the calculated sample size by the proportion you expect to complete. For 64 per group and 15% dropout, recruit \(64 / 0.85 = 75.3\), so 76 per group.

### What is the difference between power and α?

\(\alpha\) is the chance of a false positive (rejecting \(H_0\) when there is no effect), usually 0.05. Power, \(1 - \beta\), is the chance of detecting the effect if it is real, usually 0.8 or 0.9; \(\beta\) is the false-negative rate.

### How many animals or replicates do I need per group?

Use the same calculation with the effect you expect relative to the variability between animals or replicates. For a large effect (\(d = 0.8\)) a two-sample t test needs 26 per group for 80% power; for very large effects (\(d = 1.5\)) it needs 9. Reporting guidelines such as ARRIVE ask you to state how the sample size was chosen.
