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(\theta | X) = \frac{P(X | \theta) P(\theta)}{P(X)}$$

$$\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 = X w + \epsilon$ with Gaussian noise $\epsilon \sim \mathcal{N}(0, \sigma^2)$:

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

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

$$\ln P(w) = -\frac{1}{2\tau^2} |w|_2^2 + \text{const}$$

$$\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(w_j) = \frac{1}{2b} \exp\left(-\frac{|w_j|}{b}\right)$:

$$\ln P(w) = -\frac{1}{b} |w|_1 + \text{const}$$

$$\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)
Formulation$\arg\max_\theta P(X | \theta)$$\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(\theta)$
Overfitting RiskHigh on small datasetsLow (Prior acts as explicit regularizer)
Large Data Limit ($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