General Concepts & Power Analysis
Statistical Power Components
Statistical Power
$$\text{Power} = 1 - \beta = P(\text{Reject } H_0 \mid H_1 \text{ is true})$$
$\alpha$ — Significance level (Type I error rate)
$\beta$ — Type II error rate
$1-\beta$ — Statistical power
$n$ — Sample size per group
$\delta$ — Effect size (standardised)
$\sigma$ — Population standard deviation

Standard conventions

$\alpha = 0.05$ (5% significance), Power $= 0.80$ (80%), $\beta = 0.20$. These are defaults — domain knowledge should guide actual choices.

Critical Values
Two-sided critical value
$$z_{\alpha/2} = \Phi^{-1}\!\left(1 - \tfrac{\alpha}{2}\right) \approx 1.96 \text{ for } \alpha=0.05$$
One-sided critical value
$$z_{\alpha} = \Phi^{-1}(1 - \alpha) \approx 1.645 \text{ for } \alpha=0.05$$
Power critical value
$$z_{\beta} = \Phi^{-1}(\beta) = \Phi^{-1}(1 - \text{Power}) \approx -0.84 \text{ for Power}=0.80$$
One-Sample t-test (Mean)
Cloud Function ↗
Sample Size Formula (Normal Approximation)
Sample size
$$n = \left(\frac{z_{\alpha/2} + z_{\beta}}{d}\right)^{\!2}$$
Cohen's d (standardised effect size)
$$d = \frac{|\mu - \mu_0|}{\sigma}$$
$\mu$ — Expected population mean
$\mu_0$ — Null hypothesis mean
$\sigma$ — Population standard deviation
$d$ — Cohen's d
Exact Method — Non-Central t-Distribution (Cloud)

Cloud function endpoint

GET https://us-central1-tukey-multple-comparisons.cloudfunctions.net/t_testOneSample

