1.3.17 · D3Probability & Statistics

Worked examples — Maximum a posteriori estimation (MAP)

2,870 words13 min readBack to topic

This page is a drill. Its parent, MAP estimation, showed you the machinery: . Here we throw every kind of situation at that machinery so no exam question can surprise you.

First, one symbol we will use on every line:

Now a tiny reminder of the words, in plain language, each anchored to a picture below:

MAP is just "find the highest point of likelihood times prior." Everything below is that one sentence, stress-tested.


The scenario matrix

Every MAP problem falls into one of the eight cells A–H below. Read the table as "cell → what makes it tricky → which example drills it." Each worked example later is tagged with its cell letter, so you can hunt any scenario by its label. Think of A–H as a checklist: if you can do all eight, no MAP question is new to you.

Cell Cell class What makes it tricky Example
A Prior disagrees with data prior pulls estimate one way, data pulls the other Ex 1
B Data-scarce vs data-rich limit small (prior dominates) → large (data dominates) Ex 2
C Degenerate: zero successes () MLE gives ; does MAP? Ex 3
D Degenerate: uniform prior MAP must collapse exactly to MLE Ex 4
E Mode mean (asymmetric posterior) which number to report Ex 5
F Regularization face (Gaussian prior = L2) see the penalty become a prior Ex 6
G Real-world word problem translate English → likelihood + prior Ex 7
H Exam twist: prior with or forcing a boundary solution derivative never zero inside; check the edges Ex 8

Prerequisites in reach: Bayes Theorem, Beta Distribution, Posterior Distribution, Conjugate Priors, Maximum Likelihood Estimation (MLE), Regularization in ML.

Figure — Maximum a posteriori estimation (MAP)

Figure 1 (read me first). The blue curve is the likelihood , the pink curve is the prior , and the yellow curve is their point-by-point product, the posterior. The dashed yellow line marks its peak — the MAP estimate. This single picture is the template for Examples 1–5 and 8: those all live on this axis, just with different blue and pink shapes. Keep it in view.


Coin-flip cells (Beta prior + Binomial data)

Whenever the data is "successes out of trials," the likelihood is Binomial and the natural prior is a Beta. Recall the Beta shape for . Because Beta is the conjugate prior for the Binomial, the posterior is again Beta:

Why this mode formula, and why the edge checks? Take and differentiate: the slope is . Setting it to gives the fraction. But a stationary point only exists inside when both and have the sign that makes the two terms trade off. If, say, , the first term never pulls the slope positive, so the function only falls — its highest point is the boundary . That is why you cannot blindly plug in: the ""s can push you onto an edge. (The same "" mismatch also makes the mode differ from the mean — a distinction Ex 5 hammers home.)



Figure — Maximum a posteriori estimation (MAP)

Figure 2 (this is Example 2). Each curve is the posterior for one of the three sample sizes in Example 2. As climbs (blue → pink → yellow), the peak slides from toward (the dashed white MLE line) and narrows — more data buys both accuracy and confidence. The dotted vertical lines are the three MAP peaks you computed above.





Gaussian / regularization cells

For continuous parameters with Gaussian noise, the likelihood peak is the sample mean , and a Gaussian prior shrinks it toward the prior mean. This shrinkage is L2 regularization — see Regularization in ML, Ridge Regression.




Recall Quick self-test (cover the answers)

What does MAP report, mode or mean? ::: The mode (peak) of the posterior. Beta prior turns MAP into what? ::: Exactly the MLE (uniform prior). Before using the Beta mode formula, what must you check? ::: That both posterior shape numbers exceed 1 ( and ); otherwise the peak is on an edge ( or ). Zero heads in flips: why is MLE dangerous but MAP safe? ::: MLE gives (impossible-heads-forever); a Beta prior with keeps so MAP stays inside . L2 regularization with strength is MAP with which prior? ::: Gaussian with . When does the "set derivative to zero" step fail? ::: When or — the maximum is on the boundary, so check the endpoints.