Math & Statistics

MAP vs MLE

Frequentist likelihood maximization vs Bayesian posterior maximization with prior regularization.

🟡 intermediate4 min readbayesianestimation
Maximum Likelihood Estimation (MLE) maximizes data likelihood P(X | θ) ignoring prior beliefs. Maximum A Posteriori (MAP) incorporates a prior distribution P(θ), maximizing posterior P(θ | X) ∝ P(X | θ) P(θ). MAP acts as regularized MLE: assuming a zero-mean Gaussian prior P(θ) yields L2 Regularization (Ridge), while a Laplacian prior yields L1 Regularization (Lasso). As dataset size N → ∞, MAP converges to MLE.

The Derivation Bridge

Applying Bayes' Theorem to parameter estimation:

P(θ∣X)=P(X∣θ)P(θ)P(X)P(\theta | X) = \frac{P(X | \theta) P(\theta)}{P(X)} θ^MAP=arg⁡max⁡θln⁡P(θ∣X)=arg⁡max⁡θ[ln⁡P(X∣θ)+ln⁡P(θ)]\hat{\theta}_{\text{MAP}} = \arg\max_\theta \ln P(\theta | X) = \arg\max_\theta \left[ \ln P(X | \theta) + \ln P(\theta) \right]
  MLE Objective:    arg max_θ [ Log-Likelihood: ln P(X | θ) ]
  MAP Objective:    arg max_θ [ Log-Likelihood: ln P(X | θ)  +  Log-Prior: ln P(θ) ]
                                                                     │
                                                            Acts as Regularizer!

How MAP Derives L1 and L2 Regularization

Given Linear Regression y=Xw+ϵy = X w + \epsilon with Gaussian noise ϵ∼N(0,σ2)\epsilon \sim \mathcal{N}(0, \sigma^2):

1. Gaussian Prior   ⟹  \implies L2 Regularization (Ridge)

Assume prior wj∼N(0,τ2)w_j \sim \mathcal{N}(0, \tau^2):

ln⁡P(w)=−12τ2∥w∥22+const\ln P(w) = -\frac{1}{2\tau^2} \|w\|_2^2 + \text{const} w^MAP=arg⁡min⁡w[∑i=1N(yi−wTxi)2+λ∥w∥22](λ=σ2τ2)\hat{w}_{\text{MAP}} = \arg\min_w \left[ \sum_{i=1}^N (y_i - w^T x_i)^2 + \lambda \|w\|_2^2 \right] \quad \left( \lambda = \frac{\sigma^2}{\tau^2} \right)

2. Laplace Prior   ⟹  \implies L1 Regularization (Lasso)

Assume prior P(wj)=12bexp⁡(−∣wj∣b)P(w_j) = \frac{1}{2b} \exp\left(-\frac{|w_j|}{b}\right):

ln⁡P(w)=−1b∥w∥1+const\ln P(w) = -\frac{1}{b} \|w\|_1 + \text{const} w^MAP=arg⁡min⁡w[∑i=1N(yi−wTxi)2+λ∥w∥1](λ=σ2b)\hat{w}_{\text{MAP}} = \arg\min_w \left[ \sum_{i=1}^N (y_i - w^T x_i)^2 + \lambda \|w\|_1 \right] \quad \left( \lambda = \frac{\sigma^2}{b} \right)

Comparison Matrix

PropertyMLE (Maximum Likelihood)MAP (Maximum A Posteriori)
Formulationarg⁡max⁡θP(X∥θ)\arg\max_\theta P(X \| \theta)arg⁡max⁡θP(X∥θ)P(θ)\arg\max_\theta P(X \| \theta) P(\theta)
Philosophical ViewFrequentist (Parameters are fixed unknown constants)Bayesian (Parameters have probability distributions)
PriorsNo prior knowledge usedIncorporates explicit prior P(θ)P(\theta)
Overfitting RiskHigh on small datasetsLow (Prior acts as explicit regularizer)
Large Data Limit (N→∞N \to \infty)IdenticalConverges to MLE (Data dominates prior)

Say this out loud

"MLE maximizes data likelihood P(X|θ) without priors, making it prone to overfitting on small datasets. MAP incorporates a prior P(θ), maximizing log P(X|θ) + log P(θ). MAP bridges statistics and ML regularization: a Gaussian prior over weights derives L2 regularization (Ridge), while a Laplacian prior derives L1 regularization (Lasso). As sample size N grows, MAP converges to MLE."

Follow-ups to expect

Check yourself

Question 1 of 3

What happens to MAP estimation when the prior P(θ) is chosen to be a uniform flat distribution (uninformative prior)?

More in Math & Statistics

See all →
Bayes’ Theorem4 minCentral Limit Theorem4 minLaw of Large Numbers4 min