ContentsChapter 3 · Statistics and optimisation2 of 4

3.2

Priors and MAP

In this chapter
  1. 3.1Maximum likelihood
  2. 3.2Priors and MAP
  3. 3.3Gradient descent and convexity
  4. 3.4Lagrange multipliers
Before you readThe same coin gives three heads in five flips. Before flipping, you had reason to expect tails. Should your estimate still be 3/53/5
Watch: Maximum a posteriori (MAP) estimation · Data and Knowledge Modeling and Analysis

A prior p(θ)p(\theta) describes your uncertainty about the parameter before seeing the data DD Once you see DD Bayes’ rule gives the posterior:

p(θ∣D)=p(D∣θ) p(θ)p(D).p(\theta\mid D)=\frac{p(D\mid\theta)\,p(\theta)}{p(D)}.

The maximum a posteriori (MAP) estimate is the mode of that posterior. The denominator does not vary with θ\theta so you can just maximise the likelihood times the prior. With a uniform prior over the same parameter range, that gives the MLE.

For the five coin flips, try a prior with density proportional to (1−θ)k(1-\theta)^k on [0,1][0,1] When k=0k=0 it is uniform; increasing kk favours smaller values of θ\theta Multiplying by the likelihood gives a posterior proportional to θ3(1−θ)2+k\theta^3(1-\theta)^{2+k} Its peak is at 3/(5+k)3/(5+k) the same calculation as MLE, with kk extra in the tails exponent.

00.5100.20.40.60.81
MLE = 0.600MAP = 0.375
The prior (dotted), likelihood (solid) and posterior (dashed) are each scaled to peak at 1. At k = 0, the prior is flat and the two peaks coincide.

Taking negative logs turns MAP into a data loss plus a penalty, −log⁡p(D∣θ)−log⁡p(θ)-\log p(D\mid\theta)-\log p(\theta) A zero-mean Gaussian prior on weights gives a squared-weight penalty.

Recall
What does MAP maximise that MLE does not?
Recall
Why can you ignore the denominator in Bayes' rule when finding MAP?
Exercise
Use the five flips from the likelihood section with a prior proportional to (1−θ)3(1-\theta)^3 Find the MAP estimate of θ\theta
Exercise
A Gaussian posterior density is proportional to exp⁡(−(x−2)2/8)\exp(-(x-2)^2/8) Find its mode by setting the derivative of its log density to zero.