Lesson overview | Previous part | Next part
Estimation Theory: Part 6: Method of Moments to Appendix L: Worked Examples - End-to-End Estimation
6. Method of Moments
6.1 The Method of Moments
The method of moments (MoM), introduced by Karl Pearson (1894), is the oldest systematic estimation procedure. The idea is simple: match sample moments to population moments and solve for .
Definition 6.1 (Method of Moments Estimator). For a -parameter model, the MoM estimator solves the system:
where is the -th sample moment.
Example: Normal distribution. For with 2 parameters:
- 1st moment equation:
- 2nd moment equation:
For the Gaussian, MoM and MLE coincide.
Example: Gamma distribution. with mean and variance .
Solving: , . Unlike the Gaussian case, the Gamma MLE requires numerical optimisation, making MoM attractive for quick estimation.
Example: Beta distribution. with mean and variance .
Setting and , solving the moment equations:
This requires (the variance must be less than the theoretical maximum for the Beta).
Properties of MoM:
- Consistent: by the LLN, sample moments converge to population moments; moment equations are continuous, so MoM estimators are consistent
- Asymptotically normal: by the multivariate CLT and delta method
- Inefficient: generally does not achieve the CRB; MLE has smaller asymptotic variance when it exists in closed form
6.2 Generalised Method of Moments
The Generalised Method of Moments (GMM), introduced by Hansen (1982), allows for more moment conditions than parameters.
Suppose we have moment conditions , where and (over-identified system).
Sample moment conditions:
When , we cannot set all conditions to zero simultaneously. The GMM estimator minimises the weighted quadratic form:
for some positive-definite weighting matrix . The optimal weight matrix (minimising asymptotic variance) is where .
GMM is widely used in econometrics. In ML, it appears implicitly when models are estimated by matching distributional moments rather than maximising likelihood.
6.3 MoM vs MLE
| Property | Method of Moments | Maximum Likelihood |
|---|---|---|
| Computational | Often closed-form | May require numerical optimisation |
| Asymptotic efficiency | Generally inefficient | Efficient (achieves CRB) |
| Consistency | Yes | Yes (under regularity conditions) |
| Robustness | Depends only on moments | Can be sensitive to tail misspecification |
| Applicability | Works even when likelihood is intractable | Requires tractable likelihood |
| Parameter constraints | Can produce invalid estimates (e.g., ) | Respects constraints if optimised on |
When to prefer MoM:
- The likelihood is intractable (latent variable models without EM)
- Speed matters more than efficiency
- Only the first few moments are of interest
- The distributional assumption may be wrong (moments are more robust)
When to prefer MLE:
- Full likelihood is tractable and the model is well-specified
- Maximum statistical efficiency is needed
- Regularity conditions are satisfied
- A standard reference distribution is being fitted
7. Confidence Intervals
7.1 The Frequentist Interpretation
Definition 7.1 (Confidence Interval). A random interval is a confidence interval for if:
The key is that and are random (functions of the data ), while is fixed (unknown but not random in the frequentist framework).
The correct interpretation: If we repeat the experiment many times and construct a 95% CI each time, 95% of those intervals will contain the true . This specific computed interval either contains or it does not - there is no 95% probability attached to this particular interval after observing data.
Common misconceptions:
| Incorrect statement | Why it's wrong |
|---|---|
| "There is a 95% probability that ." | After computing the interval, is either in it or not - no probability remains |
| "95% of the data lies within the CI." | CIs are about the parameter, not the data distribution |
| "If I repeat the experiment, my estimate will be in this CI 95% of the time." | The CI is about the parameter being covered, not about future estimates |
| "A wider CI means I'm 95% more confident." | Width affects precision but all 95% CIs have the same coverage probability |
The Bayesian analogue - "there is a 95% probability that is in this interval" - is a credible interval and requires a prior distribution on . The full treatment is in Section04 Bayesian Inference.
7.2 Exact Confidence Intervals via Pivoting
The pivotal method constructs CIs by finding a pivot: a function of data and parameter whose distribution is known and does not depend on .
Gaussian mean, known. Let .
The pivot is .
Solving for : the CI is .
Gaussian mean, unknown. Replacing with the sample standard deviation changes the distribution: (Student's with degrees of freedom).
CI:
As , (Student's converges to standard normal).
STUDENT'S t DISTRIBUTION vs. NORMAL
========================================================================
p(t)
|
| --- Normal(0,1)
| ==== t(df=5)
| - - - t(df=1) [Cauchy]
|
| +-----+ Heavier tails of t distribution
| ++ ++ reflect additional uncertainty
| ++ ++ from estimating \\sigma.
| --+ +--
|--------------------------- t
-3 -2 -1 0 1 2 3
For df \\geq 30, t \\approx Normal - practical "large sample" threshold.
========================================================================
Gaussian variance CI. The pivot is , giving the CI:
Note this CI is asymmetric because the distribution is skewed.
7.3 Asymptotic Confidence Intervals
When exact pivots are unavailable, use the asymptotic normality of MLE: for large , .
Wald interval. Plugging in the MLE for the unknown in the Fisher information:
For Bernoulli with observations: .
Limitations of the Wald interval near boundaries. For near 0 or 1, the Wald interval can extend outside . The Wilson score interval is better-behaved:
where . This is the standard CI for proportions in ML evaluation.
Likelihood ratio interval. Based on the likelihood ratio statistic , which satisfies under . The CI is the set of values that pass the test:
This is often more accurate than the Wald interval for small .
7.4 Bootstrap Confidence Intervals
The bootstrap (Efron, 1979) is a non-parametric resampling method for constructing CIs without distributional assumptions.
Non-parametric bootstrap algorithm:
- From the original sample , draw bootstrap samples (each of size , with replacement)
- Compute the statistic for each bootstrap sample
- Estimate the sampling distribution of by the empirical distribution of
Percentile bootstrap CI: Use the and quantiles of as CI endpoints.
BCa (bias-corrected and accelerated) bootstrap: Adjusts for bias in the bootstrap distribution and non-constant acceleration. Typically more accurate than the percentile method for small .
When to use bootstrap:
- The sampling distribution of is non-standard (no closed-form pivot)
- The distributional assumptions for parametric CIs are suspect
- The statistic is complex (e.g., ratio of two MLEs, AUC, BLEU score)
- is moderate and asymptotic approximations are poor
Bootstrap for ML evaluation (example). To compute a 95% CI for test accuracy:
- Let the test set be ; accuracy
- Bootstrap: resample with replacement times, compute accuracy on each bootstrap test set
- CI = [2.5th percentile, 97.5th percentile] of bootstrap accuracies
7.5 Confidence Intervals in ML Evaluation
Understanding CI coverage for ML evaluation prevents erroneous conclusions.
Binary accuracy. Test accuracy with examples and correct. Wilson score CI:
For , : CI = - width . For : CI = - width .
This shows why benchmark results on test examples are statistically unreliable.
Comparing two models. If Model A achieves and Model B achieves on the same test examples, is A significantly better? The difference with standard error gives a 95% CI for of , which includes zero. The models are not statistically distinguishable.
McNemar's test is more powerful than comparing independent CIs when models are evaluated on the same examples (the paired structure reduces variance). See Section03 Hypothesis Testing for the full treatment.
Multiple benchmark correction. When evaluating on benchmarks, the probability of at least one spuriously significant result rises. This is the multiple comparison problem - addressed fully in Section03. For reporting CIs, Bonferroni correction replaces with , widening each CI to maintain family-wise coverage.
8. Asymptotic Theory
8.1 Convergence Modes
Before stating the asymptotic normality theorem, we review the convergence modes used.
Almost-sure (a.s.) convergence (): . The sequence converges on every sample path except a set of probability zero. This is the strongest mode; the Strong LLN gives .
Convergence in probability (): For every , . Weaker than a.s. convergence. The Weak LLN gives . Sufficient for consistency.
Convergence in distribution (): at every continuity point of . The weakest mode; the CLT gives . Used for asymptotic normality.
Key theorems for manipulating convergence:
Slutsky's Theorem. If and (a constant), then:
- (if )
Continuous Mapping Theorem. If and is continuous, then . Same holds for .
Application: The MLE (consistency) implies by the continuous mapping theorem (assuming is continuous). Then by Slutsky: .
8.2 The Delta Method
The delta method extends the CLT to smooth functions of asymptotically normal estimators.
Theorem 8.2 (Delta Method - Scalar). Suppose and is differentiable at with . Then:
Proof sketch: By differentiability, . Multiply through by : .
Examples:
- CI for log-odds. For Bernoulli with , the log-odds are . The MLE is . The asymptotic variance: , . So:
- CI for standard deviation. Given (asymptotic variance of variance estimator), the delta method with , :
Multivariate delta method. If and is differentiable:
where is the Jacobian of at .
8.3 Asymptotic Normality of MLE
Theorem 8.3 (Asymptotic Normality of MLE). Under the Cramer-Rao regularity conditions, if is the MLE based on iid observations:
Proof sketch for the scalar case. Taylor-expand the score equation around :
Rearranging:
Numerator: . By CLT (scores are iid with mean 0 and variance ): .
Denominator: . By LLN: .
By Slutsky: .
Implications for practice:
- Large sample CI: For (rule of thumb), the CI is
- Convergence rate: The MLE error is - doubling data halves the standard error
- Efficiency: The asymptotic covariance achieves the CRB - no consistent estimator is asymptotically better
- Standard errors in ML: The standard errors reported in logistic regression, GLMs, and survival models are all based on this theorem, using the observed or expected Fisher information
8.4 Misspecified Models
In practice, the model rarely contains the true data-generating distribution . What happens when the model is misspecified?
Theorem 8.4 (MLE under Misspecification). Under regularity conditions, even when , the MLE converges to:
The "pseudo-true parameter" is the closest point in the model family to the truth in KL divergence. The asymptotic distribution under misspecification is the sandwich estimator:
where is the actual variance of the score (not equal to when misspecified). Under correct specification, and the sandwich collapses to .
Implications for LLM training: Language models trained by NLL minimisation are nearly always misspecified (the model cannot perfectly represent natural language). The trained model converges to the KL-minimising distribution within the model class. This is why language models exhibit characteristic failure modes related to the model architecture's inductive biases - they converge to the nearest representable distribution, not the true distribution.
9. Applications in Machine Learning
9.1 MLE Is Cross-Entropy Training
We derived in Section5.4 that MLE = cross-entropy minimisation. Here we examine the consequences.
NLL loss for common model types:
| Task | Model | NLL loss | Standard name | | --- | --- | --- | --- | | Binary classification | | | Binary cross-entropy | | Multi-class | | | Categorical cross-entropy | | Regression | | | MSE (up to constant) | | Language model | | | NLL / perplexity |
Temperature scaling for calibration. After training a classifier, its softmax probabilities are often overconfident (Guo et al., 2017). Temperature scaling finds where logits are divided by . This is a 1-parameter MLE problem on a calibration set, provably maintaining accuracy while improving Expected Calibration Error (ECE).
Label smoothing. Standard MLE on one-hot targets drives (i.e., ) for the correct class, making the model overconfident. Label smoothing (Szegedy et al., 2016) uses target for small (typically 0.1). This regularises MLE toward a mixture of the data distribution and uniform - reducing overconfidence without sacrificing accuracy.
9.2 Natural Gradient and Fisher Information
The problem with Euclidean gradient descent. The ordinary gradient is the direction of steepest ascent in Euclidean space. But this is parameterisation-dependent: rescaling parameters changes the gradient direction. Different parameterisations of the same model family give different gradient descent trajectories.
Information geometry. The space of probability distributions has a natural Riemannian metric - the Fisher information metric . In this curved space, the steepest ascent direction is:
Natural gradient descent (Amari, 1998):
Properties:
- Parameterisation-invariant: changing parameterisation gives the same update in the function space
- Adaptive: steps are small in directions of high curvature (where the loss changes rapidly), large in flat directions
- Connection to Newton's method: natural gradient = Newton's method when the Hessian equals the FIM (true for GLMs at the maximum)
K-FAC (Martens & Grosse, 2015). Full FIM inversion is - impossible for neural networks. K-FAC approximates layer-wise using the Kronecker structure:
where and . This reduces the cost from to per layer, making natural gradient feasible for moderate-sized networks.
Shampoo (Gupta et al., 2018) is a related second-order optimiser that maintains full-matrix preconditioners per parameter group, used at Google-scale training.
9.3 Confidence Intervals for Model Evaluation
The evaluation uncertainty problem. A model is evaluated on a test set of examples. The reported accuracy is an estimate of the true accuracy . Without a CI, it is impossible to determine if two models are genuinely different or differ only by chance.
Standard practice for ML papers:
- Wilson score CI for binary metrics (accuracy, F1 per class)
- Bootstrap CI for non-standard metrics (BLEU, ROUGE, perplexity)
- Correct for multiple benchmarks using Bonferroni or BH correction
Confidence interval for AUC. The Area Under the ROC Curve is a function of ranks, not a simple proportion. Its asymptotic distribution follows the Wilcoxon-Mann-Whitney form, giving a CI:
For complex metrics like this, bootstrap is typically preferred.
LLM benchmark confidence. Major benchmarks (MMLU, HumanEval, HellaSwag) have 1000-14000 questions. For MMLU (), the 95% Wilson CI for an accuracy of 70% is approximately . For HumanEval (), the CI is - models within 7 percentage points cannot be reliably ranked.
9.4 Estimating Scaling Laws
Scaling laws (Kaplan et al., 2020; Hoffmann et al., 2022) describe how model performance depends on model size (parameters), training tokens , and compute . These are regression problems - a direct application of estimation theory.
Chinchilla scaling law (Hoffmann et al., 2022). The loss function is modelled as:
where are estimated by nonlinear least squares MLE on observations from hundreds of training runs. The fitted parameters (, ) are MLE estimates with associated uncertainty.
The optimal allocation. For a fixed compute budget , the optimal is found by constrained optimisation of the fitted loss model. Chinchilla showed that LLaMA-1 (Touvron et al., 2023) and GPT-3 were undertrained relative to their model size - the optimal allocation uses smaller models trained on more tokens.
For AI: The Chinchilla scaling law computation is MLE applied at the scale of frontier AI research. The "parameters" being estimated () are 5 numbers that determine the optimal architecture and training strategy for models costing millions of dollars to train.
9.5 Fisher Information in Fine-Tuning
Elastic Weight Consolidation (EWC, Kirkpatrick et al., 2017). In continual learning, a model trained sequentially on tasks tends to forget earlier tasks - catastrophic forgetting. EWC prevents this by penalising changes to weights that were important for task :
where is the -th diagonal element of the Fisher information matrix computed on task 's data: .
Parameters with high are those to which the task-1 likelihood is most sensitive - changing them most damages task-1 performance. EWC protects these parameters with strong quadratic penalties.
LoRA as low-rank MLE (Hu et al., 2022). LoRA fine-tunes large models by constraining weight updates to be low-rank: where , , and . This is MLE with a rank constraint on the parameter update - the MLE over a restricted parameter manifold. The rank controls the trade-off between expressivity and the number of estimated parameters.
Optimal Brain Damage (LeCun et al., 1990). Neural network pruning by removing parameters that, according to a second-order Taylor expansion, increase the loss least. The per-parameter importance is approximately , where is the diagonal Hessian. Replacing with (diagonal FIM) recovers FIM-based pruning - estimation theory meets efficient neural architecture.
10. Common Mistakes
| # | Mistake | Why It's Wrong | Fix |
|---|---|---|---|
| 1 | "The 95% CI means there is a 95% probability that ." | After observing data, is either in or not - no randomness remains. The probability refers to the procedure, not this interval. | Say "In repeated experiments, 95% of such intervals cover ." Use Bayesian credible intervals if a posterior probability statement is needed. |
| 2 | Confusing bias with MSE, treating "unbiased" as synonymous with "accurate." | Low bias says nothing about variance or overall error. An unbiased estimator with high variance can have larger MSE than a biased estimator with low variance. | Always decompose MSE = Bias^2 + Var and consider both terms. |
| 3 | Using as the unbiased variance estimator. | The estimator is the MLE and is biased; . | Use (Bessel's correction) for unbiased estimation. |
| 4 | Treating the MLE as automatically unbiased. | MLE is consistent and asymptotically efficient but not generally unbiased. The Gaussian variance MLE, Uniform maximum MLE, and many others are biased. | Compute explicitly or use the delta method for composite parameters. |
| 5 | Applying the CRB to biased estimators using the unbiased form . | The CRB for biased estimators is . Using the unbiased form gives an incorrect lower bound. | For biased estimators, always use the biased-estimator CRB, or switch to MSE rather than variance comparisons. |
| 6 | Using the Wald CI for proportions near 0 or 1 (e.g., , ). | The Wald interval can extend below 0 or above 1, and has poor coverage near the boundary. | Use the Wilson score interval or Clopper-Pearson exact interval for proportions near 0 or 1. |
| 7 | Treating the Fisher information (expected curvature) as identical to the Hessian of the log-likelihood (observed curvature). | equals the expected Hessian. For a specific sample, the observed Hessian differs. The observed Hessian is used in practice (faster) but they are equal only in expectation. | Use observed Hessian when computational speed is needed; expected FIM for theoretical comparisons. Both give consistent estimates of . |
| 8 | Applying the MLE invariance property in reverse: assuming is unbiased for because is unbiased for . | MLE invariance says , but says nothing about bias. If is nonlinear, Jensen's inequality shows in general. | Use the delta method to compute the asymptotic bias of and add a bias correction if needed. |
| 9 | Applying asymptotic () CI formulas for small (e.g., ). | Asymptotic normality of MLE typically requires - depending on the model. For small , the -distribution, exact intervals, or bootstrap should be used. | Use the -distribution CI for Gaussian mean with small ; bootstrap CI for non-standard statistics; exact binomial CI for small count data. |
| 10 | Using the sum of likelihoods instead of the product (or sum of log-likelihoods). | The likelihood function is the joint probability of the data - a product for independent observations, not a sum. Maximising the sum gives a different, generally inconsistent estimator. | Always write (log-likelihood = sum of log densities). |
11. Exercises
Exercise 1 [*] MLE for Bernoulli and Poisson.
(a) Given coin flips with outcomes (6 heads, 4 tails), compute and its standard error .
(b) For the Poisson model with iid observations summing to , derive the MLE by solving the score equation and verify it is a maximum (second derivative < 0).
(c) Using the MLE from (b) and the Fisher information , verify the MLE achieves the CRB: .
Exercise 2 [*] Bias of the MLE variance estimator.
Let with both parameters unknown.
(a) Prove that has . (Hint: write in terms of and .)
(b) Show that the corrected estimator is unbiased.
(c) By MLE invariance, . Is this an unbiased estimator of ? If not, what is the sign of its bias? Use Jensen's inequality.
Exercise 3 [*] Cramer-Rao bound verification.
For iid observations from with :
(a) Compute the score and verify .
(b) Compute the Fisher information using both the variance-of-score and negative-expected-Hessian formulas and verify they are equal.
(c) Show that is the MLE and compute using the delta method applied to with . Verify that - the CRB is achieved.
Exercise 4 [**] Method of Moments for the Beta distribution.
Let with moments and .
(a) Derive the MoM estimators and in terms of and .
(b) Show that the MoM estimates are only valid when . What is the statistical interpretation of this constraint?
(c) Generate samples from and compute both the MoM and the MLE (via numerical optimisation). Compare the estimates and their standard errors. Which is more efficient?
Exercise 5 [**] Bootstrap confidence interval.
Let (a sample of size 10).
(a) Compute the sample median and the 95% asymptotic CI for the median using the fact that, for a distribution with density at the true median, .
(b) Implement the non-parametric bootstrap with resamples and compute the percentile bootstrap CI for the median. Compare the width to the asymptotic CI.
(c) Is the bootstrap CI or the asymptotic CI more reliable here, and why?
Exercise 6 [**] Asymptotic normality simulation.
Verify the asymptotic normality of the Bernoulli MLE empirically.
(a) For true parameter and sample sizes , simulate MLEs and plot their distributions.
(b) For each , standardise: and overlay the PDF. At what does the approximation appear adequate?
(c) Compute the empirical coverage of the 95% Wald CI at each . At what does coverage first reach 94%-96%? Does the CRB bound hold: is always ?
Exercise 7 [***] Fisher information for a neural network layer.
Consider a one-layer softmax classifier for , where .
(a) Derive the score where .
(b) Show that the Fisher information matrix (as a matrix) is:
(c) Identify the two factors in the K-FAC approximation: (input covariance) and (output covariance). Simulate this for , , and compare to the full FIM.
Exercise 8 [***] Chinchilla scaling law estimation.
The Chinchilla model (Hoffmann et al., 2022) estimates language model loss as .
(a) Given synthetic training run data (simulate 50 runs with pairs and losses with added Gaussian noise), fit the 5 parameters by nonlinear least squares using scipy.optimize.curve_fit.
(b) Compute 95% CIs for each parameter using the covariance matrix returned by curve_fit (which estimates , where is the Jacobian at the solution).
(c) For a fixed compute budget (FLOPs), find the optimal by minimising over . How sensitive is this optimal allocation to uncertainty in and ?
12. Why This Matters for AI (2026 Perspective)
| Concept | AI/LLM Impact |
|---|---|
| MLE = cross-entropy minimisation | Every language model (GPT-4, LLaMA-3, Gemini, Claude) is trained by NLL minimisation; MLE provides the theoretical foundation for why this converges to the right distribution |
| Fisher information matrix | K-FAC (Martens & Grosse, 2015) enables tractable second-order optimisation for deep networks; Shampoo (Google) uses full-matrix FIM approximations in large-scale training |
| Natural gradient | Invariant to reparametrisation; theoretically optimal steepest direction in distribution space; practical approximations (K-FAC, SOAP) achieve closer-to-optimal convergence rates |
| Asymptotic normality of MLE | Justifies confidence intervals for model parameters; provides the basis for Laplace approximation in Bayesian neural networks (Section04) |
| Cramer-Rao bound | Fundamental limit on estimation from data; explains why larger datasets () always help; motivates data-efficient fine-tuning methods |
| Confidence intervals | Benchmark evaluation without CIs is scientifically misleading; Wilson CIs for accuracy, bootstrap CIs for composite metrics; the HELM/OpenLLM leaderboards report point estimates without CIs - a known limitation |
| Bias-variance decomposition | Theoretical foundation for regularisation in ML: L2/L1 regularisation = adding bias to reduce variance; early stopping, dropout, and weight decay all operate on this trade-off |
| Sufficient statistics | Exponential family sufficient statistics underlie variational autoencoders (encoder outputs , of Gaussian posterior) and normalising flows |
| Scaling law estimation | Chinchilla (Hoffmann et al., 2022) uses nonlinear MLE to fit data; the estimated scaling exponents (, ) determine optimal model sizes at every compute budget |
| Elastic weight consolidation | FIM-based penalty prevents catastrophic forgetting in continual learning; applied in fine-tuning pipelines to protect pre-trained capabilities while adapting to new tasks |
| Temperature calibration | MLE on a calibration set finds the scalar that minimises NLL; well-calibrated models produce reliable uncertainty estimates for downstream decision-making |
| Bootstrap evaluation | Non-parametric CI construction for arbitrary metrics (BLEU, pass@k, ECE); essential for comparing models with complex evaluation protocols |
13. Conceptual Bridge
Estimation theory is the bridge between probability and action. Probability theory (Chapter 6) defines random variables, distributions, and their properties - it answers "if we know the model, what data should we expect?" Estimation theory inverts this: "given data, what can we infer about the model?" This inversion from data to parameters is the core operation of every machine learning training algorithm.
The section you have just completed builds on Descriptive Statistics (Section01) in a crucial way: sample statistics like and were introduced there as data summaries; here they are elevated to estimators - random variables with sampling distributions, bias, variance, and convergence properties. The concept of Bessel's correction ( denominator) was motivated in Section01 by practicality; here it is derived from the requirement of unbiasedness.
Looking forward to Hypothesis Testing (Section03): the confidence intervals of this section have a duality with hypothesis tests - rejecting at level is equivalent to falling outside the CI. The sampling distributions developed here (Gaussian, Student's , chi-squared, ) are the exact distributions that hypothesis tests use.
The next major extension is Bayesian Inference (Section04), which reframes the estimation problem by treating as a random variable with a prior distribution . The posterior combines the likelihood (covered here) with the prior. MAP estimation - maximising the posterior - is MLE regularised by the log-prior. L2 regularisation is MAP with a Gaussian prior; L1 regularisation is MAP with a Laplace prior. The full treatment of conjugate priors, credible intervals, and MCMC is in Section04.
ESTIMATION THEORY IN THE CURRICULUM
========================================================================
Chapter 6 - Probability Theory
| Section01 Random Variables (distributions, CDF/PDF)
| Section04 Expectation and Moments (E[X], Var(X), CLT, LLN)
| Section03 Joint Distributions (Bayes' theorem)
+------------------------------------------+
| prerequisites
Chapter 7 - Statistics v
| Section01 Descriptive Statistics ----------------------------------
| sample mean, variance, data summaries -> estimators
| covariance, correlation
|
+--> Section02 ESTIMATION THEORY (this section)
| - Point estimators: bias, variance, MSE
| - Cramer-Rao bound, Fisher information
| - MLE: derivation, properties, examples
| - Asymptotic normality, delta method
| - Confidence intervals (frequentist)
| - MLE = cross-entropy training
|
+--> Section03 Hypothesis Testing (duality: CIs <-> tests)
| p-values, power, t/z/\\chi^2 tests, A/B testing
|
+--> Section04 Bayesian Inference (extension: add prior to likelihood)
| posterior = likelihood x prior, MAP = regularised MLE
| conjugate priors, MCMC, variational inference
|
+--> Section05 Time Series (sequential estimation, Kalman filter)
|
+--> Section06 Regression Analysis (applied MLE: OLS, Ridge, Lasso)
Chapter 8 - Optimisation (natural gradient uses FIM)
Chapter 9 - Information Theory (FIM and Shannon information)
========================================================================
The Fisher information matrix is the central object connecting estimation theory outward: it bounds estimation variance (CRB), defines the geometry of natural gradient optimisation (Ch8), underpins the Laplace approximation in Bayesian inference (Section04), and is related to the Shannon capacity of statistical experiments (Ch9). Understanding the FIM deeply is understanding the mathematical infrastructure of modern ML training.
End of Section02 Estimation Theory
<- Back to Chapter 7: Statistics | Next: Hypothesis Testing ->
Appendix A: Exponential Families
Exponential families are the most important class of parametric models in statistics, unifying the Gaussian, Bernoulli, Poisson, Exponential, Gamma, Beta, and dozens of other distributions under one framework.
Definition A.1 (Exponential Family). A parametric family is an exponential family if it can be written in the form:
where:
- is the natural (canonical) parameter
- is the sufficient statistic (vector of natural statistics)
- is the base measure
- is the log-partition function (ensures normalisation)
The log-partition function encodes all moments: and .
Verification examples:
Bernoulli. . Write as . Natural parameter (log-odds), sufficient statistic , .
Gaussian. : natural parameters , sufficient statistics .
Key properties of exponential families for MLE:
-
MLE score equation: satisfies - the MLE moment-matches the sufficient statistics.
-
MLE = MoM: For exponential families, MLE and method of moments coincide (they both set ).
-
Efficient MLE: The MLE achieves the CRB for all exponential families - it is always efficient.
-
Log-likelihood is concave: For minimal exponential families, is strictly concave - the MLE is the unique global maximum, and Newton-Raphson converges from any starting point.
-
Complete sufficient statistics: is a complete sufficient statistic, so the MLE is the UMVUE by Lehmann-Scheffe.
Importance for ML: The categorical distribution (softmax output of neural networks), Gaussian (regression, VAE latent space), Bernoulli (binary classification), and Poisson (count data, Poisson regression) are all exponential families. The VAE encoder outputs the natural parameters of the Gaussian posterior - the sufficient statistics. Generalised linear models (GLMs, of which logistic regression is a special case) are defined precisely as: exponential family response + linear natural parameter .
Appendix B: Sufficient Statistics - Detailed Examples
B.1 The Exponential Distribution
For :
By the factorisation theorem: (total waiting time) is a sufficient statistic. It factors as with and .
MLE: , which depends on the data only through - consistent with sufficiency.
B.2 Order Statistics and the Uniform Distribution
For :
The sufficient statistic is (the maximum order statistic). The MLE is a function of as expected.
Bias correction. Since , the unbiased estimator is . By Rao-Blackwell applied to (use only first observation): conditioning on gives , so the Rao-Blackwell estimator is indeed .
Appendix C: The EM Algorithm - Connecting MLE to Latent Variable Models
Many models of interest (Gaussian mixture models, HMMs, topic models, VAEs) have latent variables in addition to observed data . The complete-data log-likelihood would be easy to maximise if were observed, but we only observe .
The EM algorithm maximises the marginal log-likelihood by iterating two steps:
E-step: Compute the expected complete-data log-likelihood under the current posterior over :
M-step: Maximise:
Why EM guarantees : The evidence lower bound (ELBO):
where is the entropy term not involving . The M-step maximises , and the E-step tightens the bound at the new .
Gaussian Mixture Model (GMM). For -component GMM with means , covariances , and mixing weights :
- E-step: Compute responsibilities
- M-step: Update parameters:
Each M-step is a weighted MLE for a Gaussian - exactly the closed-form solutions from Section5.3, but with fractional weights.
For AI: The EM algorithm is the algorithmic prototype for variational inference in VAEs (Section04). In the VAE, the E-step is replaced by the encoder (an amortised posterior approximation) and the M-step is replaced by joint gradient ascent on the ELBO with respect to both encoder parameters and decoder parameters .
Appendix D: Cramer-Rao Bound - Multivariate Proof and Geometry
Multivariate CRB (full proof). Let be an unbiased estimator of . Define the score vector .
Since is unbiased: . Differentiating with respect to :
In matrix form: (a identity).
By the matrix Cauchy-Schwarz (Lowner ordering):
The Schur complement condition gives: , i.e., .
Information-geometric interpretation. The statistical manifold is a Riemannian manifold with the Fisher-Rao metric . The CRB states that the covariance of any unbiased estimator is at least as large as the inverse metric - the "volume" of estimation uncertainty is bounded below by the curvature of the statistical manifold.
This geometric view motivates the natural gradient: gradient descent in the Fisher-Rao metric on the statistical manifold corresponds to the natural gradient update .
Appendix E: The Score Test, Wald Test, and Likelihood Ratio Test
These three test statistics form the classical trinity of asymptotic tests in statistics. While their full treatment belongs in Section03 Hypothesis Testing, their derivations from MLE theory belong here.
For testing :
Score (Rao) test: under .
Uses only the restricted model - does not require fitting the unrestricted MLE.
Wald test: under .
Uses only the unrestricted MLE.
Likelihood ratio test: under .
Requires fitting both restricted and unrestricted models. By Wilks' theorem (1938), this converges to the chi-squared distribution.
Asymptotic equivalence. Under : - all three are first-order equivalent. They differ in finite samples. The LRT is generally most accurate for small .
These tests are developed fully in Section03 Hypothesis Testing, including the Neyman-Pearson lemma, p-values, and power calculations.
Appendix F: Sampling Distributions of Classical Statistics
Understanding the exact (finite-sample) distributions of key estimators is essential for constructing valid hypothesis tests and confidence intervals when is small.
F.1 Distribution of the Sample Mean
Let .
This is an exact result (not asymptotic) - the sum of independent Gaussians is Gaussian. The standardised version gives exact z-tests and z-intervals.
F.2 Distribution of the Sample Variance: Chi-Squared
Theorem F.1. Let . Then:
and this is independent of .
Proof sketch. Write where . The quadratic form equals , a projection of onto the -dimensional subspace orthogonal to . By the spectral theorem for Gaussian quadratic forms, this has a distribution. Independence from (a function of ) follows from the orthogonality.
The degrees of freedom arise because estimating by removes one degree of freedom from the deviations (they sum to zero, so only are free).
F.3 Student's Distribution
Definition. If and independently, then .
Application to Gaussian mean. With and (independent of ):
This is exact for all - no large-sample approximation needed. The -distribution is symmetric, bell-shaped, heavier-tailed than the Gaussian, and converges to as .
Quantiles comparison:
| (two-sided) | |||
|---|---|---|---|
| 10% | 1.645 | 1.833 | 1.699 |
| 5% | 1.960 | 2.262 | 2.045 |
| 1% | 2.576 | 3.250 | 2.756 |
The -distribution with small df requires wider intervals to achieve the same coverage - reflecting the additional uncertainty from estimating .
F.4 The Distribution
Definition. If and independently, then .
Application. Comparing variances: . Testing equality of variances : under .
The -distribution also underlies ANOVA (testing equality of multiple means), regression significance tests, and model comparison - fully developed in Section03 Hypothesis Testing and Section06 Regression Analysis.
Appendix G: Numerical Example - Fitting a Gaussian Mixture Model via EM
This worked example demonstrates MLE for a latent variable model.
Setup. Suppose we observe observations believed to come from a mixture of two Gaussians: .
The parameters are .
Direct MLE is hard. The log-likelihood is , which contains a log of a sum - non-convex, no closed form.
EM solution. Introduce latent indicators indicating which component generated .
E-step: Compute responsibilities
M-step: Update parameters (weighted MLEs for each component):
Convergence. EM guarantees at every iteration, converging to a local maximum. Multiple random initialisations are needed to find the global maximum.
For AI: The EM algorithm is the prototype for alternating optimisation in deep learning. The BERT pre-training objective (masked language modelling) alternates between predicting masked tokens (like the E-step computing responsibilities) and updating parameters (like the M-step). Expectation-Maximisation underlies the theory of the EM algorithm, which is used for fitting GMMs, HMMs, and topic models in NLP preprocessing pipelines.
Appendix H: Regularised MLE and the Bias-Variance Trade-Off in Practice
Ridge regression (L2-regularised linear regression) is the canonical example of regularised MLE.
Setup. For linear regression with , the MLE is OLS: .
Ridge regression: Add L2 penalty:
Bias: - ridge is biased.
Variance: .
Ridge has smaller covariance than OLS - introducing bias reduces variance. The bias-variance trade-off: for well-chosen , MSE of ridge < MSE of OLS.
MAP interpretation. Ridge is MAP estimation with Gaussian prior . The prior pulls toward zero, introducing bias toward zero. The full development of MAP (adding a prior to MLE) is in Section04 Bayesian Inference.
Optimal selection. Cross-validation estimates the prediction MSE for each , selecting the one that minimises the bias-variance trade-off from a prediction perspective. Alternatively, analytical formula: the MSE-minimising (depends on unknown , so must be estimated).
Connection to weight decay in LLMs. AdamW (Loshchilov & Hutter, 2019) adds weight decay to the Adam update. This is regularised MLE with a Gaussian prior on all parameters - the standard training procedure for all frontier language models. The weight decay coefficient (typically 0.1) controls the strength of the prior, determining how much parameters are regularised toward zero.
Appendix I: Non-Parametric Estimation
When the parametric model is uncertain or clearly wrong, non-parametric estimation makes minimal distributional assumptions.
Empirical Distribution Function (EDF). Given sample :
The EDF is the non-parametric MLE of the CDF . By the Glivenko-Cantelli theorem: - the EDF converges uniformly to the true CDF.
The Dvoretzky-Kiefer-Wolfowitz (DKW) inequality gives a finite-sample bound:
This is the non-parametric Cramer-Rao analogue - it bounds estimation error for the CDF without any parametric assumption.
Kernel density estimation. Estimating the PDF non-parametrically:
where is a kernel (e.g., Gaussian) and is the bandwidth. The bias-variance trade-off applies: small -> low bias, high variance; large -> high bias, low variance. Optimal bandwidth: (mean integrated squared error).
Bootstrap as non-parametric MLE. The bootstrap resamples from the EDF - effectively replacing the unknown with its non-parametric MLE. Bootstrap CI validity follows from the closeness of to (Glivenko-Cantelli) and the continuity of the statistic of interest.
Appendix J: Selected Proofs and Derivations
J.1 Asymptotic Variance of the Sample Median
For a distribution with PDF and CDF , let denote the population median (). The sample median satisfies:
Proof sketch. The sample median is the MLE for the double-exponential (Laplace) distribution, and the asymptotic variance of the -th quantile estimator is . For : .
Comparison to mean (for Gaussian data). For : , so the median's asymptotic variance is vs. for the mean. The relative efficiency is - the mean extracts more information from Gaussian data than the median. However, for heavy-tailed distributions (e.g., Cauchy), the mean has infinite variance while the median remains consistent - robustness matters.
J.2 The Neyman-Scott Paradox - Inconsistency of MLE
MLE is not always consistent. The Neyman-Scott example (1948) provides a famous cautionary case.
Setup. Observe pairs for , where . The parameters are - parameters for observations.
MLE. For each pair: . For : .
Inconsistency. - the MLE permanently underestimates by a factor of 2, regardless of . The bias does not vanish because the number of parameters grows with .
Root cause. The regularity conditions for MLE consistency require the number of parameters to be fixed as . When nuisance parameters grow with (an "incidental parameters" problem), MLE can fail. The fix: use a conditional or marginal likelihood that eliminates the nuisance parameters.
For AI. This paradox is relevant to neural network generalisation. A model with parameters (overparameterised regime) has more parameters than observations. Classical MLE theory breaks down - yet in practice, overparameterised networks often generalise well due to implicit regularisation (gradient descent inductive bias). This remains an active research area.
J.3 Locally Most Powerful Tests and the Neyman-Pearson Lemma
(Preview - full treatment in Section03 Hypothesis Testing)
The Neyman-Pearson lemma provides the most powerful test for simple hypotheses vs. . The rejection region is:
where is chosen to control type-I error at level . The likelihood ratio is a sufficient statistic for the test - no other test can be more powerful at the same level. The connection to MLE: the most powerful test uses the likelihood, and the MLE is the point that maximises the likelihood.
For composite alternatives , the likelihood ratio test statistic is the standard generalisation, and connects to the Wald and score tests via asymptotic equivalence.
Appendix K: Reference Tables
K.1 Common MLE Formulas
| Distribution | Parameters | Log-likelihood | MLE |
|---|---|---|---|
| , | , | ||
| No closed form; requires Newton-Raphson | |||
| No closed form |
K.2 Fisher Information Summary
| Distribution | Parameter | Efficient MLE | ||
|---|---|---|---|---|
| , known | ||||
| , known | ||||
| (one of free) | (marginal) | Multinomial variance |
K.3 Confidence Interval Reference
| Parameter | Setting | Pivot | CI formula |
|---|---|---|---|
| Gaussian mean | known | ||
| Gaussian mean | unknown | ||
| Gaussian variance | unknown | ||
| Bernoulli (large ) | - | Wald: | Wilson score preferred near 0/1 |
| General MLE | Large | ||
| Any statistic | Non-parametric | Bootstrap | Percentile/BCa bootstrap |
End of Appendices
Appendix L: Worked Examples - End-to-End Estimation
L.1 Estimating the Parameters of a Sentiment Classifier
Problem. A BERT-based sentiment classifier is evaluated on a test set of examples. It classifies 418 correctly (). Report (a) the point estimate with standard error, (b) the 95% Wilson CI, (c) determine if this differs significantly from a baseline accuracy of 80%.
Step 1: Point estimate and SE.
. Standard error: .
Step 2: Wilson score CI.
With , , :
Numerically: centre ; margin . CI .
Step 3: Comparison to baseline 80%.
The null hypothesis corresponds to checking if 0.80 is inside the CI. Since 0.80 is inside ? No - 0.80 is just outside. Alternatively, -test: . The improvement is statistically significant at .
Statistical interpretation. The classifier significantly outperforms the 80% baseline, but uncertainty spans from 80.4% to 86.9% - real-world performance could be anywhere in this range, highlighting the importance of CIs even for significant results.
L.2 MLE for a Gaussian Mixture - Worked Iteration
Problem. Two clusters are observed: and (but we don't know the assignments). Fit a 2-component Gaussian mixture.
Initialisation. , , , , .
E-step (iteration 1). For :
For : . The algorithm already strongly assigns each point to the correct cluster.
M-step (iteration 1). With (the four small values):
After 2-3 iterations, the algorithm converges to the obvious clusters. The key insight: EM separates the cluster assignment (E-step soft assignments ) from parameter estimation (M-step weighted MLEs), alternating until convergence.
L.3 Bootstrap CI for Median Income - ML Context
Problem. A dataset of yearly salaries (thousands) for ML engineers is collected. Sample statistics: , . Construct a 95% bootstrap CI for the median.
Why bootstrap? The Gaussian CI for the median requires knowing the PDF at the median - unknown without assuming a distribution. The salary distribution is likely right-skewed (some outliers earn much more), making parametric CIs unreliable.
Bootstrap procedure (pseudocode):
for b = 1 to B=2000:
x_star = sample(x, n=50, replace=True)
median_star[b] = median(x_star)
CI_95 = [percentile(median_star, 2.5), percentile(median_star, 97.5)]
Typical result: thousand. The CI is slightly asymmetric (the right tail is longer due to income skewness), which the bootstrap correctly captures and a symmetric Gaussian CI would miss.
For AI. This exact procedure is used to report confidence intervals for ML engineer compensation surveys, which inform hiring benchmarks and compensation strategy at AI companies. Statistically sound salary benchmarks require bootstrap CIs because income distributions are strongly non-Gaussian.