Maximum Likelihood, Fisher Information, and MAP Estimation likelihood & NLL · KL floor · noise models · score & Fisher information · Cramér–Rao bound · MAP & priors
Nine Heads in Thirteen Flips: Why 9/13?
Motivation & Core Problem
What principle singles out \hat{\theta} = 9/13 \approx 0.692? Why is empirical frequency the right estimator, and how does the same principle define losses for 10^9-parameter networks?
How tightly do 13 flips pin down \theta? Curvature 1/\sqrt{nI(\hat{\theta})} \approx 0.128 yields a 95\% interval [0.44, 0.94] that still spans a fair coin (\theta = 0.5).
What if 3 flips land \mathrm{HHH}? Priors (MAP) regularize small samples so tails are never declared impossible (\hat{\theta} = 1).
Probability vs. likelihood: Fixing \boldsymbol{\theta} and varying X gives a normalized distribution over datasets; fixing observed X and varying \boldsymbol{\theta} gives the likelihood (which does not integrate to 1 over \boldsymbol{\theta}).
Frequentist view:\boldsymbol{\theta} is a fixed unknown constant; the MLE picks the parameter vector under which the observed dataset X was most probable.
Worked Example: The Coin Likelihood
Bernoulli Maximum Likelihood
Independent flips multiply: For n_H heads and n_T tails, the likelihood is P(X \mid \theta) = \theta^{n_H}(1-\theta)^{n_T}.
Sample size sharpens curvature: Scaling from 9/13 to 90/130 leaves the peak at \hat{\theta} = 9/13 \approx 0.69, but narrows the likelihood curve by \sqrt{10} \approx 3.2\times.
Underflow of products: Multiplying 10^9 factors near 1/2 gives (1/2)^{10^9} = \texttt{0.0} in float32 and float64, destroying all gradient signal.
Additive NLL & SGD: Taking -\log turns products into a well-conditioned sum whose gradient decouples into unbiased minibatch averages.
Minimizing the NLL by Gradient Descent
Numerical Optimization
Even when a closed-form solution exists, we can minimize the coin NLL \ell(\theta) = -\bigl(n_H \log \theta + n_T \log(1-\theta)\bigr) numerically on n_H = 8{,}675{,}309 heads and n_T = 256{,}245 tails:
Systems Pitfall (Summed vs. Averaged Loss): Because \ell(\theta) is summed over n \approx 8.9 \times 10^6 flips, its gradient carries a factor of n, forcing a tiny learning rate lr = 1e-9. Dividing by n to minimize the average NLL \frac{1}{n}\ell(\boldsymbol{\theta}) keeps the stable step size independent of batch or dataset size.
Why training curves plateau above zero: The empirical entropy H(\hat{p}_{\mathrm{data}}) is fixed by the data (0.617 nats for 9/13 heads).
MLE as forward KL projection: Minimizing average NLL is equivalent to driving D_{\mathrm{KL}}(\hat{p}_{\mathrm{data}} \,\|\, p_{\boldsymbol{\theta}}) \ge 0 as close to zero as the model family allows.
MLE as Forward KL Divergence Minimization
Geometry of Cross-Entropy
Irreducible data floor: For 9 heads and 4 tails, the empirical entropy floor is H(9/13) = 0.617 nats, touched only at \hat{\theta} = 9/13.
KL penalty of misspecified parameters: A fair coin (\theta = 0.5) incurs \log 2 = 0.693 nats (0.076 nats of KL divergence); \theta = 0.9 incurs 0.164 nats of KL gap.
Classification training vs. test floor: When each training input \mathbf{x}_i is unique, its empirical label distribution is one-hot (H = 0), so overparameterized networks can drive training NLL to 0 while held-out test NLL stays bounded below by H(Y \mid X).
Continuous Data and Differential Entropy
Continuous Likelihoods
For continuous observations x_1, \dots, x_n drawn from a density p(x \mid \boldsymbol{\theta}), the probability of hitting any exact real number is zero. We instead require each observation to match within a small tolerance \epsilon > 0:
Precision tolerance drops out: The additive constant -n\log\epsilon does not depend on \boldsymbol{\theta}, so minimizing the negative log-density -\sum_i \log p(x_i \mid \boldsymbol{\theta}) is independent of \epsilon.
Densities can exceed 1 (and NLL can be negative): Because only \epsilon\,p(x \mid \boldsymbol{\theta}) is a dimensionless probability, a narrow density with small variance \sigma^2 \ll 1 has p(x \mid \boldsymbol{\theta}) > 1 and \log p > 0.
Population KL objective: At the population level under true density p_\star, \mathbb{E}_{x \sim p_\star}[-\log p(x \mid \boldsymbol{\theta})] = h(p_\star) + D_{\mathrm{KL}}(p_\star \,\|\, p_{\boldsymbol{\theta}}), where h(p_\star) = -\int p_\star(x)\log p_\star(x)\,dx is the differential entropy.
Noise Models Dictate Training Losses
Probabilistic Loss Functions
Assuming targets follow y_i = f_{\boldsymbol{\theta}}(\mathbf{x}_i) + \varepsilon_i with Gaussian noise \varepsilon_i \sim \mathcal{N}(0, \sigma^2) yields -\log \prod_i \mathcal{N}(y_i; \hat{y}_i, \sigma^2) = \frac{1}{2\sigma^2}\sum_i (y_i - \hat{y}_i)^2 + \frac{n}{2}\log(2\pi\sigma^2). Every standard training loss corresponds to a conditional noise distribution p(y \mid \mathbf{x}):
Not every loss is a negative log-likelihood: the SVM hinge loss \max(0, 1 - y\hat{y}) lacks a finite normalizing constant Z(\hat{y}) = \sum_{y \in \{\pm 1\}} e^{-\phi(y,\hat{y})} independent of the model output \hat{y}.
Gaussian vs. Laplace Noise Under Outliers
Robustness & Tail Behavior
Sensor readings \{1, 2, 3, 4, 100\}: Suppose we fit a single constant c when the fifth reading is a corrupted outlier.
Gaussian NLL (quadratic): Minimizing \frac{1}{2}\sum_i (y_i - c)^2 sets \sum_i (c - y_i) = 0, pulling the estimate to the sample meanc = 22 because the gradient grows linearly with the residual.
Laplace NLL (piecewise linear): Minimizing \sum_i \lvert y_i - c\rvert gives every point unit slope \pm 1 regardless of distance, anchoring the estimate at the sample medianc = 3.
Why the mean score vanishes at \boldsymbol{\theta}^\star: Using \nabla_{\boldsymbol{\theta}} p = p\,\nabla_{\boldsymbol{\theta}} \log p, differentiating \int p(x \mid \boldsymbol{\theta})\,dx = 1 under the integral sign gives \mathbb{E}_{\boldsymbol{\theta}}[s(x; \boldsymbol{\theta})] = \nabla_{\boldsymbol{\theta}} 1 = \mathbf{0}.
The information identity: Differentiating \int s(x;\boldsymbol{\theta})p(x\mid\boldsymbol{\theta})\,dx = \mathbf{0} once more by the product rule proves \mathbb{E}[\nabla^2 \log p] + \mathbb{E}[s\,s^\top] = \mathbf{0}.
Duality: Fisher information simultaneously equals the variance of the per-example gradient and the expected curvature (Hessian) of the NLL.
Fisher Information Across Three Models
Concrete Fisher Matrices
Bernoulli coin:s(x;\theta) = \frac{x}{\theta} - \frac{1-x}{1-\theta} and -s'(x;\theta) = \frac{x}{\theta^2} + \frac{1-x}{(1-\theta)^2}, so taking expectations with \mathbb{E}[x] = \theta gives: I(\theta) = \frac{1}{\theta(1-\theta)}
Gaussian \mathcal{N}(\mu, \sigma^2):I(\mu, \sigma) = \operatorname{diag}\bigl(\frac{1}{\sigma^2},\, \frac{2}{\sigma^2}\bigr), so the NLL curves twice as sharply along \sigma as along \mu.
Cauchy location: For p(x\mid\theta) = \frac{1}{\pi(1+(x-\theta)^2)}, setting x-\theta = \tan\varphi gives s = \sin 2\varphi and I(\theta) = \mathbb{E}[\sin^2 2\varphi] = \frac{1}{2}.
Verifying the Information Identity via Autodiff
Automatic Differentiation
When closed-form integration is tedious, per-example automatic differentiation of the score and its derivative evaluates both forms of the Fisher information directly on 10{,}000 Cauchy draws at \theta^\star = 0:
mean score 0.004, variance of score 0.498, -mean curvature 0.502
Although the Cauchy distribution has tails so heavy that its mean and variance do not exist, its score s(x;\theta) = \frac{2(x-\theta)}{1+(x-\theta)^2} is bounded in [-1, 1], yielding finite Fisher information I = 0.5 and down-weighting extreme outliers automatically.
Fair coin is not ruled out: The 95\% CI [0.44, 0.94] includes \theta = 0.5; shrinking the half-width to \pm 0.05 requires n \approx 330 flips.
Consistency of the Maximum Likelihood Estimator
Large-Sample Convergence
Before analyzing fluctuations around \boldsymbol{\theta}^\star, we must ensure that \hat{\boldsymbol{\theta}}_n \xrightarrow{P} \boldsymbol{\theta}^\star as n \to \infty. By the Law of Large Numbers, the empirical average NLL converges to the population cross-entropy:
Four conditions for consistency: (1) i.i.d. data from p_{\boldsymbol{\theta}^\star}, (2) identifiability(p_{\boldsymbol{\theta}} = p_{\boldsymbol{\theta}^\star} \implies \boldsymbol{\theta} = \boldsymbol{\theta}^\star), (3) a well-separated population minimum, and (4) uniform convergence of \frac{1}{n}\ell(\boldsymbol{\theta}) over \boldsymbol{\theta}.
Why pointwise convergence is not enough: The LLN holds at each fixed \boldsymbol{\theta}, but guaranteeing that the minimizer of the random curve converges to the minimizer of the limit curve requires uniform convergence.
Non-identifiability in deep networks: Permuting hidden units or rescaling ReLU layers changes \boldsymbol{\theta} without changing the predictive distribution p_{\boldsymbol{\theta}}(y \mid \mathbf{x}).
2. CLT over LLN: By the CLT, S_n(\theta^\star)/\sqrt{n} \xrightarrow{d} \mathcal{N}(0, I(\theta^\star)); by the LLN, -S_n'(\theta^\star)/n \xrightarrow{P} I(\theta^\star), yielding variance I / I^2 = 1/I.
Fisher Scoring on the Cauchy Location Model
Empirical Verification
Why plain Newton fails on Cauchy: Away from the minimum, the observed Cauchy second derivative \frac{2(1-u^2)}{(1+u^2)^2} turns negative for \lvert u\rvert > 1, sending Newton steps uphill.
Fisher scoring: Replacing observed curvature with expected curvature nI = n/2 > 0 gives the stable update \theta \leftarrow \theta + \frac{2}{n}S_n(\theta).
Exact match at n = 100: Across 4{,}000 datasets, the histogram of \sqrt{n}(\hat{\theta} - \theta^\star) tracks \mathcal{N}(0, 1/I) = \mathcal{N}(0, 2)(\mathrm{sd} \approx \sqrt{2} \approx 1.41).
standard deviation of sqrt(n) * theta_hat: 1.43
The Cramér–Rao Lower Bound and Efficiency
Optimality of the MLE
Can any unbiased estimator (\mathbb{E}_\theta[\tilde{\theta}] = \theta for all \theta) achieve a variance smaller than \frac{1}{nI(\theta)}? Differentiating \int \tilde{\theta}(X)\,P(X \mid \theta)\,dX = \theta under the integral sign with \partial_\theta P = P\,S_n yields:
Squaring both sides establishes the Cramér–Rao bound\operatorname{Var}(\tilde{\theta}) \ge \frac{1}{nI(\theta)}, proving that the MLE is asymptotically efficient. Comparing three Cauchy location estimators across our 4{,}000 datasets confirms the gap:
n Var(MLE) = 2.06, n Var(median) = 2.50, n Var(mean) = 7.79e+05
When Classical MLE Theory Breaks Down
Statistical Pitfalls & Misspecification
Each regularity condition behind asymptotic normality and the Cramér–Rao bound can fail in real workflows:
Finite-sample bias & boundaries: The Gaussian variance MLE divides by n(\mathbb{E}[\hat{\sigma}^2] = \frac{n-1}{n}\sigma^2); on linearly separable logistic regression data or \mathrm{HHH} coin flips, the NLL infimum sits at \pm\infty or on the boundary.
Parameter-dependent support: For \mathrm{Uniform}(0, \theta), \hat{\theta} = \max_i x_i converges at rate 1/n rather than 1/\sqrt{n}, and \frac{n+1}{n}\hat{\theta} achieves variance O(1/n^2), beating the formal Cramér–Rao formula because differentiation under the integral sign fails at the moving boundary x = \theta.
Singular Fisher matrix in ReLU networks: Rescaling (a_j, w_j) \mapsto (c a_j, w_j/c) leaves a_j \mathrm{ReLU}(w_j x) invariant, creating zero eigenvalues in I(\boldsymbol{\theta}) so I(\boldsymbol{\theta})^{-1} does not exist.
Misspecification and the sandwich covariance: When the true data law p_\star \notin \{p_{\boldsymbol{\theta}}\}, the MLE converges to the KL projection \boldsymbol{\theta}^\dagger, but score variance \mathbf{B} = \mathbb{E}[s\,s^\top] no longer equals expected curvature \mathbf{A} = -\mathbb{E}[\nabla^2 \log p], yielding the Huber–White sandwich covariance\sqrt{n}(\hat{\boldsymbol{\theta}} - \boldsymbol{\theta}^\dagger) \xrightarrow{d} \mathcal{N}(\mathbf{0}, \mathbf{A}^{-1}\mathbf{B}\mathbf{A}^{-1}).
Zero-count collapse of MLE: On 3 heads (\mathrm{HHH}),\hat{\theta}_{\mathrm{MLE}} = 3/3 = 1, assigning infinite NLL (-\log 0 = \infty) to the first future tail.
MAP regularization: A \mathrm{Beta}(2,2) prior adds 1 virtual head and 1 virtual tail, pulling \hat{\theta}_{\mathrm{MAP}} to 4/5 = 0.80(1.61 nats on a future tail).
Gaussian and Laplace Priors Yield L2 and L1 Penalties
Laplace prior \toL_1 sparsity:p(\boldsymbol{\theta}) \propto e^{-\|\boldsymbol{\theta}\|_1 / s} adds \frac{1}{s}\|\boldsymbol{\theta}\|_1, whose kink at 0 drives small weights to exact zeros.
Asymptotic fade-out: As n \to \infty or \tau \to \infty, \lambda \to 0 and MAP converges back to the MLE.
Beta Priors, Pseudo-Counts, and Reparameterization
Conjugate Priors & Equivariance
Multiplying the coin likelihood \theta^{n_H}(1-\theta)^{n_T} by a conjugate \mathrm{Beta}(a,b) prior \propto \theta^{a-1}(1-\theta)^{b-1} yields the \mathrm{Beta}(n_H + a,\, n_T + b) posterior \propto \theta^{n_H+a-1}(1-\theta)^{n_T+b-1}:
\hat{\theta}_{\mathrm{MAP}} = \frac{n_H + a - 1}{n + a + b - 2} \qquad \text{vs.} \qquad \mathbb{E}[\theta \mid X] = \frac{n_H + a}{n + a + b}
Add-one smoothing is a posterior mean: Under the flat prior \mathrm{Beta}(1,1), the posterior mean is Laplace’s rule of succession \frac{n_H+1}{n+2}, whereas the flat-prior MAP estimate is just the raw MLE \frac{n_H}{n} (which requires \mathrm{Beta}(2,2) to reach \frac{n_H+1}{n+2}).
MAP is not invariant to reparameterization: Under a change of variables \eta = g(\theta), the posterior density picks up the Jacobian factor \lvert d\theta / d\eta\rvert. A flat \mathrm{Beta}(1,1) prior in \theta becomes the logistic density e^{-\eta}/(1+e^{-\eta})^2 in log-odds \eta = \log\frac{\theta}{1-\theta}, shifting the MAP estimate for 9/13 to 10/15 = 2/3.
MLE is equivariant: Because the likelihood has no Jacobian factor, the MLE of g(\theta) is always g(\hat{\theta}_{\mathrm{MLE}}).
Concept Check: Maximum Likelihood, Fisher, and MAP
Check Your Understanding
Sample size from Fisher curvature: A coin shows 9 heads in 13 flips (\hat{\theta} \approx 0.69). How many flips are required to shrink the 95\% confidence interval \hat{\theta} \pm 1.96/\sqrt{nI(\hat{\theta})} to a half-width of \pm 0.05?
Three estimators after \mathrm{HHH}: For 3 heads in 3 flips, what are the MLE, the MAP estimate under \mathrm{Beta}(2,2), and the posterior mean under \mathrm{Beta}(1,1)?
Misspecified Fisher information: Suppose we fit a Poisson model (\operatorname{Var}(X) = \lambda) to overdispersed counts with true mean m = 4 and variance m + m^2/\alpha = 12(\alpha = 2). By what factor does (nI)^{-1} underestimate \operatorname{Var}(\hat{\lambda}_{\mathrm{MLE}})?
Answers:
Setting 1.96\sqrt{0.69(0.31)/n} = 0.05 gives n = \frac{1.96^2 \cdot 0.2139}{0.05^2} \approx 329 flips—roughly 25\times more data to shrink the error bar by 2.5\times.
\hat{\theta}_{\mathrm{MLE}} = 1; \hat{\theta}_{\mathrm{MAP}} = \frac{3+2-1}{3+2+2-2} = \frac{4}{5}; and \mathbb{E}[\theta \mid X] = \frac{3+1}{3+1+1} = \frac{4}{5} (Laplace’s rule of succession).
The Poisson MLE is \bar{X}, with true variance 12/n, whereas Poisson Fisher information I = 1/\lambda predicts 4/n—underestimating the true variance by a factor of 1 + m/\alpha = 3 (corrected by the sandwich variance B/A^2).