Gaussian Process Regression
GP regression estimates an unknown function from noisy observations with , by placing a Gaussian process prior on the function itself. Because the joint distribution of observations and test values is multivariate Gaussian, the posterior is a GP with closed-form mean and kernel.
Given test point and Gram matrix with and :
Setting gives the interpolation case; with noise, observations are allowed to disagree with the estimate and repeated measurements at the same become informative. The marginal likelihood
is used to learn kernel hyperparameters by empirical Bayes or full posterior sampling.Computational cost: the naive posterior computation is from inverting the matrix . Scalability beyond requires inducing-point or low-rank approximations (not in scope here). When the kernel has a linear component with improper priors, the Sherman-Morrison-Woodbury identity makes the limit well-defined and computable.
Prerequisites
- 3.10 Gaussian Processes — parent index.
- 3.10.1 Kernels — kernel design and algebra.
- 6.2 Multivariate Gaussian Distribution — conditioning formula for jointly Gaussian vectors.
- 3.7 Marginal Likelihood — used for hyperparameter estimation.
Intuition
GP regression is the nonparametric analog of 3.8.1 Bayesian Linear Regression. Instead of putting a prior on a finite-dimensional coefficient vector , put a prior directly on the function . The rest follows: the posterior of given noisy observations is a new GP, the posterior mean is a kernel-weighted smoother, and the posterior variance grows smoothly between observation points — small near data, large far from data.
Two kinds of uncertainty get combined. The noise variance captures how much the deviate from . The kernel variance captures how much prior uncertainty there is about itself. The regularized-kernel matrix cleanly combines both: the term is the exact same diagonal loading that makes the linear-regression MAP into ridge regression, and here it plays the analogous role of keeping the matrix invertible and damping overfitting.
Unlike interpolation, observations are averaged rather than exactly matched. At an observed input , the posterior mean of need not equal — it typically pulls toward the GP prior mean (zero) and toward neighboring observations. Repeated noisy measurements at the same are informative: each reduces posterior variance at as more information accumulates.
Properties
(Posterior is a GP) Closed-form posterior mean and kernel.
The posterior process is itself a Gaussian process with mean function and covariance kernel
where . Because the posterior is itself a GP, any functional of (derivative, integral, linear predictor) is also Gaussian with computable mean and variance. This closure under conditioning is what makes GPs so clean to work with analytically.
(Posterior Mean is a Kernel Smoother) Linear combination of observed values.
The posterior mean is a linear combination of the observations with weights depending only on inputs and kernel, not on . Writing , the predictor is — a weighted sum of kernel functions centered at the training inputs. This is formally identical to the predictor in kernel ridge regression, which reveals that GP regression and kernel ridge regression are the same algorithm with different probabilistic interpretations.
(Posterior Variance Ignores Observations) Depends only on inputs and kernel.
The posterior variance depends on the inputs and the test point , but not on the observed values. This is because the conditional covariance of a Gaussian depends only on the covariance matrix, not on the observed values. A counterintuitive consequence: the posterior variance can be computed before any data is collected. This is the basis for Bayesian optimization and active learning strategies, which choose new query points to minimize posterior variance before looking at .
(Hyperparameter Estimation via Marginal Likelihood) Optimize evidence, not held-out loss.
The kernel depends on hyperparameters (length-scale, signal variance, etc.) and the noise level . These are estimated by maximizing (or placing priors on) the log-marginal likelihood:
The first term rewards fit, the second penalizes complexity — the log-determinant is large when the kernel allows high-variance functions, providing automatic regularization. Unlike cross-validation, marginal likelihood does not require held-out data and uses all observations. Full details and computational tricks in 3.7 Marginal Likelihood.
(Sherman-Morrison-Woodbury for Infinite-Variance Priors) Linear components with priors are handled analytically.
When the kernel has a linear component with (flat priors on intercept and slope), direct computation is unstable. Using the Woodbury identity
and sending , the posterior mean for the combined kernel reduces to
where and . This expression depends only on the identifiable ratio , not on and separately. The first term is the ordinary-least-squares fit projected onto the linear component; the second is the IBM-smoothed residual.
(Computational Cost is ) Dominated by the matrix solve.
Computing requires a Cholesky factorization of the matrix, which costs time and memory. This makes naive GP regression impractical beyond . Standard scaling strategies (not in scope here): inducing-point approximations ( with inducing points), structured kernel interpolation, random-feature approximations, or Kronecker methods when inputs lie on a grid. For the problem sizes in STAT 238 (a few hundred observations), the cost is inconsequential.
(Separable-Noise Predictive Distribution) Predictions account for both signal and noise variance.
To predict a new noisy observation rather than the underlying , add to the posterior variance:
The noise variance cleanly separates: predictions of the underlying function are narrower than predictions of new observations by exactly . This is the GP analog of the prediction-interval / confidence-interval distinction in linear regression.
Derivation
Start from the joint distribution of the noisy observations and the latent value at a test point. Under the prior, is a GP with mean zero and kernel , so
using and . Applying the standard Gaussian conditioning formula
with , , , , gives the headline result. The derivation extends immediately to joint prediction at multiple test points by replacing the scalar with a test vector and adjusting matrix dimensions.
Examples
(Easy) Predict a GP with Brownian motion kernel between two observations.
Observe at and at , both with noise . Use the scaled BM plus constant kernel with and . Predict .
Solution. With , the posterior mean becomes the linear interpolant (Example 2.1 in L22):
Outside , the posterior mean is constant-extrapolated: , . This confirms that the Brownian motion kernel induces linear interpolation inside the observed range and constant extrapolation outside.
(Medium) Hyperparameter fitting via marginal-likelihood grid.
Given observations and the scaled-IBM-plus-linear-term kernel with ratio , sketch how to learn and from the data.
Solution. Place a prior on (log-uniform). After integrating out analytically (inverse-Gamma conjugacy) and letting via Sherman-Morrison-Woodbury, the marginal posterior of is
with . Workflow:
- Choose a grid (log-spaced between underfit and overfit extremes).
- Evaluate on the grid.
- Sample from the discrete grid posterior.
- For each -sample, draw from the inverse-Gamma conditional.
- For each pair, draw and the posterior function values via the closed-form Gaussian formulas.
This produces posterior samples of the function — full Bayesian inference without MCMC.
(Hard) Two noisy measurements at the same input reduce posterior variance.
Observe and both at , with noise . Use an RBF kernel with and any length-scale . Compute the posterior mean and variance of .
Solution. Both observations are at the same input, so the Gram matrix is
Inverting gives . The vector (both at ). Posterior mean:
close to the mean of the two observations (1.0) but shrunk slightly toward the prior mean (0). Posterior variance:
smaller than the posterior variance from a single observation . Replication at the same input did tighten the posterior — as expected.
See Also
- 3.10 Gaussian Processes — parent index.
- 3.10.1 Kernels — kernel design and algebra.
- 3.10.3 Integrated Brownian Motion — the IBM kernel used in the STAT 238 running example.
- 3.8.1 Bayesian Linear Regression — parametric cousin; GP regression is the nonparametric limit.
- 3.7 Marginal Likelihood — engine for hyperparameter estimation.
- 6.2 Multivariate Gaussian Distribution — conditioning formula.