Statistics

Dive into Deep Learning · §36.5

Point Estimation, Hypothesis Testing, Confidence Intervals, and the Bootstrap
sampling distributions · bias–variance triangle · Monte Carlo · permutation & z-tests · statistical power · confidence intervals · bootstrap

Is 921/1,000 Truly Better Than 912/1,000?

Motivation

  • The 1,000-question test set: Classifier A scores 912/1000 (91.2\%) and Classifier B scores 921/1000 (92.1\%), with single-model standard error \mathrm{se} \approx 0.90\%.
  • Unpaired vs. paired comparison: Treated as two independent test sets, the +0.9\% gap is buried inside \mathrm{se} = 1.24\%; pairing on the same 1{,}000 questions cancels shared item difficulty and cuts required labels 9\times.

Estimators and Their Sampling Distribution

Fluctuations Across Hypothetical Datasets

An estimator \hat{\theta}_n = T(x_1, \dots, x_n) is any rule that maps a random sample of size n to a parameter estimate. Its distribution across repeated draws of the entire dataset is its sampling distribution:

  • Test accuracy as a sample proportion: Let x_i \in \{0, 1\} indicate whether question i is answered correctly (x_i \stackrel{\text{i.i.d.}}{\sim} \mathrm{Bernoulli}(\theta)). The sample accuracy \hat{\theta}_n = \frac{1}{n}\sum_{i=1}^n x_i has exact moments: \mathbb{E}[\hat{\theta}_n] = \theta, \qquad \mathrm{Var}(\hat{\theta}_n) = \frac{\theta(1 - \theta)}{n}, \qquad \mathrm{se}(\hat{\theta}_n) = \sqrt{\frac{\theta(1 - \theta)}{n}}
  • Simulating 10{,}000 independent test sets of size n = 1{,}000 at true accuracy \theta = 0.912:
mean 0.9119, std 0.0089, formula 0.0090

The fundamental mental model of frequentist statistics: We actually observe only one test set, but we evaluate the trustworthiness of our rule by analyzing how it scatters across the 10{,}000 hypothetical test sets we did not draw.

Bias and Standard Error: Offset vs. Scatter

Two Distinct Modes of Estimation Error

  • Bias (systematic offset of the center from \theta): \mathrm{Bias}(\hat{\theta}_n) = \mathbb{E}[\hat{\theta}_n] - \theta \quad (\text{unbiased if } \mathrm{Bias} = 0\ \forall\theta)
  • Variance & Standard Error (width around \mathbb{E}[\hat{\theta}_n]): \mathrm{Var}(\hat{\theta}_n) = \mathbb{E}\Bigl[\bigl(\hat{\theta}_n - \mathbb{E}[\hat{\theta}_n]\bigr)^2\Bigr], \quad \mathrm{se}(\hat{\theta}_n) = \sqrt{\mathrm{Var}(\hat{\theta}_n)}
  • Benchmark (n = 30 draws from \mathcal{N}(1, 16)):
    • Sample mean \bar{x}: \mathrm{Bias} = 0, \mathrm{se} = 4/\sqrt{30} \approx 0.73.
    • Shrunk mean 0.65\,\bar{x}: \mathrm{Bias} = -0.35, \mathrm{se} = 0.65(0.73) \approx 0.47.
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Why Dividing by n Underestimates Variance

Bessel’s n − 1 Correction & Degrees of Freedom

\mathbb{E}\!\left[\sum_{i=1}^n (x_i - \bar{x})^2\right] = n\sigma^2 - n\,\mathrm{Var}(\bar{x}) = (n - 1)\sigma^2

  • Why \bar{x} shrinks residuals: The sample mean \bar{x} minimizes \sum_i (x_i - c)^2 for the sample in hand, making \sum_i (x_i - \bar{x})^2 smaller than \sum_i (x_i - \mu)^2 by exactly n(\bar{x} - \mu)^2.
  • Bessel’s correction (ddof=1): Dividing by n - 1 degrees of freedom makes s^2 = \frac{1}{n-1}\sum_{i=1}^n (x_i - \bar{x})^2 unbiased (\mathbb{E}[s^2] = \sigma^2).

