1. Gaussian process as a prior over functions
A Gaussian process (GP) is a probability distribution over functions. It is a natural prior for an unknown regression function μ(x), especially when:
- predictors are multivariate, and
- interactions and nonlinearities are important,
- but explicit basis expansions are inconvenient.
Write the prior as
where:
- is the mean function,
- is the covariance function.
For any finite collection of inputs , the random vector of function values
is multivariate normal with mean vector and covariance matrix , where the (p, q) entry is
The GP is nonparametric: the function evaluated over all possible x is characterized by infinitely many degrees of freedom. The mean function can encode a parametric “base model,” often a linear regression:
with a prior on β (for example, a Gaussian prior). This centers the GP around a linear model but allows smooth deviations from linearity. In regions where the data are sparse, the GP naturally shrinks back toward the mean function, which helps control the curse of dimensionality.
When needed, the collection of GP hyperparameters (for example, τ, l, σ) can be viewed collectively as a parameter vector θ.
2. Covariance function and the squared exponential kernel
The covariance function determines:
- how smooth the sample paths of μ(x) are,
- how strongly values at different inputs are correlated,
- how strongly the function is shrunk towards the mean.
A common choice is the squared exponential (Gaussian / exponentiated quadratic) kernel:
where:
- controls the overall vertical scale (amplitude) of the function,
- is a length-scale parameter controlling smoothness,
- is the squared Euclidean distance between x and x′.
Large l produces very smooth, slowly varying functions. Small l allows rapid changes. Larger τ produces functions with larger variability around the mean.
Random draws from a GP with a squared exponential kernel produce smooth, “wiggly” curves whose roughness is governed by τ and l.
3. Relationship to basis expansions
Consider a basis expansion model:
with coefficient vector
Define
Then the induced distribution for is multivariate normal, with
- mean function
- covariance function
Thus any linear basis-function model with a Gaussian prior on β defines a GP prior on μ.
Conversely, many standard GP covariance functions (including the squared exponential) admit an equivalent representation as an infinite basis expansion with Gaussian weights. Truncating these expansions yields approximate finite-dimensional models that can speed up computation.
4. Isotropic vs anisotropic covariance
With multivariate predictors , using a single length scale l for all directions implies isotropy: the function is assumed to vary at the same rate in every coordinate. This is often unrealistic and inefficient if:
- some predictors have stronger influence than others,
- the function changes quickly in some directions and slowly in others,
- some predictors are essentially irrelevant.
An anisotropic squared exponential kernel allows separate length-scales for each predictor:
Each controls smoothness in the j-th coordinate. Very large effectively suppresses variation along predictor j, which can be interpreted as a form of nonparametric variable selection. Priors on the vector allow the data to drive the degree of relevance of each predictor.
5. Posterior for μ in Gaussian noise
Assume a regression model with Gaussian observation noise:
Stack the data into vectors:
- ,
- .
Given a GP prior and fixed hyperparameters θ (for example, τ, l, σ), the joint distribution of y and the function at prediction points is multivariate normal:
where:
- is the n×n covariance matrix with entries ,
- is the cross-covariance between prediction points and training points,
- is the covariance among prediction points.
Conditioning on the observed data y yields the posterior distribution of :
with
The posterior mean is a linear smoother of the observed data y. The weight each $y_i$ receives depends on the covariance structure: points $x_i$ near in input space carry more weight.
6. Computational cost
The main bottleneck in GP regression is the inversion (or factorization) of the n×n matrix , which costs operations. This must be repeated whenever the covariance hyperparameters θ change (for example, within MCMC). As a result:
- GP regression is straightforward for small or moderate n (up to a few thousand),
- but becomes computationally challenging for large n or many hyperparameters.
These limitations motivate approximate methods.
7. Covariance approximations and scalable GPs
Several strategies reduce the computational cost:
- Markov random field representations
Some GPs can be represented as Gaussian Markov random fields (GMRFs) with sparse precision matrices. In low dimensions (e.g., time series or low-dimensional spatial problems), this leads to algorithms that scale much better than . For example:- in 1D, state-space methods can achieve complexity,
- in 2D spatial problems, specialized algorithms can achieve around .
- Basis-function approximations
When the latent function is smooth and the dimension is modest, μ(x) can be approximated by a lower-dimensional basis expansion with m basis functions, where . In that case, matrix operations involve m instead of n, greatly reducing cost. This is closely related to truncated Karhunen–Loève expansions or other low-rank approximations. - Compact-support covariance functions
If the covariance is chosen to have compact support and the length scale is short, distant points become exactly uncorrelated, making the covariance matrix sparse. Sparse linear algebra can then be used to speed computation, even with many predictors. - Reduced-rank approximations
When the function is very smooth (long length scales), low-rank approximations to the covariance matrix can be effective. The covariance matrix is approximated as , where Q is n×m with . This reduces matrix operations to . Careful construction is needed to keep approximation error small. - Additive GP structures
In high dimensions, additive decompositions of μ(x) into low-dimensional components (for example, univariate GPs and low-order interactions) can combine the above approximations effectively. Each low-dimensional component is cheaper to represent and compute with.
Different approximations can be combined, for example, one approximation for short-range structure and another for long-range structure in an additive model.
8. Marginal likelihood and posterior for hyperparameters θ
For Gaussian observation noise, integration over μ yields an analytic marginal likelihood for y given θ:
Here θ typically includes τ, the length-scale parameters (l or ), and σ. Combining this marginal likelihood with a prior gives the posterior . Inference for θ can proceed via:
- optimization (type-II maximum likelihood / empirical Bayes),
- or full Bayesian sampling (e.g., MCMC methods such as slice sampling, Metropolis–Hastings, or Hamiltonian Monte Carlo).
Posterior samples of θ can be combined with the conditional GP posterior formulas to obtain posterior draws of μ(x) and predictive distributions at new points.
