Volume II, Chapter 5 — Part I. Full Bayesian treatment of linear regression: conjugate Gaussian prior, closed-form posterior derivation, predictive distribution with epistemic and aleatoric uncertainty, MAP–Ridge equivalence, sequential updating, and the kernel dual form leading to Gaussian processes.
Classical linear regression returns a point estimateθ^ — a single best guess for the parameters. Bayesian linear regression returns a distribution over parameters, encoding which settings are plausible given the data and prior beliefs.
Why does this matter?
Uncertainty quantification. Predictions come with confidence intervals that widen when extrapolating beyond training data.
Regularization with meaning. A prior Pr(θ) is not an ad hoc penalty — it encodes genuine beliefs about parameter magnitude before seeing data.
Sequential learning. New data updates the posterior directly; the old posterior becomes the new prior.
Foundation for advanced methods. Variational inference, Gaussian processes, and Bayesian neural networks all extend the framework developed here.
For linear regression with Gaussian noise and a Gaussian prior, the posterior is exactly Gaussian — no approximation needed. This conjugacy makes Bayesian linear regression one of the few models where full Bayesian inference is analytically tractable.
Series context. This opens Chapter 5 (Bayesian Machine Learning) in Volume II. It is followed by Variational Inference, which handles models where the posterior is not conjugate.
Bayesian Linear Regression
N = 3σ_post ≈ 1.597
Data pts3
2σ bandPosterior mean
Explore: With no data, the wide prior band reflects uncertainty. As points arrive, the posterior narrows around the best-fit slope.
From MLE to MAP to Full Bayesian Inference
Definition 1 (Likelihood). Given the Gaussian noise model yi=θTx~i+εi with εi∼N(0,σn2), the likelihood of parameters θ is
Pr(y∣X,θ)=N(y∣Xθ,σn2IN).(1)
We use the standard design matrix convention X∈RN×(d+1) with y^i=θTx~i, so y∼N(Xθ,σn2I).
Definition 2 (Three Inference Paradigms).
MLE — θ^ML=argmaxθPr(y∣X,θ) — Point estimate
MAP — θ^MAP=argmaxθPr(θ∣X,y) — Point estimate (posterior mode)
Bayesian — Compute Pr(θ∣X,y) — Full posterior distribution
Proposition 1 (MLE = OLS).The MLE is the ordinary least squares solution:
θ^ML=(XTX)−1XTy.(2)
Proof. Maximizing the Gaussian log-likelihood is equivalent to minimizing ∥Xθ−y∥2. See Linear Regression. ■
Proposition 2 (Bayes' Rule for Parameters).
Pr(θ∣X,y)=Pr(y∣X)Pr(y∣X,θ)Pr(θ).(3)
The marginal likelihood Pr(y∣X)=∫Pr(y∣X,θ)Pr(θ)dθ is the evidence. For conjugate models, it is analytically computable.
The Conjugate Gaussian Model
Definition 3 (Gaussian Prior). We place an isotropic Gaussian prior on parameters:
Pr(θ)=N(θ∣0,σp2Id+1).(4)
The prior mean 0 reflects a belief that parameters should be small. The prior variance σp2 controls strength: large σp2 is a weak (vague) prior; small σp2 strongly shrinks parameters toward zero.
Definition 4 (Conjugacy). A prior is conjugate to a likelihood if the posterior belongs to the same parametric family as the prior. The Gaussian prior is conjugate to the Gaussian likelihood — the posterior is Gaussian.
Theorem 1 (Posterior Distribution).Under the Gaussian likelihood (1) and Gaussian prior (4), the posterior is
Important equation. Equation (8) shows that the posterior mean equals the Ridge regression solution with λ=σn2/σp2. Bayesian inference and regularized frequentist estimation coincide for point predictions — but the Bayesian framework additionally provides Σpost for uncertainty.
The Predictive Distribution
Definition 5 (Posterior Predictive). For a new input x∗, the posterior predictive distribution is
Pr(y∗∣x∗,X,y)=∫Pr(y∗∣x∗,θ)Pr(θ∣X,y)dθ.(17)
Theorem 2 (Predictive Distribution).Under the conjugate Gaussian model:
The epistemic term arises from uncertainty in θ; the aleatoric term is irreducible observation noise. ■
Epistemic and Aleatoric Uncertainty
Definition 6 (Epistemic Uncertainty).Epistemic (model) uncertainty reflects incomplete knowledge about θ. It is reducible with more data — as N→∞, Σpost→0 and epistemic uncertainty vanishes.
Definition 7 (Aleatoric Uncertainty).Aleatoric (data) uncertainty reflects inherent noise in observations. It is irreducible regardless of sample size.
Proposition 3 (Extrapolation Behavior).As ∥x~∗∥→∞ in directions poorly covered by training data, x~∗TΣpostx~∗→∞ and predictive uncertainty grows without bound.
Proof sketch.Σpost is positive definite (for any λ>0). For x~∗ orthogonal to the column space of X, x~∗T(XTX)x~∗=0, so the prior term dominates and x~∗TΣpostx~∗≈σp2∥x~∗∥2. ■
This is a principled mechanism for knowing what you don't know — something point estimates cannot provide.
Sequential Bayesian Updating
Theorem 3 (Online Update).After observing a new data point (x~new,ynew), the updated posterior precision is
Σnew−1=Σold−1+σn21x~newx~newT.(21)
The updated mean satisfies
μnew=Σnew(Σold−1μold+σn21x~newynew).(22)
Proof. The old posterior becomes the new prior. Applying Lemma 2 with the new likelihood (rank-1 update to precision) yields (21)–(22). ■
Each observation adds a rank-1 term to the precision matrix — the posterior concentrates incrementally. This is the Bayesian analog of recursive least squares.
Connection to Ridge Regression
Theorem 4 (MAP–Ridge Equivalence).The MAP estimator under prior (4) is
This is Ridge regression with regularization parameter λ=σn2/σp2.
Proof. The MAP maximizes logPr(y∣X,θ)+logPr(θ), equivalent to minimizing:
2σn21∥Xθ−y∥2+2σp21∥θ∥2.(24)
Setting the gradient to zero gives (23). ■
Interpretation.λ=σn2/σp2 is the ratio of observation noise to prior uncertainty. Noisy data (σn2 large) ⟹ weak regularization. Strong prior (σp2 small) ⟹ strong shrinkage.
Computational Identities: Woodbury and Dual Form
When N≪d (few samples, many features), inverting XTX is expensive. The Woodbury matrix identity converts between primal and dual forms.
where Kij=k(x~i,x~j) and k∗=[k(x~1,x~∗),…,k(x~N,x~∗)]T.
This is the Gaussian process prediction formula with a linear kernel. Replacing the kernel with a nonlinear function (e.g., RBF) yields nonlinear Bayesian regression without explicit feature engineering — the function-space view of the same mathematics.
Worked Examples
Example 1: Single-Feature Model
Prior: σp2=1, σn2=0.5. One observation: x~=(1,2)T, y=3.
The posterior is tighter than the prior — data has reduced uncertainty.
Example 2: Predictive Uncertainty Near vs. Far from Data
For training points clustered near x~=(1,0), prediction at x~∗=(1,0) has small epistemic variance. At x~∗=(1,100), epistemic variance is large — we are extrapolating.
Example 3: Limit of Flat Prior
As σp2→∞: Σpost−1→σn21XTX, and μpost→θ^ML (when XTX is invertible). The Bayesian posterior recovers the frequentist MLE.
Variational Autoencoders apply variational inference to latent variable models where the posterior over latents is approximated rather than computed exactly.
Common Pitfalls and Misconceptions
Pitfall 1: Confusing posterior variance with prediction interval width. The posterior Pr(θ∣D) describes uncertainty about parameters. Predictive intervals for y∗ include both epistemic and aleatoric terms (20).
Pitfall 2: Using an improper prior without care. The limit σp2→∞ yields an improper (non-normalizable) prior. Predictions may be valid, but the posterior may not exist when N≤d.
Pitfall 3: Assuming Gaussian prior is always appropriate. Heavy-tailed priors (Student-t) provide robustness to outliers. The Gaussian prior penalizes large coefficients quadratically.
Pitfall 4: Ignoring hyperparameter selection.σp2 and σn2 are hyperparameters. Empirical Bayes or cross-validation selects them; treating them as fixed without justification is a form of misspecification.
Pitfall 5: Conflating MAP with full Bayesian inference. MAP gives a point estimate (posterior mode). It ignores posterior covariance and can be sensitive to reparameterization — unlike the full predictive distribution (18).
Research Perspective
Bayesian linear models date to Laplace and Gauss. The modern formulation through conjugate analysis connects to empirical Bayes (Robbins, 1955; Efron & Morris, 1973) and hierarchical modeling.
In machine learning:
Gaussian Processes (Rasmussen & Williams, 2006) generalize Bayesian linear regression to infinite-dimensional function spaces via kernels.
Bayesian deep learning attempts to place priors on neural network weights — but the posterior is intractable, motivating Variational Inference.
Uncertainty quantification in safety-critical applications (medical diagnosis, autonomous driving) relies on principled epistemic uncertainty from Bayesian methods.
Last-layer Bayesian inference — treating only the final layer as Bayesian while keeping feature extractors deterministic — provides efficient uncertainty at scale.
The conjugate Gaussian case remains the gold standard: when it applies, use it exactly rather than approximating.
Summary of Takeaways
Posterior precision — Σpost−1=σn21XTX+σp21I — Data + prior information
Posterior mean — μpost=Σpostσn21XTy — = Ridge estimate
MAP = Ridge — λ=σn2/σp2 — Bayesian interpretation of L2
Next article:Variational Inference → — for models where the posterior is not conjugate and must be approximated.
Exercises
Exercise 1 (Posterior derivation). Verify Theorem 1 by completing the square directly in θ without using Lemma 2.
Exercise 2 (Predictive distribution). Derive (18) by evaluating the integral (17) using the formula for the convolution of two Gaussians.
Exercise 3 (Sequential update). Starting from prior N(0,σp2I), derive the posterior after observing two data points sequentially. Show the result equals the posterior from observing both simultaneously.
Exercise 4 (MAP limit). Prove that as σp2→∞, μpost→(XTX)−1XTy (when invertible).
Exercise 5 (Uncertainty decomposition). For a given dataset, compute the fraction of predictive variance that is epistemic vs. aleatoric at a test point near the training data centroid vs. far from it.
Exercise 6 (Woodbury). Derive (26) by applying the Woodbury identity to μpost.
Exercise 7 (Kernel form). Show that the GP formula (27)–(28) with linear kernel reproduces the Bayesian linear regression predictive distribution.
Exercise 8 (Conceptual). Explain why the posterior covariance Σpost does not depend on y — only on X, σn2, and σp2. What does this imply about uncertainty before seeing targets?