Maximum Likelihood & MAP Estimation
Prerequisites
🎯 Learning Objectives
- Formulate the likelihood function for common distributions
- Derive MLE for Bernoulli, Gaussian, and Poisson distributions
- Use the log-likelihood trick to simplify optimization
- State MAP estimation and its relationship to MLE and priors
- Compare MLE vs MAP vs full Bayesian inference
1. Maximum Likelihood Estimation
Likelihood Function
Given data D = {x1, …, xn} assumed i.i.d. from a distribution with parameter θ:
The MLE is: θ̂MLE = argmaxθ L(θ)
Log-Likelihood Essential Trick
Since log is monotonically increasing, maximizing log-likelihood gives the same θ̂ as maximizing likelihood, but products become sums — much easier to differentiate.
2. MLE for Common Distributions
Bernoulli Distribution
Example GATE Favorite
Data: n coin flips with k heads. P(xi | p) = pxi(1−p)1−xi
ℓ(p) = k log p + (n−k) log(1−p)
Setting dℓ/dp = k/p − (n−k)/(1−p) = 0:
10 flips, 7 heads ⇒ p̂ = 7/10 = 0.7
Normal (Gaussian) Distribution
MLE for Normal
Data: x1, …, xn ~ N(μ, σ2)
Note: MLE for variance divides by n (biased), not n−1.
Poisson Distribution
MLE for Poisson GATE Style
P(x|λ) = e−λλx/x!. ℓ(λ) = −nλ + (∑ xi) log λ − ∑ log(xi!)
Data: {2, 3, 1, 4, 2} ⇒ λ̂ = 12/5 = 2.4
3. MAP Estimation
Maximum A Posteriori Estimation
MAP incorporates a prior P(θ) over the parameter. In log form:
Example — Bernoulli with Beta Prior
Prior: Beta(α, β). Data: k heads in n flips.
With Beta(2,2) prior and 7 heads in 10 flips: p̂MAP = (7+1)/(10+2) = 8/12 ≈ 0.667
Compare with MLE = 0.7. The prior "pulls" the estimate toward 0.5.
MLE vs MAP vs Full Bayesian
| Method | Formula | Uses Prior? |
|---|---|---|
| MLE | argmax P(D|θ) | No |
| MAP | argmax P(θ|D) | Yes (point estimate) |
| Full Bayesian | P(θ|D) entire posterior | Yes (full distribution) |
MLE with Uniform Prior = MAP
If the prior is uniform (flat), then MAP reduces to MLE since log P(θ) is constant.
Summary
- MLE: maximize likelihood (or log-likelihood) — no prior needed
- MLE for Bernoulli = sample proportion, for Gaussian = sample mean and (biased) variance
- MAP: maximize posterior = likelihood × prior — acts as regularization
- MAP with uniform prior = MLE
- Log-likelihood converts products to sums — a key computational trick