The Bias–Variance Decomposition as Pythagoras

Orthogonal Error Decomposition

  • Mean Squared Error (MSE) measures total squared distance to the truth \theta: \mathrm{MSE}(\hat{\theta}_n) = \mathbb{E}\bigl[(\hat{\theta}_n - \theta)^2\bigr] = \mathrm{Bias}(\hat{\theta}_n)^2 + \mathrm{Var}(\hat{\theta}_n)
  • Proof & geometry: Set m = \mathbb{E}[\hat{\theta}_n] and split \hat{\theta}_n - \theta = (\hat{\theta}_n - m) + (m - \theta). Under the inner product \langle U, V \rangle = \mathbb{E}[UV], the zero-mean fluctuation \hat{\theta}_n - m is orthogonal to the constant bias m - \theta: \mathbb{E}\bigl[(\hat{\theta}_n - m)(m - \theta)\bigr] = (m - \theta)\,\underbrace{\mathbb{E}[\hat{\theta}_n - m]}_{0} = 0
  • Pythagorean hypotenuse: \sqrt{\mathrm{MSE}} = \sqrt{\mathrm{Bias}^2 + \mathrm{se}^2} (0.65\bar{x} has hypotenuse 0.59 < 0.73).

Empirical Ranking: Biased Shrinkage Beats Unbiased

Unbiased Does Not Mean Accurate

Comparing the sample mean \bar{x}, the shrunk mean 0.65\,\bar{x}, and the sample median across 10{,}000 datasets of n = 30 draws from \mathcal{N}(1, 16):

   estimator  bias^2    var    MSE predicted
        mean   0.000  0.532  0.532     0.533
 0.65 * mean   0.125  0.225  0.350     0.348
      median   0.000  0.805  0.805         -

Relative efficiency of the median vs. the mean: For Gaussian data, the sample median is unbiased by symmetry, but its asymptotic variance is \frac{\pi}{2}\frac{\sigma^2}{n} \approx 1.57\frac{\sigma^2}{n} (0.80 vs. 0.53 at n=30), giving it an efficiency of 2/\pi \approx 64\%.

Optimal Shrinkage and the Bias–Variance Trade-Off

Regularization in Miniature

  • For the shrunk estimator c\,\bar{x} (0 < c < 1), MSE is a sum of two parabolas in c: \mathrm{MSE}(c) = (1 - c)^2\theta^2 + c^2\frac{\sigma^2}{n}
  • Setting \frac{d}{dc}\mathrm{MSE}(c) = 0 yields the optimal shrinkage: c^\star = \frac{\theta^2}{\theta^2 + \sigma^2/n} < 1, \quad \mathrm{MSE}(c^\star) = \frac{\theta^2\,\sigma^2/n}{\theta^2 + \sigma^2/n} < \frac{\sigma^2}{n}
  • The catch: c^\star depends on unknown \theta (at \theta=1, c^\star \approx 0.65 gives \mathrm{MSE} = 0.35; if \theta=10, c=0.65 gives \mathrm{MSE} = 12.5 \gg 0.53). In d \ge 3 dimensions, data-driven James–Stein shrinkage \left(1 - \frac{d-2}{\|\mathbf{x}\|^2}\right)\mathbf{x} beats \mathbf{x} for every \boldsymbol{\theta}.
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Consistency and the Weak Law of Large Numbers

Asymptotic Convergence as n → ∞

An estimator \hat{\theta}_n is consistent (\hat{\theta}_n \xrightarrow{P} \theta) if P(|\hat{\theta}_n - \theta| > \varepsilon) \to 0 as n \to \infty for every tolerance \varepsilon > 0. Applying Markov’s inequality to (\hat{\theta}_n - \theta)^2 > \varepsilon^2 links consistency directly to MSE:

