1.3.16 · D2Probability & Statistics

Visual walkthrough — Maximum likelihood estimation (MLE)

2,172 words10 min readBack to topic

We will use the coin flip as our running example because it needs only one unknown number, so we can draw everything on a flat sheet of paper.


Step 1 — What is a "parameter" and what is "data"?

WHAT. We have a coin. It lands heads with some unknown chance we call . Here is a single number between and — that is our parameter (the dial we get to turn). We flip the coin times and record what happened; those recorded outcomes are our data. We write == for the number of heads== we saw (so is the number of tails). In our running example and .

WHY start here. Before any maths, we must be crystal clear on which thing is fixed and which thing we are searching over. The data already happened — it is frozen. The parameter is the mystery knob. Nailing down the letters and now means every later formula reads without surprise.

PICTURE. Below: a dial for on the left (turnable), and the frozen data on the right — 7 heads, 3 tails, already fallen and unchangeable.

Figure — Maximum likelihood estimation (MLE)

Step 2 — How likely is this exact data for one setting of the knob?

WHAT. Pick one value of the knob, say . Ask: if the true chance of heads were , how probable is it to see exactly 7 heads then 3 tails? Each head costs a factor , each tail costs a factor . Multiply them:

Here each symbol earns its place: is "each of the heads has chance , multiplied," and is "each of the tails has chance ." The whole product is the likelihood — the probability of the frozen data, read as a function of the knob .

WHY multiply. The flips are independent — one flip's result tells you nothing about the next. For independent events, the probability of "this AND that AND the other" is the product of the individual probabilities. That is the only reason the product appears.

PICTURE. Two dial settings side by side: at the data is fairly likely; at the three tails become very unlikely, so the product shrinks. The bar height = .

Figure — Maximum likelihood estimation (MLE)

Step 3 — Slide the knob and watch the likelihood rise and fall

WHAT. Instead of testing one value at a time, sweep smoothly from to and plot the height . You get a single hump.

WHY a hump. At you claim heads are impossible, yet you saw 7 heads → likelihood . At you claim tails are impossible, yet you saw 3 tails → likelihood . Somewhere in between the two pressures balance and the curve peaks. The MLE is the location of that peak — the knob setting that makes the frozen data most probable.

PICTURE. The full likelihood curve. It is pinned to zero at both ends, bulges in the middle, and its highest point is marked with a dashed line dropping to the -axis.

Figure — Maximum likelihood estimation (MLE)

Step 4 — Why we climb the log of the curve instead

WHAT. Replace with its logarithm, the log-likelihood:

The turned the product into a sum, because and . (If we had kept the binomial factor from Step 2, it would appear here only as an extra constant , flat in — invisible to the peak-finder.)

WHY the log — and why it is safe. Two reasons. (1) Same peak. is strictly increasing: if curve is taller than curve at some point, its log is also taller there. So climbing lands us at the exact same as climbing . (2) Practical. Sums are far easier to differentiate than products, and for large the raw product underflows to on a computer while its log stays a sensible number.

PICTURE. Left axis: the hump . Right axis: the curve . Notice the dashed vertical line — both peaks sit at the same . The log-curve is stretched and shifted but its summit has not moved.

Figure — Maximum likelihood estimation (MLE)

Step 5 — The slope is zero at the summit

WHAT. At the top of a smooth hill the ground is momentarily flat — the slope (derivative) is zero. So we compute the slope of and set it to zero:

Term by term: (this pushes up, since more heads-weight wants larger ), and (the tails pull down). At the peak these two forces exactly cancel.

WHY the derivative. Why this tool and not, say, just eyeballing the graph? Because the derivative is the precise machine that answers "where is the curve flat?" — and a smooth hump is flat only at its summit. Setting it to zero converts a searching problem into an equation-solving problem.

PICTURE. The log-likelihood curve with three tangent lines: one uphill (positive slope) on the left, one downhill (negative slope) on the right, and one perfectly horizontal at the top where slope .

Figure — Maximum likelihood estimation (MLE)

Step 6 — Solve, and read the meaning of the answer

WHAT. Rearrange the flat-slope equation:

In general, with heads out of flips the same algebra gives : the MLE is simply the observed fraction of heads.

WHY it is beautiful. The abstract machinery — products, logs, derivatives — collapses to the most obvious estimate a child would guess. That is a sign the method is sane.

PICTURE. The likelihood hump again, with the peak annotated at , and the fraction written beside the frozen data to show they are the same number.

Figure — Maximum likelihood estimation (MLE)

Step 7 — Was it really a maximum? And the degenerate cases

WHAT. A zero slope alone could mark a valley, not a peak. We check the second derivative (the rate at which the slope itself changes — negative means the curve bends downward, a true summit):

Both terms are negative for all valid , so the curve is concave-down everywhere — our critical point is unquestionably the maximum.

Edge cases — cover them all:

  • All heads (): has no interior flat point; it just keeps rising toward . The MLE sits at the boundary . Interpretation: the data has given zero evidence that tails can happen.
  • All tails (): mirror image, .
  • Zero flips (): no data, no hump — every is equally (un)supported and the MLE is undefined. You cannot estimate a knob you never tested.

WHY show these. The clean formula still returns , , and in these three cases — matching exactly the boundary/undefined behaviour we just reasoned out. A method you trust must behave sensibly at its extremes.

PICTURE. Three mini-curves side by side: the interior-peak normal case, the all-heads case (peak pinned to the right wall ), and the all-tails case (peak pinned to the left wall ).

Figure — Maximum likelihood estimation (MLE)

The one-picture summary

This final figure compresses the whole journey: frozen data → likelihood hump → log reshaping → flat slope at the peak → answer , with the boundary cases in the margin.

Figure — Maximum likelihood estimation (MLE)
Recall Feynman retelling — say it back in plain words

We had a coin with an unknown heads-chance , and we saw heads and tails frozen on the table (out of flips). For any guess of , the chance of seeing that exact record is — big when fits, tiny when it doesn't. If we had only counted heads instead of remembering the order, there'd be an extra out front, but it's a constant that never moves the peak, so we ignore it. We swept from 0 to 1 and got a hump that is zero at both ends (a guess of "heads impossible" or "tails impossible" contradicts the data). The best is the top of the hump. To find the top we took the log — which reshapes the hump but keeps its summit in the same spot and turns the product into an easy sum. At a summit the ground is flat, so we set the slope to zero, and the heads-force balanced the tails-force , giving . The second derivative was negative everywhere, so it truly was a peak. And in general the answer is just the fraction of heads, — with the edges (all heads → 1, all tails → 0, no flips → undefined) all behaving exactly as common sense demands.

Recall Quick self-test

Why does the likelihood curve touch zero at both and ? ::: Because makes the 7 observed heads impossible and makes the 3 observed tails impossible, so the product vanishes at each end. Why can we drop the factor before maximizing? ::: It contains no , so it only scales the curve's height by a positive constant — the location of the peak (the ) is unchanged. Why is taking the log allowed without changing the answer? ::: is strictly increasing, so it never moves a taller point below a shorter one — the location of the peak is preserved. What confirms the critical point is a maximum, not a minimum? ::: The second derivative is negative for all valid , so the curve is concave down (a peak).


See also: Method of Moments (a different fitting recipe), Bayesian Estimation (adds a prior over ), Fisher Information and Cramér-Rao Bound (how sharp the peak is), Gaussian Distribution (the next worked case), Bias-Variance Tradeoff (why the MLE variance estimate is biased).