ContentsChapter 3 · Statistics and optimisation1 of 4

3.1

Maximum likelihood

In this chapter
  1. 3.1Maximum likelihood
  2. 3.2Priors and MAP
  3. 3.3Gradient descent and convexity
  4. 3.4Lagrange multipliers
Before you readA coin lands heads three times in five flips. Which value of its heads probability makes the observed flips most likely?
Watch: Maximum likelihood, clearly explained · StatQuest with Josh Starmer

In probability, you fix the model and ask how likely the data are. In likelihood, you fix the observed data and vary the model parameter θ\theta The maximum likelihood estimate (MLE) is the value of θ\theta that gives the largest likelihood.

For independent and identically distributed (iid) observations x1,…,xnx_1,\ldots,x_n independence lets you multiply their probabilities (or densities for continuous data). Taking logs turns the product into a sum without moving the maximum:

L(θ)=∏i=1np(xi∣θ),ℓ(θ)=log⁡L(θ)=∑i=1nlog⁡p(xi∣θ).\begin{aligned} L(\theta)&=\prod_{i=1}^n p(x_i\mid\theta),\\ \ell(\theta)&=\log L(\theta)=\sum_{i=1}^n\log p(x_i\mid\theta). \end{aligned}

For a Bernoulli variable, 11 has probability θ\theta and 00 has probability 1−θ1-\theta For the sequence (1,1,0,0,1)(1,1,0,0,1) this gives L(θ)=θ3(1−θ)2L(\theta)=\theta^3(1-\theta)^2

00.010.020.030.0400.20.40.60.81
Likelihood = 0.01811
Move θ and look for the peak. The five observed flips stay fixed; only the model changes.

Inside 0<θ<10<\theta<1 the log-likelihood is 3log⁡θ+2log⁡(1−θ)3\log\theta+2\log(1-\theta) Its derivative is zero when 3θ=21−θ\frac{3}{\theta}=\frac{2}{1-\theta} so θ^=3/5\hat\theta=3/5 This is the maximum: the log-likelihood is strictly concave and the likelihood vanishes at both endpoints. In general the Bernoulli MLE is the fraction of ones. If every flip is the same, the maximum is at 00 or 11 not at an interior stationary point.

Minimising negative log-likelihood is how many models fit their parameters to data.

Recall
When you maximise a likelihood, what stays fixed and what varies?
Recall
Why maximise log-likelihood instead of likelihood?
Exercise
You observe 2,4,92,4,9 from an iid Gaussian model with known variance 11 and unknown mean μ\mu Find the MLE of μ\mu
Exercise
In nn iid Bernoulli observations, ss are ones. What is the log-likelihood?
Exercise
Starting from the log-likelihood of (1,1,0,0,1)(1,1,0,0,1) find the MLE of θ\theta