P\bigl(|\hat{\theta}_n - \theta| > \varepsilon\bigr) \le \frac{\mathrm{MSE}(\hat{\theta}_n)}{\varepsilon^2} = \frac{\mathrm{Bias}(\hat{\theta}_n)^2 + \mathrm{Var}(\hat{\theta}_n)}{\varepsilon^2}

  • Sufficient condition for consistency: If \mathrm{Bias}(\hat{\theta}_n) \to 0 and \mathrm{Var}(\hat{\theta}_n) \to 0 as n \to \infty, then \hat{\theta}_n \xrightarrow{P} \theta.
    • Consistent despite finite-n bias: Plug-in variance s_0^2 = \frac{n-1}{n}s^2 has bias -\sigma^2/n \to 0 and variance O(1/n) \to 0.
    • Inconsistent despite zero bias: First observation \hat{\theta}_n = x_1 has \mathrm{Bias} = 0 but \mathrm{Var} = \sigma^2 \not\to 0.
  • Proposition (Weak Law of Large Numbers): For i.i.d. x_1, \dots, x_n with mean \mu and variance \sigma^2 < \infty, \bar{x}_n has \mathrm{Bias} = 0 and \mathrm{Var}(\bar{x}_n) = \sigma^2/n, so P\bigl(|\bar{x}_n - \mu| > \varepsilon\bigr) \le \frac{\sigma^2}{n\,\varepsilon^2} \xrightarrow{n \to \infty} 0 \implies \bar{x}_n \xrightarrow{P} \mu

Monte Carlo Estimation vs. Deterministic Grids

Beating the Curse of Dimensionality

\hat{I}_N = \frac{1}{N}\sum_{i=1}^N g(\mathbf{x}_i), \qquad \mathrm{RMSE}(\hat{I}_N) = \frac{\sigma}{\sqrt{N}} = O\bigl(N^{-1/2}\bigr)

  • Curse of dimensionality on grids: A second-order midpoint grid of N = \epsilon^{-d} points has error O(\epsilon^2) = O(N^{-2/d}), collapsing in high dimensions.
  • Dimension-free Monte Carlo: Averaging N i.i.d. draws converges at \sigma N^{-1/2} in every dimension d, tying midpoint grids at d = 4 and winning for all d > 4.

Monte Carlo Convergence: Single Run vs. RMS Error

Empirical Verification of σ / √n

  • Estimating \int_0^1 e^{-x^2}\,dx = \mathbb{E}[e^{-U^2}] = \frac{\sqrt{\pi}}{2}\mathrm{erf}(1) \approx 0.746824 with U \sim \mathrm{Unif}(0, 1) (\sigma = \mathrm{sd}(e^{-U^2}) \approx 0.201):
    • n = 10^2: \sigma/\sqrt{n} \approx 2.0 \times 10^{-2}
    • n = 10^4: \sigma/\sqrt{n} \approx 2.0 \times 10^{-3}
  • Single run vs. ensemble RMS: A single running average wanders and dips sharply whenever its error crosses zero, whereas the root-mean-square error over 200 independent runs locks onto the theoretical \sigma/\sqrt{n} line of slope -1/2 across four orders of magnitude.

RMS error / (sigma/sqrt(n)) over all n: 0.87 to 1.08

Hypothesis Testing: Null Distribution & p-Values

Comparing Models Across Random Seeds

