Maximum Likelihood Estimation
The engine under regression and machine learning: pick the parameter that makes your data most plausible.
Turning the question around
Probability and likelihood use the same formula but ask opposite questions. In a probability question the parameter is fixed and we ask how likely various data are: given a fair coin, how probable is it to see 8 heads in 10 tosses? In a likelihood question the data are fixed — we already saw 8 heads — and we ask which parameter makes what we observed most plausible.
Maximum likelihood estimation, or MLE, is the recipe behind that second question. It is the quiet workhorse under a huge amount of modern statistics — linear and logistic regression, and much of machine learning, all fit their parameters by maximizing a likelihood.
The likelihood of a whole data set
Suppose \( x_1, x_2, \dots, x_n \) are drawn independently from a model with density \( f(x \mid \theta) \). Independence means the probability of seeing the whole batch is the product of the individual densities. Products of many small numbers underflow toward zero and are painful to differentiate, so we take a logarithm: it turns the product into a sum, and because \( \ln \) is strictly increasing it never moves where the maximum is. So we maximize the log-likelihood instead.
The MLE is the peak
The maximum likelihood estimate \( \hat\theta \) is the parameter value at the top of the log-likelihood curve — the setting that makes the data you actually saw most plausible:
\( \hat\theta = \arg\max_{\theta}\; \ell(\theta) \)
The tool below fixes a sample of 30 values drawn from a normal model with a known spread \( \sigma \), then plots \( \ell(\mu) \) as you slide the candidate mean \( \mu \). The small ticks along the axis are the data points themselves. Drag \( \mu \): the red dot rides the curve, and the fit is best exactly at the green peak — watch where that peak lands.
The general recipe
Almost every MLE problem follows the same three steps:
- Write the log-likelihood \( \ell(\theta) \) for your model and data.
- Differentiate with respect to the parameter and set the derivative to zero — this is the score equation.
- Solve for \( \theta \), and check the solution is a maximum (the second derivative is negative), not a minimum.
Carry that out for the normal mean. The log-likelihood is \( \ell(\mu) = -\tfrac{n}{2}\ln(2\pi\sigma^2) - \tfrac{1}{2\sigma^2}\sum (x_i-\mu)^2 \). Only the last term depends on \( \mu \), so differentiating and setting to zero gives:
- Write the log-likelihood: \( \ell(\mu) = -\tfrac{n}{2}\ln(2\pi\sigma^2) - \tfrac{1}{2\sigma^2}\sum (x_i-\mu)^2 \). Only the final sum depends on \( \mu \).
- Differentiate and set to zero: \( \frac{d\ell}{d\mu} = \frac{1}{\sigma^2}\sum (x_i-\mu) = 0 \), which rearranges to \( \sum x_i - n\mu = 0 \).
- Solve: \( \hat\mu = \frac{1}{n}\sum x_i = \frac{2+4+9}{3} = \frac{15}{3} \).
Check your understanding
- A probability fixes the parameter and asks about the data; a likelihood fixes the data and asks about the parameter.
- The likelihood of an independent sample is the product of its densities; the log-likelihood is the sum of the log-densities and has the same maximizer.
- The maximum likelihood estimate is the parameter at the peak of the (log-)likelihood curve: θ-hat = argmax ℓ(θ).
- General recipe: write the log-likelihood, differentiate, set to zero, solve, and confirm it is a maximum.
- For a normal model with known σ the log-likelihood in μ is a downward parabola whose peak is the sample mean, so the MLE of a normal mean is x-bar.