Show that ridge regression is the MAP (maximum a posteriori) estimate under a Gaussian prior, and lasso under a Laplace prior, when the noise is Gaussian. If the noise variance is σ2=2 and the prior is βj∼N(0,τ2) with τ2=0.5, what ridge λ does this give?

Supervised learning, Ridge, lasso and Bayesian priors
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can write the log posterior and read off the penalty and its strength from the prior.

Key idea

−log⁡p(β∣y)=12σ2∥y−Xβ∥2−log⁡p(β)+const. A Gaussian prior gives an L2 penalty with λ=σ2/τ2. A Laplace prior gives an L1 penalty.

Steps

  1. Likelihood: y∣β∼N(Xβ,σ2I), so −log⁡p(y∣β)=12σ2∥y−Xβ∥2+const.
  2. Gaussian prior βj∼N(0,τ2): −log⁡p(β)=12τ2∥β∥2+const.
  3. Maximising the posterior equals minimising the sum. Multiply by 2σ2: ∥y−Xβ∥2+σ2τ2∥β∥2, which is ridge with λ=σ2/τ2.
  4. Numbers: λ=2/0.5=4. A tighter prior (smaller τ2) means a larger λ and more shrinkage.
  5. Laplace prior p(βj)=12be−∣βj∣/b: −log⁡p(β)=1b∥β∥1+const. Multiplying by 2σ2 gives lasso with λ1=2σ2/b.
  6. Note: the Laplace density is sharply peaked at 0, which is why the MAP estimate can be exactly zero. The posterior mean under this prior is not sparse.

Common mistakes

How long your answer should be

Half a page; 5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Supervised learning: The elastic net minimises ∥y−Xβ∥2+λ2∥β∥22+λ1∥β∥1. How do you show that it is a lasso problem on augmented data, and what does this imply for the number of variables it can select and for correlated features?
Next in Supervised learning: Take an orthonormal design (X⊤X=I) with noise variance σ2. For one coefficient with true value β, find the mean squared error of the ridge estimate β^/(1+λ) as a function of λ. Show that some λ>0 always beats OLS, find the best λ, and evaluate it for σ2=1, β=2. Why is this not a free lunch?