Foundations to Frontier
Tests
A. Mathematical Foundations › A4 Probability Theory › Stochastic processes

Gaussian Processes

A Gaussian process is a probability distribution over functions: any finite set of function values is jointly Gaussian, with covariance given by a kernel. GP regression is just Gaussian conditioning, so it returns a prediction and an honest uncertainty that grows away from the data. You will build kernels, sample priors, fit hyperparameters by marginal likelihood, see Brownian motion and OU as GPs, and use GP-UCB Bayesian optimization to tune a controller in a handful of trials, with links to terrain mapping, safe learning and the infinite-width limit of neural networks.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Guessing a hillside from a few measurements

A rover measures the ground height at five spots. What’s the height between them? Close to a measured spot, it’s probably close to that measurement. Far from all of them, who knows? A good guess should say both “here’s my best estimate” and “here’s how sure I am”, and be more unsure the further you get from the data.

A Gaussian process does exactly that. It treats the whole unknown hillside as a random curve, and every measurement narrows down which curves are plausible.

Gaussian-process regression: click to add data
5 observations · log marginal likelihood -6.20 · posterior sd at x = 5: 0.991 (prior sd σ_f = 1.00)
Orange: posterior mean. Blue band: ±2 posterior sd. Click to add a point, or click a point to remove it. Small ℓ gives wiggly fits that overfit; large ℓ gives stiff ones. Try maximizing the log marginal likelihood with the sliders: it trades data fit against complexity automatically. Far from the data, the GP reverts to its prior (mean 0, sd σ_f), so it knows what it doesn't know.
Why engineers care

Robots map terrain and signal strength with GPs. Engineers tune controllers and hyperparameters with GP-based Bayesian optimization, because each trial is expensive. Safe-learning systems use the GP’s uncertainty to avoid trying anything they’re not confident about.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Far from all measurements, a GP is…
  2. 2. A GP gives…
  3. 3. Near a measured point the prediction is…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

Definition

f∼GP(m,k)f\sim\mathcal{GP}(m, k) means that for any inputs x1,…,xnx_1, \dots, x_n, the vector (f(x1),…,f(xn))(f(x_1), \dots, f(x_n)) is multivariate normal with mean m(xi)m(x_i) and covariance Kij=k(xi,xj)K_{ij} = k(x_i, x_j).

The kernel kk encodes your assumptions about the function:

