You flip a coin a handful of times and see mostly heads. What single value of "probability of heads" makes the data you actually saw the least surprising?
Drag the candidate across the curve. Every point on it is the log-likelihood of these exact five flips under that one value of — and the curve has a single, unambiguous high point.
For independent Bernoulli trials with heads, the likelihood of the data under parameter is
- — the likelihood: how probable the observed data is, as a function of .
- — the number of heads actually observed.
- — the total number of flips.
Products of small numbers underflow fast, so in practice everyone maximizes the log-likelihood instead — same maximizer, better numerics:
- The log is monotonic, so the peak doesn't move
is strictly increasing, so whatever maximizes also maximizes — taking the log never changes where the maximum sits.
- Setting the derivative to zero gives a closed form
- Move the second term across and cross-multiply:
- Expand both sides:
- The on the left and on the right are the same term, so they cancel, leaving
Dividing both sides by gives
— the maximum likelihood estimate is exactly the observed proportion of heads, no search required.
- This is the general MLE recipe
Write the likelihood of the data under a parameter, take its log, and find where the derivative vanishes — the same three steps work for far more complex models than a coin.
The curve's exact peak sits at , matching exactly — drag away in either direction and the log-likelihood only gets worse, confirming this closed form really is the unique maximizer.
Five flips: H, H, T, H, H — so heads out of .
- Apply the closed-form MLE
- Confirm it by evaluating the log-likelihood at the estimate
- Check a nearby value scores worse
Worse (more negative) than — exactly what " is the maximizer" predicts.
4 heads out of 5 flips. Drag p until it lands on the maximum likelihood estimate.
Maximum likelihood estimation is this same idea at any scale: write down how probable your data is under a parameter, then find the parameter that makes that probability as large as possible. Logistic regression, neural network training via cross-entropy, and Gaussian curve-fitting are all MLE in disguise.