Suppose we train Model A and Model B across k = 20 random seeds each (seed standard deviation \sigma = 1.0\%, true improvement \mu_B - \mu_A = +0.8\%). Can we tell from the 40 numbers that Model B is better?

  • Null hypothesis (H_0): Both sets of accuracies come from the same distribution (\mu_A = \mu_B).
  • Alternative hypothesis (H_A): The distributions differ (\mu_A \ne \mu_B).
  • Permutation test (Fisher, 1935): Under H_0, the group labels "A" and "B" are meaningless. Pool all 40 scores, shuffle them into two groups of 20 across R permutations, and compute the two-sided p-value: p = \frac{1 + \#\bigl\{r : |\text{gap}_r| \ge |\text{gap}_{\text{obs}}|\bigr\}}{R + 1}

Vectorized Permutation Testing in Code

Distribution-Free Model Comparison

Vectorizing R random relabelings of the pooled accuracies and testing k = 20 seeds per model:

def perm_p(acc_a, acc_b, rng, R=2000):
    """Two-sided permutation p-value and the R shuffled gaps."""
    k = len(acc_a)
    observed = acc_b.mean() - acc_a.mean()
    pooled = np.tile(np.concatenate([acc_a, acc_b]), (R, 1))
    shuffled = rng.permuted(pooled, axis=1)    # R relabelings
    gaps = shuffled[:, k:].mean(1) - shuffled[:, :k].mean(1)
    p = (1 + (np.abs(gaps) >= abs(observed)).sum()) / (R + 1)
    return p, gaps
observed gap 0.0044, permutation p-value 0.158

Why +1 in the numerator and denominator matters: Treating the observed labeling as one of R + 1 exchangeable orderings under H_0 ensures the observed gap’s rank is uniform on \{1, \dots, R+1\}, guaranteeing P_{H_0}(p \le \alpha) \le \alpha.

The Parametric z-Test and Rejection Regions

Closed-Form Hypothesis Testing

  • For x_1, \dots, x_n \stackrel{\text{i.i.d.}}{\sim} \mathcal{N}(\mu, \sigma^2) with known \sigma, testing H_0 : \mu = 0 uses the standardized statistic: T = \frac{\bar{x}}{\sigma / \sqrt{n}} = \frac{\sqrt{n}\,\bar{x}}{\sigma} \;\underset{H_0}{\sim}\; \mathcal{N}(0, 1)
  • Two-sided p-value and critical threshold: p = 2\bigl(1 - \Phi(|T|)\bigr) \le \alpha \iff |T| \ge z_{1 - \alpha/2} At \alpha = 0.05, z_{0.975} \approx 1.96: we reject H_0 whenever \bar{x} falls more than 1.96 standard errors from 0.
  • Two-sample seed comparison: T = \frac{\bar{x}_B - \bar{x}_A}{\sigma\sqrt{2/k}} has \mathrm{se} = 0.01\sqrt{2/20} \approx 0.00316 (+0.008 is 2.53\,\mathrm{se}).
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Type I Error, Type II Error, and Statistical Power

The 2×2 Decision Matrix of an Experiment

  • Type I error (false positive, rate \alpha): Rejecting H_0 when H_0 is true (claiming a bogus improvement).
  • Type II error (false negative, rate \beta): Failing to reject H_0 when H_A is true (missing a real gain).
  • Statistical power (1 - \beta): Probability of detecting a true effect of size \delta: 1 - \beta = P(\text{reject } H_0 \mid H_A \text{ true})
  • Two classic p-value fallacies to avoid:
    1. p is P(\text{data this extreme} \mid H_0), not P(H_0 \mid \text{data}).
    2. p > 0.05 does not prove H_0 is true: an underpowered test (k = 5 seeds) routinely misses real gains.
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Why p-Values Are Uniform Under the Null

Exact Calibration of the False-Positive Rate

Proposition: If T has a continuous CDF F under H_0, then the one-sided p-value p = 1 - F(T) and two-sided p-value p = 2\min\{F(T), 1 - F(T)\} both follow \mathrm{Unif}(0, 1) under H_0, so P_{H_0}(p \le \alpha) = \alpha.

  • Proof: By the converse of inverse-transform sampling, U = F(T) satisfies P(U \le u) = P(T \le F^{-1}(u)) = F(F^{-1}(u)) = u, so U \sim \mathrm{Unif}(0, 1). Thus P(2\min\{U, 1-U\} \le \alpha) = P(U \le \alpha/2) + P(U \ge 1 - \alpha/2) = \alpha/2 + \alpha/2 = \alpha. \blacksquare
gap 0.000: 0.10 0.10 0.11 0.10 0.09 0.10 0.10 0.10 0.10 0.10   p <= 0.05: 0.05
gap 0.008: 0.82 0.08 0.04 0.02 0.01 0.01 0.01 0.01 0.01 0.01   p <= 0.05: 0.72

Power Analysis and Sample-Size Planning

Why 5 Seeds Miss Real Gains & the 1/δ² Scaling Law

  • Under H_A with standardized effect \delta = |\mu|/\sigma, T \sim \mathcal{N}(\delta\sqrt{n}, 1) rejects when T \ge z_{1-\alpha/2}, giving power: 1 - \beta \approx \Phi\bigl(\delta\sqrt{n} - z_{1-\alpha/2}\bigr)
  • Sample size for target power 1 - \beta (\alpha = 0.05, power 0.80 \implies z_{0.975} + z_{0.80} = 1.96 + 0.842 = 2.802): n = \frac{(z_{1-\alpha/2} + z_{1-\beta})^2}{\delta^2} \approx \frac{7.85}{\delta^2} (Doubled to k \approx \frac{15.7}{\delta^2} per group for a two-sample test).
  • At \delta = 0.8, 80\% power needs k = 25 seeds per model (k = 20 gives 72\% power; k = 5 gives only 24\%).
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Paired Comparisons: Stripping Out Shared Noise

Why Competing Models Must Share the Same Test Set

Evaluating Classifier A (912/1000) and Classifier B (921/1000) on the same 1{,}000 questions lets us analyze the per-question difference d_i = x_{B,i} - x_{A,i} \in \{-1, 0, +1\}. When 959 agreements have d_i = 0 and only 41 questions disagree (25 for B, 16 for A), the sign-flip permutation test flips signs on the 41 disagreements:

gap 0.009, sign-flip p-value 0.21
  • Massive sample-size savings (9\times fewer labels): Because \mathrm{Var}(X_B - X_A) = \mathrm{Var}(X_B) + \mathrm{Var}(X_A) - 2\,\mathrm{Cov}(X_B, X_A), positive correlation across shared questions slashes the noise. Detecting 91\% vs. 90\% accuracy when models disagree on 4\% of questions (\mathrm{Var}(d_i) \approx 0.0399) requires n \approx 3{,}100 paired questions vs. 13{,}500 unpaired questions per model (27{,}000 total).

Multiple Testing, p-Hacking, and Bonferroni

Controlling False Discoveries in Hyperparameter Sweeps

  • False-positive inflation: Testing m = 20 null models at \alpha = 0.05 produces at least one false discovery with probability 1 - 0.95^{20} \approx \mathbf{64.2\%}.
  • Bonferroni correction (\alpha/m): Rejecting only when p_j \le \alpha/m guarantees \mathrm{FWER} \le m(\alpha/m) = \alpha via the union bound, even for correlated tests.
  • Benjamini–Hochberg (FDR \le \alpha): Sorting p_{(1)} \le \dots \le p_{(m)} and finding the largest k with p_{(k)} \le \frac{k}{m}\alpha preserves power across large sweeps (m \gg 100).

Confidence Intervals: Procedure Hit Rate vs. Truth

Frequentist Coverage Guarantee

  • A 1 - \alpha confidence interval is a random interval C_n = [L(x_{1:n}), U(x_{1:n})] whose construction procedure traps the fixed parameter \theta with probability at least 1 - \alpha: P_\theta(C_n \ni \theta) \ge 1 - \alpha \quad \text{for every } \theta
  • Where the randomness lives: \theta is fixed; the interval C_n shifts from sample to sample. Out of 100 independent experiments, \sim 95 intervals cover \theta and \sim 5 miss.
  • Confidence vs. Credible (9/13 coin):
    • Frequentist 95\% Wald CI (0.44, 0.94): Procedure covers true fixed \theta in \approx 95\% of repeated experiments.
    • Bayesian 95\% credible interval (0.42, 0.87): Under \mathrm{Beta}(1,1) prior, P(\theta \in (0.42, 0.87) \mid x=9) = 0.95.
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Gaussian, Student-t, and Wald Confidence Intervals

Inverting the Sampling Distribution

Flipping the probability statement |\bar{x} - \mu| \le h \iff \mu \in [\bar{x} - h, \bar{x} + h] yields the confidence interval:

  • Known \sigma vs. estimated s: With known \sigma, h = z_{1-\alpha/2}\frac{\sigma}{\sqrt{n}} (1.96\frac{\sigma}{\sqrt{n}} at 95\%). Replacing \sigma by sample standard deviation s introduces extra denominator noise, so (\bar{x} - \mu)/(s/\sqrt{n}) \sim t_{n-1} requires the heavier-tailed Student-t quantile t_{n-1, 0.975} (12.71 at n=2; 2.776 at n=5; 1.984 at n=100 \to 1.96).
  • Wald interval for accuracy (\hat{\theta} \pm 1.96\sqrt{\hat{\theta}(1-\hat{\theta})/n}) and empirical coverage across 1{,}000 trials at n = 100:
912 of 1000: (0.894, 0.930)
  9 of   13: (0.441, 0.943)
first interval (-0.299, 0.098) contains 0: True
951 of 1000 intervals contain the true mean (nominal 950, exact 947)

Test–Interval Duality and the Delta Method

Inverting Tests & Propagating Error Bars Through Functions

1. Duality of Tests and Confidence Sets

  • A two-sided level-\alpha test of H_0 : \mu = \mu_0 fails to reject H_0 iff |\bar{x} - \mu_0| \le 1.96\frac{\sigma}{\sqrt{n}} \iff \mu_0 \in [\bar{x} - h, \bar{x} + h].
  • Universal inversion theorem: For any level-\alpha test of H_0 : \theta = \theta_0, collecting all non-rejected parameter values C_n = \bigl\{\theta_0 : \text{test of } H_0:\theta=\theta_0 \text{ does not reject}\bigr\} automatically forms an exact 1 - \alpha confidence set.
  • Fixing boundary overflow (29/30 correct): The Wald interval (0.90, 1.03) spills past 1.0, whereas inverting the exact binomial test keeps (0.83, 0.999) \subset [0, 1].

2. The Delta Method for Smooth Functions g(\hat{\theta})

  • How does uncertainty in \hat{\theta} propagate to g(\hat{\theta}) (e.g., log-odds)? Linearizing g(\hat{\theta}) \approx g(\theta) + g'(\theta)(\hat{\theta} - \theta) rescales the standard error by the local slope: \mathrm{se}\bigl(g(\hat{\theta})\bigr) \approx \bigl|g'(\hat{\theta})\bigr|\,\mathrm{se}(\hat{\theta}) (or \mathrm{Var}(g(\hat{\boldsymbol{\theta}})) \approx \nabla g^\top \boldsymbol{\Sigma}\nabla g for vectors).
  • Log-odds of \hat{\theta} = 0.90 (n = 1{,}000, \mathrm{se} = 0.0095): Since g(\theta) = \log\frac{\theta}{1-\theta} has derivative g'(0.9) = \frac{1}{0.9 \times 0.1} \approx 11.11, \mathrm{se}(\text{log-odds}) \approx 11.11 \times 0.0095 \approx \mathbf{0.105}.

The Non-Parametric Bootstrap: Plug-In Resampling

Error Bars Where No Closed-Form Formula Exists

  • Efron’s plug-in principle (1979): Replace the unknown true distribution F by the empirical distribution \hat{F}_n (mass 1/n on each observed point x_i).
  • Three-step algorithm:
    1. Draw n points from \{x_1, \dots, x_n\} with replacement.
    2. Recompute the statistic \hat{\theta}^*_r on resample r.
    3. Repeat R times; use \mathrm{sd}(\hat{\theta}^*_{1:R}) as \mathrm{se}(\hat{\theta}) and the 2.5\% and 97.5\% quantiles as the 95\% percentile CI.
  • Works automatically for complex metrics (median, AUC, F1, BLEU) when observations are i.i.d. and the functional is smooth.
image/svg+xml Matplotlib v3.11.2, https://matplotlib.org/

Bootstrap Verification and Two Classic Failures

When Resampling Succeeds and When It Breaks

  • Success on smooth statistics: Recovers the exact 0.0090 accuracy SE and estimates the \mathrm{Exp}(1) median SE (\approx 0.071) without knowing the density f(m):
bootstrap se 0.0090, formula 0.0090
median 0.741, bootstrap se 0.090, 95% percentile interval (0.636, 0.993)
  • Failure 1: Non-smooth extremes (\hat{\theta} = \max_i x_i on U(0, \theta)): Every resample has \hat{\theta}^* \le \hat{\theta} < \theta (0\% CI coverage) and piles mass at the sample maximum: P(\hat{\theta}^* = \hat{\theta}) = 1 - \left(1 - \frac{1}{n}\right)^n \xrightarrow{n \to \infty} 1 - \frac{1}{e} \approx 0.632
  • Failure 2: Clustered benchmarks (G passages \times m questions, within-passage correlation \rho): \mathrm{Var}(\hat{\theta}) = \frac{\theta(1 - \theta)}{Gm}\bigl(1 + (m - 1)\rho\bigr) At m = 20, \rho = 0.1, resampling individual questions understates \mathrm{se} by \sqrt{2.9} \approx \mathbf{1.7\times}. Fix: Cluster-bootstrap whole passages.

Concept Check: Bessel’s Correction, Power & Bootstrap

Check Your Understanding

Test your understanding on three practical statistical design problems:

  1. Sample size for a target effect: Using n \approx 7.85/\delta^2 (\alpha = 0.05, 80\% power), how many independent observations are needed to detect a standardized effect of \delta = 0.5? How many if \delta shrinks fivefold to \delta = 0.1?
  2. Clustered benchmark error bars: A vision benchmark has G = 200 videos with m = 16 frames per video. Frame predictions within the same video have correlation \rho = 0.2. By what factor does a naive frame-level bootstrap understate the true standard error?
  3. Why a single sample maximum repeats in 63.2\% of resamples: In a sample of n distinct points, what is the probability that a particular observation x_i is never selected in a bootstrap resample of size n as n \to \infty?

Answers:

  1. At \delta = 0.5, n \approx 7.85 / 0.25 \approx \mathbf{32} observations. Shrinking \delta by 5\times to 0.1 requires 5^2 = 25\times more data: n \approx 7.85 / 0.01 = \mathbf{785} observations.
  2. The variance inflation factor is 1 + (m - 1)\rho = 1 + 15(0.2) = 4.0, so the naive frame-level bootstrap understates the true standard error by \sqrt{4.0} = 2.0\times.
  3. Each of the n draws misses x_i with probability 1 - 1/n, so all n draws miss x_i with probability (1 - 1/n)^n \to e^{-1} \approx 36.8\% (meaning each resample includes \approx 63.2\% of the unique original points).

Summary: Statistical Estimation and Testing

Key Takeaways

Statistical Tool Mathematical Formula / Rule Benchmark Value in §36.5 Deep Learning Engineering Role
Sample Proportion \hat{\theta}_n \mathbb{E}[\hat{\theta}_n] = \theta, \mathrm{se}(\hat{\theta}_n) = \sqrt{\theta(1-\theta)/n} 912/1000 \implies 91.2\% \pm 0.90\% (\mathrm{se}) Error bars on classification test accuracy
Unbiased Variance s^2 s^2 = \frac{1}{n-1}\sum_{i=1}^n (x_i - \bar{x})^2 (ddof=1) Dividing by n has bias -\sigma^2/n Estimating seed-to-seed variance at small k
Bias–Variance Triangle \mathrm{MSE}(\hat{\theta}_n) = \mathrm{Bias}(\hat{\theta}_n)^2 + \mathrm{Var}(\hat{\theta}_n) Shrunk mean 0.65\bar{x} (0.35) beats \bar{x} (0.53) Regularization, shrinkage & model complexity
Monte Carlo Integration \mathrm{RMSE}(\frac{1}{N}\sum_{i=1}^N g(\mathbf{x}_i)) = \sigma / \sqrt{N} Beats 2nd-order grids (N^{-2/d}) for d > 4 High-d loss, ELBO & gradient estimation
Permutation & Paired Tests p = \frac{1 + \#\{\|\text{gap}_r\| \ge \|\text{gap}_{\text{obs}}\|\}}{R+1}; P_{H_0}(p \le \alpha) \le \alpha Pairing cuts 90\%\text{ vs. }91\% budget 9\times Comparing models across shared test sets/seeds
Power & Sample Size 1 - \beta \approx \Phi(\delta\sqrt{n} - z_{1-\alpha/2}); n \approx 7.85/\delta^2 \delta = 0.8: k=25 seeds (80\%), k=5 (24\%) Sizing ablation budgets & Bonferroni (\alpha/m)
Confidence Intervals & Bootstrap P_\theta(C_n \ni \theta) \ge 1-\alpha; resample n with replacement \bar{x} \pm t_{n-1, 0.975}s/\sqrt{n}; cluster-resample groups Valid uncertainty for accuracy, log-odds & F1/BLEU