Query parameters
effect_size  — Cohen's d (float, e.g. 0.5)
target_power  — desired power (float, e.g. 0.8)
significance_level  — α (float, e.g. 0.05)
tail_type  — two_tailed | one_tailed
Example response
{"required_sample_size": 34}
Live API Test
Two-Sample t-test (Means)
Local calculation
Equal Sample Sizes
Sample size per group
$$n = 2\!\left(\frac{z_{\alpha/2} + z_{\beta}}{d}\right)^{\!2}$$
Effect size (Cohen's d)
$$d = \frac{|\mu_1 - \mu_2|}{\sigma_{\text{pooled}}}$$
Unequal Sample Sizes (allocation ratio $k = n_2/n_1$)
Group 1
$$n_1 = \left(\frac{z_{\alpha/2} + z_{\beta}}{d}\right)^{\!2} \cdot \frac{1+k}{k}$$
Group 2
$$n_2 = k \cdot n_1$$
$\mu_1, \mu_2$ — Group means
$\sigma_{\text{pooled}}$ — Pooled standard deviation
$k = n_2/n_1$ — Allocation ratio

Implementation note

The calculator uses an iterative binary search with the exact t-distribution (incomplete beta function) rather than the normal approximation — this is especially important for small $n$.

One-Sample Proportion Test
Local calculation
Sample Size Formula
Exact form
$$n = \frac{\Bigl(z_{\alpha/2}\sqrt{p_0(1-p_0)}\;+\;z_{\beta}\sqrt{p(1-p)}\Bigr)^2}{(p - p_0)^2}$$
Large-sample approximation
$$n \approx \frac{(z_{\alpha/2} + z_{\beta})^2 \cdot p(1-p)}{(p - p_0)^2}$$
$p$ — Expected proportion
$p_0$ — Null hypothesis proportion
$\sqrt{p(1-p)}$ — SE of proportion

Normal approximation valid when

$np \geq 5$ and $n(1-p) \geq 5$ for both $p$ and $p_0$.

Two-Sample Proportion Test
Local calculation
Sample Size Formula
Sample size per group
$$n = \frac{\Bigl(z_{\alpha/2}\sqrt{2\bar{p}(1-\bar{p})}\;+\;z_{\beta}\sqrt{p_1(1-p_1)+p_2(1-p_2)}\Bigr)^2}{(p_1-p_2)^2}$$
Pooled proportion
$$\bar{p} = \frac{p_1 + p_2}{2}$$
$p_1, p_2$ — Group proportions
$\bar{p}$ — Pooled proportion estimate
Total N $= 2n$
Correlation Analysis
Local calculation
Fisher's Z Transformation Method
Fisher's Z transform
$$Z_r = \frac{1}{2}\ln\!\left(\frac{1+r}{1-r}\right)$$
Sample size (testing $r$ vs $r_0$)
$$n = \left(\frac{z_{\alpha/2} + z_{\beta}}{Z_1 - Z_0}\right)^{\!2} + 3$$
Special case: testing $r = 0$
$$n = \left(\frac{z_{\alpha/2} + z_{\beta}}{0.5\ln\!\left(\frac{1+r}{1-r}\right)}\right)^{\!2} + 3$$
$r$ — Expected correlation coefficient
$r_0$ — Null hypothesis correlation (often 0)
$Z_1, Z_0$ — Fisher's Z of $r$ and $r_0$

Why Fisher's Z?

The correlation coefficient $r$ has a skewed sampling distribution. Fisher's Z transform maps $r \in (-1,1)$ to a near-normally distributed variable with standard error $\approx 1/\sqrt{n-3}$, enabling straightforward z-test power calculations.

One-Way ANOVA
Local calculation
Sample Size Formula
Sample size per group (normal approximation)
$$n \approx \frac{(z_{\alpha} + z_{\beta})^2}{f^2} + 1$$
Total sample size
$$N = n \times k$$
Cohen's f from group means
$$f = \frac{\sigma_m}{\sigma} = \sqrt{\frac{\eta^2}{1-\eta^2}}$$
Eta-squared $(\eta^2)$
$$\eta^2 = \frac{SS_{\text{between}}}{SS_{\text{total}}} = \frac{\sum_{i=1}^{k} n_i(\mu_i - \bar{\mu})^2}{\sigma^2_{\text{total}}}$$
$k$ — Number of groups
$f$ — Cohen's f (effect size)
$\sigma_m$ — SD of group means
$\sigma$ — Within-group SD
$\eta^2$ — Proportion of variance explained
$\lambda = nkf^2$ — Non-centrality parameter

Implementation detail

The calculator uses a binary search over $n$ with the F-distribution critical value from the incomplete beta function. Power is approximated via the normal distribution applied to $\lambda = nkf^2$.

Linear Regression
Local calculation
Sample Size Formula
Multiple regression (overall model)
$$n = \frac{(z_{\alpha} + z_{\beta})^2}{f^2} + p + 1$$
Cohen's $f^2$ from $R^2$
$$f^2 = \frac{R^2}{1 - R^2}$$
Single additional predictor
$$n = \frac{(z_{\alpha/2} + z_{\beta})^2 \cdot (1-R^2)}{R^2_{\text{new}}} + p + 1$$
$p$ — Number of predictors
$R^2$ — Expected coefficient of determination
$f^2$ — Cohen's $f^2$ (effect size)
$R^2_{\text{new}}$ — Incremental variance from new predictor
$\lambda = nR^2/(1-R^2)$ — Non-centrality parameter
Effect Size Guidelines
Cohen's Conventions
Test TypeSmallMediumLarge
Cohen's d (t-tests)0.20.50.8
Cohen's f (ANOVA)0.10.250.4
Cohen's f² (Regression)0.020.150.35
R² (Regression)0.020.130.26
Correlation r0.10.30.5

Important note

These are general guidelines only. Effect sizes should be grounded in practical significance and prior domain knowledge — not chosen to meet Cohen's thresholds.

Conversions Between Effect Size Metrics
Cohen's d → Cohen's f
$$f = \frac{d}{2}$$
$\eta^2$ → Cohen's f
$$f = \sqrt{\frac{\eta^2}{1-\eta^2}}$$
$R^2$ → Cohen's $f^2$
$$f^2 = \frac{R^2}{1-R^2}$$
Cloud API Reference
Base URL
https://us-central1-tukey-multple-comparisons.cloudfunctions.net/
Available Endpoints
GET /t_testOneSample — Non-central t-distribution (exact)
Parameters
effect_sizefloat — Cohen's d
target_powerfloat — e.g. 0.8
significance_levelfloat — e.g. 0.05
tail_typetwo_tailed | one_tailed
Response
{"required_sample_size": 34}
Live Test — /t_testOneSample

CORS — serving from file://

If opening this page directly from disk (file://), the browser will block the cloud call. Serve from a local web server: python -m http.server 8000, then open http://localhost:8000/SampleSizeFormulas.html.

Planned / Future Endpoints
/t_testTwoSample
/proportionOneSample
/proportionTwoSample
/correlationTest
/anovaOneway
/regressionMultiple
References

Key references

• Cohen, J. (1988). Statistical Power Analysis for the Behavioral Sciences (2nd ed.)
• Faul, F., Erdfelder, E., Lang, A. G., & Buchner, A. (2007). G*Power 3
• Lakens, D. (2013). Calculating and reporting effect sizes
• Murphy, K. R., Myors, B., & Wolach, A. (2014). Statistical Power Analysis