Three data points sit on a line. A bell slides along them, and the heights it gives the points are multiplied. Watch where the product peaks.
Which value fits best
A bell with spread 2 slides along the data 3, 5 and 7; its heights there multiply into the likelihood.
The data 3, 5 and 7, and a bell with spread 2. Each stem is the bell's height at a data point; their product is the likelihood.
Predict first. Where will the product of the three heights be largest?
Describe this picture
Three panels on one horizontal scale from 0 to 10. On top, the data 3, 5 and 7 as dots on an axis, and a bell curve with standard deviation 2 whose centre can move; a stem from each dot up to the curve shows the curve’s height there. Below it, “likelihood L(μ)”, the product of the three heights drawn against , and under that, “log-likelihood ℓ(μ)”, its logarithm. Before the clip a question asks where the likelihood will peak: at the smallest, the middle or the largest data value. A tap picks one and starts the clip. In the clip moves from 1 to 9 over 8 seconds, easing in and out, and both curves are traced as it goes, with a dot at the current : 0.000651 at , 0.00201 at 4, and its peak, 0.00292, at 5. Then the bell returns to 5 and the peak is marked; the logarithm is labelled a parabola. Your guess is a dotted line on the likelihood. Readouts give , the likelihood to three significant figures and the log-likelihood to three decimals. After the clip a slider, “Centre μ”, moves from 1 to 9 in steps of 0.1.
Slide the model, multiply the heights
I have data, and a model with a knob: here a bell of known width whose centre I do not know. Each setting of the knob gives each data point a height. The idea of maximum likelihood is to choose the setting that makes the data I saw as probable as possible.
The heights multiply because the three points were drawn independently: the chance of seeing all three is a product. That product, as a function of the knob, is the likelihood:
where is the model’s density (or its pmf, for counts) at when the knob is set to . The best setting, , is the maximum likelihood estimate.
Before the clip you guessed where the peak would be. It is at , the middle value, which is also the mean of the three. At the bell sits on the left point and gives the right point, 7, a low height; the product suffers. At no point is far from the centre.
Take the logarithm
Products of many small numbers are awkward: with 1000 data points the likelihood is smaller than any computer can store. Take the logarithm instead. It turns the product into a sum, and since the logarithm only ever rises, the peak stays at the same :
This is the log-likelihood. For the bell of width 2,
so for the three points the log-likelihood is plus a constant: a parabola with its top at 5, the curve under the likelihood in the picture.
Three recipes
To find the peak, set the slope of to zero.
A coin. heads in independent flips with chance of heads: . Its slope is , which is zero at
A bell. For bell-shaped data with unknown centre and width, the slopes give , the sample mean, and
with divisor , so biased low, as Estimators: bias and variance showed. Maximum likelihood is not always unbiased.
Waiting times. For gaps from the exponential law of rate , . Its slope is zero at
one over the mean gap.
A coin, and how sure to be
The likelihood also shows how sharply the data pin the parameter down.
Describe this picture
One panel: the likelihood of 7 heads in 10 flips, drawn against the chance of heads from 0 to 1, on a vertical axis counted in units of . The clip traces the curve from to 1, marks its peak at 0.7 with a dashed drop to the axis, then shades the area under it, labelled “1/1320 = 0.00076, not 1”. Readouts give the estimate , 0.7, its standard error, 0.1449, and the area under the curve, 0.00076. After the clip a switch, “Data”, changes the data to 70 heads in 100 flips. Its likelihood is about , so the vertical axis is relabelled in units of , and the caption says so. The peak stays at 0.7 and the curve becomes about three times narrower: standard error 0.0458, area .
The peak is at in both cases. With 10 flips the curve is wide, so many values of fit nearly as well. With 100 flips it is narrow. Its width is measured by the standard error of ,
for 10 flips and for 100: ten times the data, a third of the width.
Watch out
The likelihood is not the probability that the parameter is right. It is a function of , but it is built from the chance of the data, and it does not add up to 1 over : the area under is . Turning it into a probability for needs a starting belief, the subject of Bayesian updating.
Two properties make maximum likelihood a default way to fit a model. Under mild conditions on the model, as the sample grows, closes in on the true value: it is consistent. And for large samples its distribution over repeated samples is close to a bell centred on the truth, with a width that shrinks like . I state these without proof.
Worked example
1. Seven heads in ten. At the estimate,
A fair coin gives . So makes the data times as probable as a fair coin does: more probable, but not overwhelmingly.
2. The bell, with its width unknown too. For the data 3, 5 and 7, . The squared deviations add to 8, so and . The sample variance of Describing data divides by 2 instead and gives .
3. Waiting times. Four gaps between clicks, s, add to 2.0 s. So per second, the rate of the Geiger counter in Random arrivals. The log-likelihood peaks there at .
4. Noise that is bell-shaped. If each measurement is a model value plus bell-shaped noise of fixed width, then is, apart from a constant, . Making the likelihood largest is making the sum of squared errors smallest: maximum likelihood is least squares.
Try it yourself. Three heads in 12 flips give . A mean gap of 0.25 s gives per second. If every data value is shifted by 10, the estimate of the bell’s centre shifts by 10.
Where you’ll meet this
Fitting models. Rates of events, failure times, the gain of a channel, the frequency of a tone in noise: many fitted parameters in science and engineering are maximum likelihood estimates, or close to them.
Classification. Logistic regression, the standard model for yes-or-no outcomes, is fitted by maximum likelihood.
Searching for a peak. Many estimates are found the way the picture found : slide a template along, score each position, keep the best. Pitch trackers slide over candidate frequencies; radar slides over delays.
In signal processing · detection in noise
In bell-shaped white noise, the delay that maximises the likelihood of a known pulse is the delay where the correlation with the pulse peaks. That is what Matched filters and detection computes in the signal processing course.
Where this leads · least squares
The fourth example turns maximum likelihood into least squares. Least squares in the linear algebra course solves that problem with projections.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Likelihood | a function of ; not a probability for | |
| Log-likelihood | same peak | |
| Coin | standard error | |
| Bell | , | divisor : biased low |
| Exponential | one over the mean gap | |
| Bell-shaped noise | maximum likelihood = least squares | |
| Large samples | consistent, close to a bell | width like |