ES98E · Course contents

Part B · Lectures 1–4

3. Gaussian processes: learning an expensive function

An uncertainty calculation may need thousands of simulator evaluations. A parameter search may ask for thousands more. If a single run takes hours, a faster approximation becomes part of the scientific method: spend a limited simulation budget learning the response, then use that approximation for repeated calculations.

A surrogate or emulator is such a model, Q^(x)≈Q(x)\hat Q(x)\approx Q(x). It must be assessed on the inputs and tasks for which it will be used. Small training error alone says little about uncertainty propagation, optimisation or posterior inference. An inaccurate emulator can move an optimum or distort a posterior even when its average error looks modest.

In this chapter: function priors, conditioning, training, using surrogates.

Similarity becomes covariance

The Bayesian feature model assigned correlated uncertainty to function values. A Gaussian process specifies this directly:

f∼GP(m,k)⟺(f(x1),…,f(xn))T∼N(mX,K)f\sim\mathcal{GP}(m,k) \quad\Longleftrightarrow\quad (f(x_1),\ldots,f(x_n))^T\sim\mathcal N(m_X,K)

for every finite input set, where (mX)i=m(xi)(m_X)_i=m(x_i) and Kij=k(xi,xj)K_{ij}=k(x_i,x_j). A valid kernel is symmetric and positive semidefinite on every finite set: aTKa≥0a^TKa\ge0. This ensures that every proposed variance is nonnegative. It need not be strictly positive definite; repeated inputs, for example, can make KK singular.