Kernel k(x,x′)k(x, x') Functions look…
RBF (squared exponential) σf2e−(x−x′)2/2ℓ2\sigma_f^2e^{-(x - x')^2/2\ell^2} smooth, wiggling on scale ℓ\ell
Exponential (OU) σ2e−∣x−x′∣/ℓ\sigma^2e^{-\lvert x - x'\rvert/\ell} rough, continuous
Brownian motion min⁡(x,x′)\min(x, x') random-walk-like, starting at 0
Periodic σ2e−2sin⁡2(π∣x−x′∣/p)/ℓ2\sigma^2e^{-2\sin^2(\pi\lvert x - x'\rvert/p)/\ell^2} repeating with period pp
Linear xx′xx' straight lines

A valid kernel must give a positive semidefinite KK for every set of inputs. Sums, products and positive multiples of kernels are kernels.

📝 Quick check (Level 1)
0/3 answered
  1. 1. A GP's finite-dimensional marginals are…
  2. 2. A larger RBF lengthscale ℓ gives functions that are…
  3. 3. The kernel min(s, t) describes…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 45 minUndergraduate students and practising engineers.

GP regression is Gaussian conditioning

Observe y=f(X)+εy = f(X) + \varepsilon with ε∼N(0,σn2I)\varepsilon\sim\mathcal N(0, \sigma_n^2I). Joint Gaussianity and the conditioning formula (A4.2-4) give, at test points X∗X_*,

fˉ∗=K∗⊤(K+σn2I)−1y,cov⁡(f∗)=K∗∗−K∗⊤(K+σn2I)−1K∗\bar f_* = K_*^\top(K + \sigma_n^2I)^{-1}y, \qquad \operatorname{cov}(f_*) = K_{**} - K_*^\top(K + \sigma_n^2I)^{-1}K_*

Compute it with a Cholesky factorization, O(n3)O(n^3) once. The variance doesn’t depend on yy, only on where you measured. Far from data, K∗→0K_*\to0 and the GP returns to its prior.

Choosing hyperparameters

Maximize the log marginal likelihood

log⁡p(y∣X,θ)=−12y⊤Ky−1y−12log⁡∣Ky∣−n2log⁡2π,Ky=K+σn2I\log p(y\mid X, \theta) = -\tfrac12y^\top K_y^{-1}y - \tfrac12\log\lvert K_y\rvert - \tfrac n2\log2\pi, \quad K_y = K + \sigma_n^2I

The first term rewards fitting the data, and the second penalizes complexity: an automatic Occam’s razor. Too small an ℓ\ell overfits, and too large an ℓ\ell can’t fit at all. Both lose likelihood.

🐍 Exercise 1: GP regression from scratch
Implement the RBF kernel, the GP posterior via Cholesky, and the log marginal likelihood. Check that the fit tracks a noisy function inside the data range, that the variance is small near data and back to σ_f² far away, that the marginal likelihood prefers a sensible lengthscale, and that prior samples have covariance K.
📝 Quick check (Level 2)
0/3 answered
  1. 1. GP posterior variance depends on…
  2. 2. The −½ log|K_y| term in the marginal likelihood…
  3. 3. Exact GP regression costs…

Level 3: Advanced

★★★★☆ Advanced⏱ 45 minGraduate level, with full derivations and proofs.

The posterior mean is a kernel expansion

fˉ(x)=∑iαik(x,xi)\bar f(x) = \sum_i\alpha_ik(x, x_i) with α=(K+σn2I)−1y\alpha = (K + \sigma_n^2I)^{-1}y. It’s the same as kernel ridge regression with regularization σn2\sigma_n^2. By the representer theorem, it minimizes ∑(yi−f(xi))2+σn2∥f∥Hk2\sum(y_i - f(x_i))^2 + \sigma_n^2\lVert f\rVert_{\mathcal H_k}^2 over the reproducing-kernel Hilbert space of kk (A3.5-5). The Bayesian and regularization views agree on the mean. The GP adds the variance.

Mercer and the feature view

A continuous PSD kernel expands as k(x,x′)=∑jλjϕj(x)ϕj(x′)k(x, x') = \sum_j\lambda_j\phi_j(x)\phi_j(x') (Mercer). So f=∑jwjλjϕjf = \sum_jw_j\sqrt{\lambda_j}\phi_j with iid wj∼N(0,1)w_j\sim\mathcal N(0,1): a GP is Bayesian linear regression with (possibly infinitely many) features. Bochner’s theorem gives random Fourier features for stationary kernels (A4.3-3).

Markov GPs and filtering

The OU kernel corresponds to a first-order SDE (A4.4-5). Matérn kernels with half-integer smoothness correspond to higher-order linear SDEs. For these, GP regression in time can be done by a Kalman smoother in O(n)O(n) instead of O(n3)O(n^3) (Hartikainen and Särkkä, 2010). That’s why filters and GPs are the same mathematics.

Neural networks as GPs

A one-hidden-layer network with iid random weights becomes a GP as its width goes to infinity, by the CLT across units (Neal, 1996). Deep versions give the NNGP and neural tangent kernels (Lee et al., 2018; Jacot, Gabriel and Hongler, 2018).

Exercise 3.1: Show that the sum of two kernels is a kernel

For any cc, c⊤(K1+K2)c=c⊤K1c+c⊤K2c≥0c^\top(K_1 + K_2)c = c^\top K_1c + c^\top K_2c\ge0. Equivalently, it’s the covariance of f1+f2f_1 + f_2 for independent GPs.

📝 Quick check (Level 3)
0/3 answered
  1. 1. The GP posterior mean equals…
  2. 2. A GP with the OU kernel in time can be computed in O(n) using…
  3. 3. Infinitely wide random networks converge to…

Level 4: Expert

★★★★★ Expert⏱ 45 minResearchers: original papers and open problems.

Tuning a controller with Bayesian optimization

Each closed-loop trial on hardware is expensive: minutes of flight or a risk of damage. Model the tracking score as an unknown function of the gain, f∼GPf\sim\mathcal{GP}. Pick each next trial by the upper confidence bound fˉ(x)+βσ(x)\bar f(x) + \beta\sigma(x), which balances exploiting good gains against exploring uncertain ones. GP-UCB has sublinear regret guarantees (Srinivas et al., 2010). It routinely finds near-optimal gains in 10–20 trials where grid or random search needs many more (Calandra et al., 2016; Berkenkamp, Schoellig and Krause, 2016). SafeOpt adds a constraint: only try gains whose lower confidence bound on safety is acceptable.

🐍 Exercise 2 (research): GP-UCB Bayesian optimization of a controller gain
Implement GP-UCB on a grid of gains with a noisy, two-peaked tracking score. Show that within 15 trials it reaches the global optimum (median over 10 runs), beats random search with the same budget, and doesn't get stuck on the smaller local peak.

Gaussian processes in AI, robotics and aerospace

  • Terrain and field mapping. GP occupancy maps and elevation maps, and adaptive sampling of ocean or atmospheric fields with uncertainty-driven paths (O’Callaghan and Ramos, 2012; Krause, Singh and Guestrin, 2008).
  • Learning dynamics with uncertainty. PILCO learns a GP dynamics model and plans through its uncertainty, learning cart-pole swing-up in seconds of real data (Deisenroth and Rasmussen, 2011). GP-MPC learns residual dynamics for racing drones and cars (Hewing et al., 2020).
  • Safe learning. Lower confidence bounds from GPs certify which states or parameters are safe to explore (Berkenkamp et al., 2017).
  • Sparse and scalable GPs. Inducing points (Titsias, 2009) and state-space GPs bring costs down from O(n3)O(n^3) for large sensor datasets.
  • Hyperparameter tuning of deep networks and simulators by Bayesian optimization (Snoek, Larochelle and Adams, 2012).

References

  1. C. Rasmussen, C. Williams (2006). Gaussian Processes for Machine Learning. MIT Press.
  2. N. Srinivas, A. Krause, S. Kakade, M. Seeger (2010). “Gaussian process optimization in the bandit setting: no regret and experimental design.” ICML.
  3. F. Berkenkamp, A. Schoellig, A. Krause (2016). “Safe controller optimization for quadrotors with Gaussian processes.” ICRA.
  4. R. Calandra, A. Seyfarth, J. Peters, M. Deisenroth (2016). “Bayesian optimization for learning gaits under uncertainty.” Annals of Mathematics and Artificial Intelligence, 76.
  5. M. Deisenroth, C. Rasmussen (2011). “PILCO: a model-based and data-efficient approach to policy search.” ICML.
  6. L. Hewing, J. Kabzan, M. Zeilinger (2020). “Cautious model predictive control using Gaussian process regression.” IEEE Transactions on Control Systems Technology, 28(6).
  7. J. Hartikainen, S. Särkkä (2010). “Kalman filtering and smoothing solutions to temporal Gaussian process regression models.” IEEE MLSP.
  8. R. Neal (1996). Bayesian Learning for Neural Networks. Springer.
  9. M. Titsias (2009). “Variational learning of inducing variables in sparse Gaussian processes.” AISTATS.
  10. J. Snoek, H. Larochelle, R. Adams (2012). “Practical Bayesian optimization of machine learning algorithms.” NeurIPS.
  11. S. O’Callaghan, F. Ramos (2012). “Gaussian process occupancy maps.” IJRR, 31(1).