Gaussian Processes
The function-space view of Bayesian learning: defining GPs via mean and covariance functions, deriving the predictive distribution in closed form, kernel design, marginal likelihood for hyperparameter optimization, and connections to neural networks.
Prerequisites
Table of Contents
- Learning Objectives
- Notation
- Core Intuition
- Definition of a Gaussian Process
- The Prior Over Functions
- GP Regression: Noise-Free Case
- GP Regression: Noisy Observations
- Kernel (Covariance) Functions
- Marginal Likelihood and Hyperparameter Optimization
- Connection to Bayesian Linear Regression
- Connection to Neural Networks
- Computational Considerations
- Common Pitfalls
- Summary
- Exercises
Learning Objectives
- Define a Gaussian process and understand it as a distribution over functions.
- Derive the GP predictive distribution using properties of multivariate Gaussians.
- Interpret the role of the kernel in encoding assumptions about function smoothness and periodicity.
- Derive the log marginal likelihood and its gradient for hyperparameter optimization.
- Show that GP regression with a linear kernel recovers Bayesian linear regression.
- Explain the connection between GPs and infinite-width neural networks.
Notation
- — Gaussian process with mean function and kernel
- — mean function
- — covariance (kernel) function
- — kernel matrix with
- — vector with
- — observation noise variance
Core Intuition
Instead of placing a prior over parameters (as in Bayesian linear regression), a GP places a prior directly over functions. Any finite collection of function values has a joint Gaussian distribution. Given observations, we condition this joint Gaussian to get the posterior — which is again a GP. This gives us both predictions and calibrated uncertainty, all in closed form.
Gaussian Process Regression
Definition of a Gaussian Process
Definition. A Gaussian process is a collection of random variables, any finite number of which have a joint Gaussian distribution.
A GP is fully specified by:
We write . For any finite set :
The Prior Over Functions
With (common default), the GP prior says: "I expect the function to be near zero, with covariance structure determined by ." Sampling from the prior produces random smooth functions whose properties (smoothness, lengthscale, amplitude) are controlled by the kernel.
GP Regression: Noise-Free Case
Given noise-free observations and a test point , the joint prior is:
where .
Conditioning on the observations:
The predictive mean interpolates training points exactly; the variance is zero at observed locations and grows with distance.
GP Regression: Noisy Observations
With , :
The predictive distribution at :
Interpretation:
- is a weighted average of training targets, with weights determined by kernel similarity.
- captures epistemic uncertainty: small near training data, large far away.
Kernel (Covariance) Functions
The kernel encodes our prior beliefs about :
Squared Exponential (RBF):
Produces infinitely differentiable (very smooth) functions. = lengthscale, = signal variance.
Matérn family:
controls smoothness: (Ornstein–Uhlenbeck, non-differentiable), (once differentiable), (recovers SE).
Periodic:
Kernels can be composed: sums, products, and compositions of valid kernels are valid.
Marginal Likelihood and Hyperparameter Optimization
The log marginal likelihood (model evidence):
Three terms:
- Data fit: — penalizes poor predictions.
- Complexity penalty: — penalizes overly flexible models.
- Normalization: constant.
Hyperparameters are optimized by maximizing (11) via gradient ascent.
Connection to Bayesian Linear Regression
Consider the linear kernel . Then:
The GP predictive mean becomes:
which is exactly the posterior mean of Bayesian linear regression with Gaussian prior .
Connection to Neural Networks
Theorem (Neal, 1996; Lee et al., 2018). A single hidden-layer neural network with random weights and infinite width converges to a GP. The kernel is determined by the activation function and weight priors.
This connects to the Neural Tangent Kernel: the output of a trained (infinite-width) neural network under gradient descent is described by a GP with the NTK as the covariance function.
Computational Considerations
- Training: Computing costs ; storage is .
- Prediction: Each prediction costs (after precomputing ).
- Scalability: For large , use inducing-point methods (sparse GPs), which reduce cost to where is the number of inducing points.
Common Pitfalls
Pitfall 1. Using the SE kernel when the function is non-smooth. The SE kernel assumes infinite differentiability; use Matérn or for finite smoothness.
Pitfall 2. Confusing predictive variance with noise. The GP variance is epistemic (reducible with more data); the noise is aleatoric (irreducible).
Pitfall 3. Over-optimizing the marginal likelihood with too many hyperparameters can lead to overfitting the model selection criterion itself.
Summary
- A GP defines a distribution over functions via a mean and kernel.
- Conditioning on data gives exact posterior predictions: mean and variance in closed form.
- The kernel encodes smoothness, periodicity, and lengthscale assumptions.
- Marginal likelihood enables principled hyperparameter selection.
- GPs are the infinite-width limit of Bayesian neural networks.
Exercises
Exercise 1. Derive the GP predictive equations (6)–(7) from the conditional Gaussian formula.
Exercise 2. Show that the GP predictive mean at training points equals the observations (for the noise-free case).
Exercise 3. Prove that the SE kernel corresponds to an infinite-dimensional feature space.
Exercise 4. Compute the gradient of the log marginal likelihood (11) with respect to a kernel hyperparameter .
Exercise 5. Show that a GP with linear kernel recovers Bayesian linear regression.