Part III — Probability, Information Theory & Bayesian Inference · Chapter 7

Maximum A Posteriori (MAP) estimation

Hook

Maximum likelihood trusts the data completely — four flips is a tiny sample, and MLE will happily report p^=0.75\hat{p}=0.75 off of it. What if you walked in already believing tails were a bit more likely?

Intuition
HHHT
MLE p=0.75 (faint curve) vs. MAP p=0.500 (bold curve, α=2, β=4)

The faint curve is the plain likelihood from the flips alone; the bold curve adds in a tails-favoring prior. Dial the prior's strength up and watch the bold curve's peak slide away from the faint curve's — that gap is the prior's influence.

Formalize

Bayes' rule turns a likelihood into a posterior by multiplying in a prior belief over the parameter itself. The MAP estimate maximizes that posterior instead of the raw likelihood:

p^MAP=argmaxp[logL(p)+logπ(p)]\hat{p}_{\text{MAP}} = \arg\max_p \big[\log L(p) + \log \pi(p)\big]
  • p^MAP\hat{p}_{\text{MAP}} — the maximum a posteriori estimate.
  • L(p)L(p) — the data likelihood, same as in plain MLE.
  • π(p)\pi(p) — the prior density over pp, encoding belief held before seeing any data.

Using a Beta(α,β)(\alpha,\beta) prior — encoded as α1\alpha-1 imagined extra heads and β1\beta-1 imagined extra tails — gives a closed form that looks just like the MLE with pseudo-counts folded in:

p^MAP=k+α1n+α+β2\hat{p}_{\text{MAP}} = \frac{k+\alpha-1}{n+\alpha+\beta-2}
  • α,β\alpha,\beta — the prior's pseudo-counts: imagined extra heads and tails, respectively.
  • k,nk, n — the actually observed heads and total flips, exactly as in MLE.
  1. A uniform prior (α=β=1) reduces exactly to MLE

    Plug in α=β=1\alpha=\beta=1 and the pseudo-counts vanish: p^MAP=k/n=p^MLE\hat{p}_{\text{MAP}} = k/n = \hat{p}_{\text{MLE}}.

  2. MAP is a compromise, not a replacement

    p^MAP\hat{p}_{\text{MAP}} always sits between the prior's own mean α/(α+β)\alpha/(\alpha+\beta) and the MLE — more data pulls it toward the MLE; a stronger prior pulls it toward the prior mean.

  3. The normalizing constant never matters

    The true posterior divides by P(data)P(\text{data}), but that constant doesn't depend on pp, so it can never change where the maximum sits — only the unnormalized numerator matters for MAP.

Play
HHHT
prior mean=0.333, MLE=0.75, MAP=0.500 — MAP sits between the prior mean and the MLE

At strength 0 the two peaks coincide exactly — an uninformative prior changes nothing. Every notch up adds more imagined tails-observations, and the MAP estimate keeps sliding toward the prior's own mean.

Worked example

Same four flips as the MLE chapter's toy — H, H, H, T, so k=3k=3, n=4n=4 — now with a Beta(α=2,β=4\alpha{=}2,\beta{=}4) prior.

  1. The MLE, ignoring the prior entirely
    p^MLE=34=0.75\hat{p}_{\text{MLE}} = \frac{3}{4} = 0.75
  2. Apply the MAP closed form
    p^MAP=k+α1n+α+β2=3+214+2+42=48=0.5\hat{p}_{\text{MAP}} = \frac{k+\alpha-1}{n+\alpha+\beta-2} = \frac{3+2-1}{4+2+4-2} = \frac{4}{8} = 0.5
  3. Compare to the prior's own mean

    The prior alone believes α/(α+β)=2/60.333\alpha/(\alpha+\beta) = 2/6 \approx 0.333. The MAP estimate, 0.50.5, lands exactly between that prior belief and the MLE's 0.750.75 — pulled by the prior, not overridden by it.

Checkpoint

3 heads out of 4 flips, with a Beta(α=2, β=4) prior (mean 0.333). What is the MAP estimate of p?

HHHT
Pick a value to try it
Summary
p^MAP=k+α1n+α+β2\hat{p}_{\text{MAP}} = \frac{k+\alpha-1}{n+\alpha+\beta-2}

MAP estimation is MLE with a built-in regularizer: prior pseudo-counts act exactly like extra observations, pulling small-sample estimates back toward a belief you held before seeing any data — the same mechanism that shows up later as L2 regularization's Gaussian prior on weights.