Foundations to Frontier
Tests
A. Mathematical Foundations › A5 Statistics › Bayesian statistics

MAP Estimation and Its Link to Regularization

The maximum a posteriori (MAP) estimate is the peak of the posterior: maximize log-likelihood + log-prior. That turns every prior into a penalty: a Gaussian prior is ridge regression (L2, weight decay), a Laplace prior is the lasso (L1, sparsity), and a prior centred on datasheet values pulls identified parameters toward physics. You will derive these equivalences, see why L1 gives exact zeros, use prior strength λ = σ²/τ² as a principled knob, learn what MAP loses compared with the full posterior (uncertainty, and invariance to reparameterization), and identify a robot joint's friction from a handful of samples.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Don’t believe wild answers from little data

Fit a model to only a few noisy measurements and it may give extreme answers, like a motor friction ten times larger than any real motor has. If you already know roughly what values are reasonable, you should prefer answers near them unless the data strongly disagree. That’s a prior. Picking the single most probable answer given data and prior is MAP estimation.

Engineers often do this without calling it Bayesian: “regularization” or “weight decay” in machine learning is exactly a prior that says “smaller weights are more plausible”.

A prior is a regularizer: ridge (Gaussian) vs lasso (Laplace)
w₁w₂
least squares (MLE) w = (2.162, 0.272) · MAP w = (1.794, 0.000) · w₂ is exactly 0
Thin contours: equal-likelihood ellipses around the least-squares point (uncoloured dot). The shaded circle or diamond is the prior's level set through the MAP point (orange), where it just touches a likelihood contour (dashed). Purple: the MAP path as λ grows from 0.1 to 200. The Gaussian prior shrinks both weights smoothly. The Laplace prior's corners snap the weaker, correlated feature to exactly zero: sparsity.
Why engineers care

Identifying robot dynamics from short experiments, training neural networks that generalize, and picking out the few sensors that matter from hundreds all rely on regularization, which is MAP with a prior. Knowing the link tells you how to set the regularization strength sensibly.

📝 Quick check (Level 0)
0/3 answered
  1. 1. MAP picks the parameter value that is…
  2. 2. Weight decay in ML corresponds to…
  3. 3. With very little data, a prior helps by…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Definition

θ^MAP=arg⁡max⁡θp(θ∣x)=arg⁡max⁡θ[log⁡p(x∣θ)+log⁡p(θ)]\hat\theta_{\text{MAP}} = \arg\max_\theta p(\theta\mid x) = \arg\max_\theta\big[\log p(x\mid\theta) + \log p(\theta)\big]

Because p(x)p(x) doesn’t depend on θ\theta, it doesn’t affect the maximizer. With a flat prior, MAP equals MLE.

Priors are penalties

For linear regression y=Xw+εy = Xw + \varepsilon with ε∼N(0,σ2I)\varepsilon\sim\mathcal N(0, \sigma^2I):

Prior on ww MAP problem Name
N(0,τ2I)\mathcal N(0, \tau^2I) min⁡∥y−Xw∥2+λ∥w∥22\min\lVert y - Xw\rVert^2 + \lambda\lVert w\rVert_2^2 ridge, weight decay
Laplace(0, b) min⁡12∥y−Xw∥2+λ∥w∥1\min\frac12\lVert y - Xw\rVert^2 + \lambda\lVert w\rVert_1 lasso
N(θ0,τ2I)\mathcal N(\theta_0, \tau^2I) min⁡∥y−Xw∥2+λ∥w−θ0∥2\min\lVert y - Xw\rVert^2 + \lambda\lVert w - \theta_0\rVert^2 shrink toward a reference

For ridge, λ=σ2/τ2\lambda = \sigma^2/\tau^2: noisy data or a confident prior mean strong regularization. The closed form is w^=(X⊤X+λI)−1X⊤y\hat w = (X^\top X + \lambda I)^{-1}X^\top y, which also fixes ill-conditioned or rank-deficient X⊤XX^\top X (A2.3-7).

📝 Quick check (Level 1)
0/3 answered
  1. 1. A Gaussian prior on regression weights gives…
  2. 2. For ridge, λ =
  3. 3. With a flat prior, the MAP equals…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.

Why L1 gives exact zeros