For inputs in Rp\mathbb R^p, let r2=∑j(xj−xj′)2/ℓj2r^2=\sum_j(x_j-x_j')^2/\ell_j^2. The squared-exponential kernel is k=vexp⁡(−r2/2)k=v\exp(-r^2/2), with signal variance v>0v>0 and lengthscales ℓj>0\ell_j>0. Large lengthscales correlate distant inputs; short ones allow rapid change. A Matérn-3/23/2 kernel is

k(x,x′)=v(1+3r)exp⁡(−3r).k(x,x')=v(1+\sqrt3r)\exp(-\sqrt3r).

Kernel choice encodes regularity assumptions. The squared-exponential process has derivatives of every mean-square order. A Matérn process has kk mean-square derivatives exactly when ν>k\nu>k; hence ν=3/2\nu=3/2 supports one and ν=5/2\nu=5/2 two. Saying it is “differentiable exactly ν\nu times” is incorrect. Sample-path regularity is a related but separate statement. Sums and products of valid kernels remain valid, allowing additive components or interactions. These regularity and composition facts are detailed in Rasmussen and Williams, chapter 4.

Before conditioning, ask what a lengthscale means for whole functions. Keep the same Gaussian innovations and gradually increase the lengthscale. The matrix and the function draws below are two views of the same covariance assumption: longer-range dependence makes nearby values move together.

Smoothness is a relationship between points

k(x, x′) = v exp(−(x − x′)² / 2ℓ²)

-2.52.54.5-4.5input xthree coupled GP drawsCovariance on seven equally spaced inputs

lengthscale ℓ = 0.18signal variance = 1.0

Keep the same Gaussian innovations while changing the lengthscale. Three finite-grid GP draws bend together as the covariance matrix changes. These are exact joint Gaussian draws at 41 grid points, connected by lines; the diagonal includes 10⁻⁷ numerical jitter. The seven-point heatmap uses the same kernel, with fixed colour scaling. Seeded teaching draws are not fitted data. ↗

What does one observation change?

Start with a zero-mean unit-variance GP on a line. Observe y=1y=1 at x=0x=0, with independent noise variance s2s^2. For a new input xx, Gaussian conditioning gives

E[f(x)∣y]=k(x,0)1+s2,Var⁡(f(x)∣y)=1−k(x,0)21+s2.\mathbb E[f(x)\mid y]=\frac{k(x,0)}{1+s^2},\qquad \operatorname{Var}(f(x)\mid y)=1-\frac{k(x,0)^2}{1+s^2}.

The same covariance controls both the mean update and the uncertainty reduction. Before inspecting the figure, consider what a shorter lengthscale should do: it changes how far the observation's information travels, rather than changing the observation itself.

One observation, two notions of nearness
Lengthscale ℓ = 0.35fx-33-2.22.7solid: mean · dashed: covarianceLengthscale ℓ = 1.2fx-33-2.22.7solid: mean · dashed: covariance
Exact one-observation conditioning with a squared-exponential kernel, signal variance one, observation y = 1 at x = 0, and noise variance 0.04. Solid curves are posterior means; shaded bands are mean ± two latent standard deviations, pointwise rather than simultaneous bands. The dashed curve shows covariance with the observed input. Both panels use identical axes. ↗

For nn observations, put C=K+σn2IC=K+\sigma_n^2I, ry=y−mXr_y=y-m_X, and (k∗)i=k(xi,x∗)(k_*)_i=k(x_i,x_*). If CC is positive definite,

μ∗=m(x∗)+k∗TC−1ry,s∗2=k(x∗,x∗)−k∗TC−1k∗.\mu_*=m(x_*)+k_*^TC^{-1}r_y,\qquad s_*^2=k(x_*,x_*)-k_*^TC^{-1}k_*.

These are the posterior mean and latent variance; add σn2\sigma_n^2 for a new noisy observation under the same noise model. The variance reduction is nonnegative because it is a Gaussian conditional covariance. In the noiseless limit, interpolation at training points requires an invertible KK. With nonzero noise, even the training latent value remains uncertain. A derivation and the multivariate predictive distribution appear in Rasmussen and Williams, chapter 2.

Conditioning is a transformation of a distribution, not just a curve passing through observations. Introduce the observations one at a time and follow the mean and latent variance together. The influence of each observation is tied to its covariance with the rest of the domain.

Let each observation reshape a distribution

μ* = k*ᵀC⁻¹y · s*² = k** − k*ᵀC⁻¹k*

-2.52.52.3-2.3input xlatent function f-2.52.510input xcovariance with observations

0 observations contributinglatent variance at 0 = 1.000

Three observations arrive in order. Between arrivals, increasing likelihood precision gives a continuous, exact Gaussian update; this is not an optimiser trajectory. The band is the posterior mean ± two latent standard deviations. The lower strip shows covariance with each observed input for a fixed lengthscale of 0.7. Observation noise and latent function uncertainty are distinct. ↗

The practical computation solves linear systems. Factor C=LLTC=LL^T, solve for α=C−1ry\alpha=C^{-1}r_y, and compute s∗2=k∗∗−∥L−1k∗∥2s_*^2=k_{**}-\|L^{-1}k_*\|^2. Do not form C−1C^{-1}. A small diagonal jitter can stabilise near-singular arithmetic; record it separately from physical observation noise. Large negative computed variances indicate a numerical or modelling error, not negative uncertainty.

Training includes testing the assumptions

With kernel and noise parameters ψ\psi, the log marginal likelihood is

log⁡p(y∣X,ψ)=−12ryTC−1ry−12log⁡∣C∣−n2log⁡(2π).\log p(y\mid X,\psi) =-\frac12r_y^TC^{-1}r_y-\frac12\log|C|-\frac n2\log(2\pi).

The quadratic term and the log determinant balance fit and the volume of possible observations. This is the function-space counterpart of the evidence in the preceding chapter. It is generally nonconvex in ψ\psi. Multiple starts, physically meaningful bounds and hyperpriors can help; no fixed number of restarts guarantees the best solution. Hyperparameters may be estimated, integrated out or fixed from justified physical knowledge. They need not always be fitted by evidence maximisation.

Scale inputs by their physical ranges or training-set statistics and centre/scale targets when appropriate; retain the inverse transform and avoid test leakage. A unit lengthscale is interpretable only relative to those scales. Explore noise initialisation rather than always starting high: a deterministic converged simulator and noisy measurements are different modelling situations. Inspect whether fitted noise is absorbing a misspecified mean or kernel.

Exact dense factorisation costs O(n3)O(n^3) time and O(n2)O(n^2) storage. After training, a single predictive mean is O(n)O(n) and a dense predictive variance is generally O(n2)O(n^2), since it needs a triangular solve. Inducing-point methods with m≪nm\ll n can reduce common training formulations to O(nm2)O(nm^2), at an approximation cost that must be assessed.

Validate accuracy and interval coverage on withheld simulator runs, with residual checks across the intended domain. A GP's credible intervals are conditional on its model and fitted hyperparameters; being inside the design's convex hull does not guarantee calibration. For decaying kernels, k∗→0k_*\to0 far from all training inputs, so mean and variance revert to their prior values. Periodic, linear and other nondecaying kernels need not do this. Prior reversion describes the model's ignorance, not the true function's behaviour.

Where to spend the next simulator run

Space-filling designs, including Latin hypercubes, can initialise an emulator. Sampling should also reflect the intended downstream distribution: a design suitable for a broad exploration need not resolve a sharply concentrated posterior. Use simulator checks near inferred optima, posterior mass and difficult transitions. Simulation convergence failures may indicate discontinuities or an invalid input regime; a smooth kernel cannot repair them.

The original notes report a Matérn-3/23/2 vacancy-energy surrogate trained on 25 Latin-hypercube points, with test MAE 0.040.04 eV, and an extrapolation example where relaxation failed. No data or notebook accompanies those figures. They illustrate the intended use, but are not reproduced benchmarks here.

Other surrogates make different compromises. Polynomial chaos uses polynomial bases orthogonal under a specified input distribution; RBF regression uses local features. Neural networks learn features and can handle complex high-dimensional structure, but their data requirements depend on the problem. A useful surrogate need not interpolate noisy observations exactly, and uncertainty estimates require their own validation.

Bayesian optimisation adds a sequential decision rule to a surrogate; it is not a separate regression family. For minimisation, one possible acquisition is expected improvement,

EI⁡(x)=E[(fbest−f(x))+∣D].\operatorname{EI}(x)=\mathbb E[(f_{\rm best}-f(x))_+\mid D].

It rewards promising means and uncertainty that offers a chance of improvement. Evaluate the selected input with the real simulator, update the surrogate, and repeat. This does not promise a global optimum in a universally minimal number of evaluations; the acquisition and assumptions determine the search. Exploring Bayesian Optimization develops this sequential viewpoint visually.

Part B has now supplied the course's statistical foundation: local approximation, regression, uncertainty and expensive-function learning. Part A begins by replacing fixed features with learned representations.