Maximum Likelihood: The Default Recipe for Turning Data Into Parameters
Published:
Likelihood is the density, read sideways
For a model \(p(x \mid \theta)\) and independent observations \(x_1,\dots,x_n\), the likelihood is
Algebraically this is the joint density. Conceptually it is something different: the data are fixed and known, and \(\theta\) is the free argument. \(L(\theta)\) is not a probability distribution over \(\theta\) — it does not integrate to one, and rescaling it changes nothing about where the maximum is. Only ratios of likelihoods at different \(\theta\) carry meaning.
We maximise the logarithm because sums are easier than products in three separate ways: the derivative of a sum is a sum of derivatives; the exponential families that dominate practice have log-densities that are simple polynomials; and a product of \(10^5\) densities underflows to zero in floating point while its log does not. Since \(\log\) is strictly increasing, the maximiser is unchanged.
The Gaussian, worked end to end
Take \(x_i \sim \mathcal{N}(\mu, \sigma^2)\) with both parameters unknown. The log-likelihood is
Differentiate in \(\mu\): only the last term depends on it, giving \(\partial\ell/\partial\mu = \frac{1}{\sigma^2}\sum_i (x_i - \mu)\). Setting this to zero gives \(\hat\mu = \bar{x}\), independently of \(\sigma^2\).
Now differentiate in \(\sigma^2\), treating it as a single variable \(v\):
Concretely, for the five measurements 2.1, 1.9, 2.4, 2.0, 2.6: the sum is 11.0 so \(\hat\mu = 2.2\), and the squared deviations \(0.01 + 0.09 + 0.04 + 0.04 + 0.16\) total 0.34. The MLE gives \(\hat\sigma^2 = 0.34/5 = 0.068\), while the unbiased estimator gives \(0.34/4 = 0.085\). The ratio is \(0.8 = (n-1)/n\), exactly as the Bessel argument in descriptive statistics predicts.
Curvature is information
Under regularity conditions the MLE is asymptotically normal:
\(I(\theta)\) is the Fisher information per observation — the expected curvature of the log-density at the truth. A sharply peaked log-likelihood means small parameter changes cost a lot of fit, so the parameter is well determined; a flat one means many values fit almost equally well. For the Gaussian mean, \(I(\mu) = 1/\sigma^2\), so the asymptotic variance of \(\hat\mu\) is \(\sigma^2/n\) — which here is the exact finite-sample answer too.
The same thing as minimising KL
Let \(\hat{p}\) be the empirical distribution, putting mass \(1/n\) on each observed point. Then
The first term is the negative entropy of the data and does not involve \(\theta\). So minimising KL divergence to the empirical distribution and maximising the average log-likelihood are the same optimisation. This is the bridge to machine learning: cross-entropy loss on a classifier is the negative log-likelihood of a categorical model, and squared error is the negative log-likelihood of a Gaussian with fixed variance. Nobody chose those losses for aesthetic reasons.
MAP, and why L2 is a Gaussian prior
Put a prior \(p(\theta)\) on the parameter and maximise the posterior instead. Since \(p(\theta \mid x) \propto p(x\mid\theta)\,p(\theta)\),
MAP is MLE plus one extra additive term. Take linear regression with Gaussian noise of variance \(\sigma^2\) and a prior \(\theta \sim \mathcal{N}(0, \tau^2 I)\). The log-prior is \(-\lVert\theta\rVert^2/(2\tau^2)\) up to a constant, so maximising gives
which is ridge regression with \(\lambda = \sigma^2/\tau^2\). A tight prior (small \(\tau\)) means heavy regularisation; a flat prior recovers plain MLE. A Laplace prior gives L1 and hence lasso by the same route.
Recap
- Likelihood is the density with data fixed and \(\theta\) free; it is not a distribution over \(\theta\), so only ratios matter.
- Gaussian MLE: \(\hat\mu = \bar{x}\) (unbiased), \(\hat\sigma^2 = \frac1n\sum_i(x_i-\bar x)^2\) (biased by \((n-1)/n\)).
- Asymptotically \(\hat\theta \approx \mathcal{N}(\theta, (nI(\theta))^{-1})\); Fisher information is expected log-likelihood curvature.
- Maximising log-likelihood = minimising \(D_{\mathrm{KL}}(\hat p \,\|\, p_\theta)\), which is why cross-entropy and squared error are the standard losses.
- MAP = MLE + log-prior; a Gaussian prior gives ridge with \(\lambda = \sigma^2/\tau^2\), a Laplace prior gives lasso.
References
- Fisher, R. A. On the Mathematical Foundations of Theoretical Statistics. Philosophical Transactions of the Royal Society A, 222, 309–368, 1922.
- van der Vaart, A. W. Asymptotic Statistics. Cambridge University Press, 1998.
- Efron, B. R. A. Fisher in the 21st Century. Statistical Science, 13(2), 95–122, 1998.
- Murphy, K. P. Probabilistic Machine Learning: An Introduction. MIT Press, 2022.