The lasso’s optimality condition for coordinate jj is Xj⊤(y−Xw)=λ ∂∣wj∣X_j^\top(y - Xw) = \lambda\,\partial\lvert w_j\rvert, where the subgradient ∂∣0∣=[−1,1]\partial\lvert0\rvert = [-1, 1]. If the correlation with the residual is below λ\lambda in absolute value, wj=0w_j = 0 is optimal. The coordinate update is the soft-threshold wj=Sλ(zj)/∥Xj∥2w_j = S_\lambda(z_j)/\lVert X_j\rVert^2, with Sλ(z)=sign⁡(z)max⁡(∣z∣−λ,0)S_\lambda(z) = \operatorname{sign}(z)\max(\lvert z\rvert - \lambda, 0). Geometrically, the L1 ball’s corners touch the likelihood contours on the axes (see the demo). L2’s round ball almost never does.

Choosing λ

  1. From the model: σ2\sigma^2 from noise calibration and τ2\tau^2 from prior knowledge.
  2. From data: cross-validation, or empirical Bayes (maximize the marginal likelihood over τ\tau, A5.2-5).

What MAP gives up

  • Uncertainty: a point estimate says nothing about how wide the posterior is. The Laplace approximation adds a Gaussian around the MAP, with covariance (−∇2log⁡p(θ∣x))−1(-\nabla^2\log p(\theta\mid x))^{-1}.
  • Invariance: reparameterizing (pp vs logit⁡p\operatorname{logit}p) changes the density by a Jacobian factor, so it moves the mode. The posterior mean and median don’t have this problem.
  • Representativeness: in high dimensions the mode can be atypical (most of the mass is far from it), and for multimodal posteriors it picks one bump.
🐍 Exercise 1: ridge and lasso as MAP estimates
Implement ridge (closed form) and lasso (coordinate descent with soft-thresholding). Check that ridge with λ = σ²/τ² zeroes the gradient of the Gaussian-prior negative log posterior, and that the lasso gives exact zeros while keeping the real effects.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Soft-thresholding z = 0.4 with t = 0.5 gives…
  2. 2. The Laplace approximation's covariance is…
  3. 3. Is the MAP invariant to reparameterization?

Level 3: Advanced

★★★★☆ Advanced⏱ 40 minGraduate level, with full derivations and proofs.

Derivation: ridge = Gaussian MAP

−log⁡p(w∣y)=12σ2∥y−Xw∥2+12τ2∥w∥2+const-\log p(w\mid y) = \frac1{2\sigma^2}\lVert y - Xw\rVert^2 + \frac1{2\tau^2}\lVert w\rVert^2 + \text{const}

Multiply by 2σ22\sigma^2 to get ∥y−Xw∥2+σ2τ2∥w∥2\lVert y - Xw\rVert^2 + \frac{\sigma^2}{\tau^2}\lVert w\rVert^2. Setting the gradient to zero gives (X⊤X+λI)w=X⊤y(X^\top X + \lambda I)w = X^\top y. ∎ The Gaussian posterior is N((X⊤X+λI)−1X⊤y, σ2(X⊤X+λI)−1)\mathcal N\big((X^\top X + \lambda I)^{-1}X^\top y,\ \sigma^2(X^\top X + \lambda I)^{-1}\big). Its mean, median and mode coincide, so here MAP loses nothing but the covariance.

Ridge through the SVD

With X=UΣV⊤X = U\Sigma V^\top, w^=∑jsj2sj2+λuj⊤ysjvj\hat w = \sum_j\frac{s_j^2}{s_j^2 + \lambda}\frac{u_j^\top y}{s_j}v_j. Each direction is shrunk by sj2/(sj2+λ)s_j^2/(s_j^2 + \lambda): well-determined directions (large sjs_j) barely change, and poorly determined ones are damped. This is Tikhonov regularization of an ill-posed inverse problem (A2.3-5).

Why the mode moves under reparameterization

If η=g(θ)\eta = g(\theta), then pη(η)=pθ(g−1(η))∣(g−1)′(η)∣p_\eta(\eta) = p_\theta(g^{-1}(\eta))\lvert(g^{-1})'(\eta)\rvert (A4.3-2). The Jacobian factor changes where the density peaks. For a flat prior on pp with kk of nn, the mode is k/nk/n on the pp scale, but (k+1)/(n+2)(k + 1)/(n + 2) when computed on the logit scale.

Exercise 3.1: Derive the lasso as Laplace-prior MAP

