How is the sample size calculated?
We start from the desired type I error \((\alpha)\) and
power \((1-\beta)\).
These levels determine the critical values of the standard normal distribution
\(\,z_{\alpha/2}\) or \(z_{\alpha}\) (for two- or one-tailed tests, respectively)
and \(z_{\beta}\).
• Comparison of proportions \(\bigl(p_{1}\ \text{vs.}\ p_{2}=p_{1}+d\bigr)\):
\[
n \;=\;
\frac{\left[\,z_{\alpha}\,\sqrt{2\,\bar p\,(1-\bar p)} \;+\;
z_{\beta}\,\sqrt{p_{1}(1-p_{1}) + p_{2}(1-p_{2})}\,\right]^{2}}{d^{2}}
\]
where \(\bar p = \tfrac{p_{1}+p_{2}}{2}\) and \(d\) is the MDE expressed as a proportion
(percentage points / 100).
• Comparison of means:
\[
n \;=\; \frac{2\,(z_{\alpha}+z_{\beta})^{2}\,\sigma^{2}}{\delta^{2}}
\]
with \(\sigma\) the population standard deviation and \(\delta\) the MDE in units of the variable.
These formulas assume equal variances and simple random sampling.