# A/B Testing Power Analysis, Simpson’s Paradox & Correlation vs Causality Traps
Exam: GATE Data Science & Artificial Intelligence (DA) (GATE DA)
Subject: Data Science, Statistics & Data Warehousing
Canonical URL: https://gateandnet.com/exams/gate-da/data-science/experimental-design-ab-testing-and-time-series

> Sample size scaling in online A/B experiments, Bonferroni multiple-testing correction, Pearson linear vs Spearman rank correlation, Anscombe’s quartet, and Simpson’s confounding paradox.

## 1. Online Controlled Experiments (A/B Testing) & Multiple Comparisons

- **Statistical Power ($1 - \beta$):** Probability of correctly rejecting $H_0$ when a real effect $\delta \neq 0$ exists (standard industry target: $\alpha = 0.05$, Power $1 - \beta = 0.80$).
- **Multiple Testing ($p$-Hacking) Trap:** Testing $m = 20$ independent metrics at $\alpha = 0.05$ when all null hypotheses are true gives family-wise false positive probability:

$$
P(\text{at least 1 false positive}) = 1 - (1 - 0.05)^{20} \approx \mathbf{0.642 \; (64.2\%)}!
$$

- **Bonferroni Correction:** Test each individual hypothesis at $\alpha_{\text{adj}} = \alpha / m$ to guarantee Family-Wise Error Rate $\text{FWER} \le \alpha$ (or use Benjamini-Hochberg to control False Discovery Rate).

## 2. Classic Correlation & Aggregation Traps

1. **Zero Correlation $\neq$ Independence:** $X$ and $Y$ independent $\implies \operatorname{Cov}(X,Y) = 0 \implies r_{XY} = 0$, **EXCEPT** the converse is **FALSE**! Example: $X \in \{-1, 0, +1\}$ equally likely and $Y = X^2 \implies \mathbb{E}[XY] = \mathbb{E}[X^3] = 0 = \mathbb{E}[X]\mathbb{E}[Y]$, so $r_{XY} = 0$ even though $Y$ is $100\%$ determined by $X$! *(Exception: For **Bivariate Normal** $(X,Y)$, $\rho = 0 \iff$ Independent!)*
2. **Pearson ($r$) vs Spearman ($r_s$):** For strictly monotonic non-linear $Y = e^X$, Spearman rank correlation is **$r_s = +1.0$**, whereas Pearson $r < 1$.
3. **Simpson’s Paradox:** A trend present inside *every subgroup* ($A$ beats $B$ in both Easy and Hard patient cohorts) **reverses direction** when groups are aggregated because a **confounder** $Z$ affects both treatment assignment and base outcome rate!

## Solved Practice Questions & PYQs

### [GATE DA A/B Testing | MCQ]
In an online A/B test with fixed significance $\alpha = 0.05$ and power $1 - \beta = 0.80$, you decide to detect a **Minimum Detectable Effect (MDE)** half as small ($\delta_{\text{new}} = \delta / 2$). How does the required sample size $n$ per variant change?
**Correct Answer:** B
**Solution:** Because standard error scales as $\sigma / \sqrt{n}$, sample size scales inversely with the **square** of MDE: $n \propto \frac{\sigma^2}{\delta^2}$. Halving $\delta$ multiplies required traffic by **$4\times$**!
