For Bayesian linear regression with prior w∼N(0,α−1I) and likelihood t∼N(Φw,β−1I), how do you derive the posterior p(w∣t) by completing the square, and how does its mean relate to ridge regression?

Probabilistic models, Bayesian linear regression
Level L3 Intermediate. Length Long. Nature Mat Mathematical.

What's being asked

Whether you can combine a Gaussian prior and likelihood by completing the square.

Key idea

The log posterior is quadratic in w, so the posterior is Gaussian with SN−1=αI+βΦ⊤Φ and mN=βSNΦ⊤t.

Steps

  1. Here Φ is the N×M design matrix, α is the prior precision and β is the noise precision. By Bayes' rule ln⁡p(w∣t)=−β2∥t−Φw∥2−α2w⊤w+const.
  2. Expand the first term and collect: −12w⊤(αI+βΦ⊤Φ)w+β w⊤Φ⊤t+const.
  3. Compare with the general Gaussian form −12(w−m)⊤S−1(w−m)=−12w⊤S−1w+w⊤S−1m+const.
  4. Matching the quadratic term gives SN−1=αI+βΦ⊤Φ. Matching the linear term gives SN−1mN=βΦ⊤t, so mN=βSNΦ⊤t.
  5. Ridge link: the mode of the posterior minimises ∥t−Φw∥2+αβ∥w∥2. So mN=(Φ⊤Φ+λI)−1Φ⊤t with λ=α/β.
  6. The Bayesian answer also gives the covariance SN, which ridge regression does not. As α→0 we recover the least-squares solution with a covariance (βΦ⊤Φ)−1.

Common mistakes

How long your answer should be

A page. About 6 minutes.

Last checked on 4 December 2026.

Read this

Previous in Probabilistic models: For a mixture of Bernoulli distributions on binary vectors x∈{0,1}D, with p(x)=∑kπk∏dμkdxd(1−μkd)1−xd, how do you derive the E-step and M-step updates of EM?
Next in Probabilistic models: Show that the predictive distribution of Bayesian linear regression at a new input x has variance σN2(x)=1β+ϕ⊤SNϕ, where ϕ=ϕ(x) is the feature vector. How do you show that the second term can only shrink when a new data point is added?