With p(wj)∝e−∣wj∣/bp(w_j)\propto e^{-\lvert w_j\rvert/b}, −log⁡p(w∣y)=12σ2∥y−Xw∥2+1b∥w∥1+c-\log p(w\mid y) = \frac1{2\sigma^2}\lVert y - Xw\rVert^2 + \frac1b\lVert w\rVert_1 + c. Multiply by σ2\sigma^2: 12∥y−Xw∥2+σ2b∥w∥1\frac12\lVert y - Xw\rVert^2 + \frac{\sigma^2}b\lVert w\rVert_1, so λ=σ2/b\lambda = \sigma^2/b.

📝 Quick check (Level 3)
0/3 answered
  1. 1. Ridge shrinks the SVD direction with singular value s by the factor…
  2. 2. For a Gaussian likelihood and Gaussian prior, the MAP equals…
  3. 3. The lasso λ corresponds to…

Level 4: Expert

★★★★★ Expert⏱ 40 minResearchers: original papers and open problems.

Identifying joint friction from a few samples

A robot joint’s torque is τ=Iq¨+bq˙+csign⁡q˙\tau = I\ddot q + b\dot q + c\operatorname{sign}\dot q: inertia, viscous and Coulomb friction. It’s linear in the parameters. With only 8 short excitation samples, least squares is noisy. A Gaussian prior centred on datasheet/CAD values (MAP shrinking toward θ0\theta_0) cuts the parameter error by about 70%. With 2000 samples the prior’s influence vanishes, as it should. Physically informed priors and penalties are standard in robot dynamics identification, also to keep identified inertias physically consistent (Swevers et al., 1997; Wensing, Kim and Slotine, 2018).

🐍 Exercise 2 (research): MAP identification of joint dynamics
Simulate 400 short (8-sample) identification experiments of a 1-DOF joint with inertia, viscous and Coulomb friction. Compare least squares with MAP shrinkage toward datasheet values (λ = σ²/τ²), and show that with 2000 samples the MAP converges to the truth.

MAP and regularization in AI, robotics and aerospace

  • Deep learning. Weight decay (Gaussian prior), dropout (approximate Bayesian averaging) and early stopping (implicit L2) are all regularizers (Krogh and Hertz, 1992; Gal and Ghahramani, 2016).
  • Sparse identification of dynamics (SINDy) uses an L1 / sequential-threshold penalty over a library of candidate terms to discover governing equations from data (Brunton, Proctor and Kutz, 2016).
  • Factor-graph SLAM and bundle adjustment compute MAP estimates of poses and landmarks. Priors anchor the gauge freedom and encode odometry (Dellaert and Kaess, 2017).
  • Inverse problems in imaging and remote sensing. Tikhonov and total-variation regularization are MAP under smoothness or edge-preserving priors.
  • Compressed sensing. L1 recovery of sparse signals from few measurements (Candès, Romberg and Tao, 2006).

References

  1. A. Tikhonov (1963). “Solution of incorrectly formulated problems and the regularization method.” Soviet Mathematics Doklady, 4.
  2. A. Hoerl, R. Kennard (1970). “Ridge regression: biased estimation for nonorthogonal problems.” Technometrics, 12(1).
  3. R. Tibshirani (1996). “Regression shrinkage and selection via the lasso.” JRSS B, 58(1).
  4. T. Park, G. Casella (2008). “The Bayesian lasso.” JASA, 103(482).
  5. T. Hastie, R. Tibshirani, M. Wainwright (2015). Statistical Learning with Sparsity. CRC Press.
  6. A. Krogh, J. Hertz (1992). “A simple weight decay can improve generalization.” NeurIPS.
  7. S. Brunton, J. Proctor, J. N. Kutz (2016). “Discovering governing equations from data by sparse identification of nonlinear dynamical systems.” PNAS, 113(15).
  8. P. Wensing, S. Kim, J.-J. Slotine (2018). “Linear matrix inequalities for physically consistent inertial parameter identification.” IEEE RA-L, 3(1).
  9. F. Dellaert, M. Kaess (2017). “Factor graphs for robot perception.” Foundations and Trends in Robotics, 6(1–2).
  10. E. Candès, J. Romberg, T. Tao (2006). “Robust uncertainty principles: exact signal reconstruction from highly incomplete frequency information.” IEEE Transactions on Information Theory, 52(2).