Skip to content
BIASED

Gaussian processes

Block 1 of 7~2 min

A prior over functions

The topic Gibbs sampling and Metropolis–Hastings finished our toolkit for posteriors over parameters. But every model so far had a parameter vector of a fixed size, chosen before seeing the data. In regression this is often the wrong thing to be uncertain about. In Bayesian linear regression the weights ww were only a means to an end: what we predicted was the function f(x)=ϕ(x)⊤wf(x) = \phi(x)^\top w, and the prior on ww mattered only through the uncertainty it induced on ff.

So let us put the prior on the function directly. A function is an infinite-dimensional object, one value f(x)f(x) for each input. We cannot write a density over all of them, but we never need to: we only ever look at finitely many values.

Definition. A Gaussian process is a random function ff such that for any finite set of inputs x1,…,xnx_1, \dots, x_n the values are jointly Gaussian:

(f(x1),…,f(xn))∼N(m,K),mi=m(xi),Kij=k(xi,xj).\big(f(x_1), \dots, f(x_n)\big) \sim \mathcal N(m, K), \qquad m_i = m(x_i), \quad K_{ij} = k(x_i, x_j).

We write f∼GP(m,k)f \sim \mathcal{GP}(m, k). The mean function m(x)=Ef(x)m(x) = \mathbb E f(x) is the prior guess; the kernel, or covariance function, k(x,x′)=Cov⁡(f(x),f(x′))k(x, x') = \operatorname{Cov}(f(x), f(x')) says how strongly the values at two inputs move together. Throughout this topic m=0m = 0: before the data, the function is as likely to go up as down.

To "draw a function" from the prior, pick a fine grid of, say, 200 inputs, build the 200×200200 \times 200 matrix KK and sample one vector from N(0,K)\mathcal N(0, K): draw ε∼N(0,I)\varepsilon \sim \mathcal N(0, I) and take LεL\varepsilon, where K=LL⊤K = LL^\top. Plotted against the grid, it looks like a curve.

A Gaussian process is nonparametric: there is no fixed list of parameters. As we will see, the prediction uses one coefficient per training point, so the model grows with the data.

Answers are saved on the server and tied to this browser until you sign in.

Go deeper — optional

Code and labs do not count toward the main percentage or the certificate.

  • GP RBF: draw from the prioroptional

    Build K_RBF(X,X)+σ²I and sample f~N(0,K); check PSD.

    ~25 min · easier on a computer · The matching course topic has been read.

    Self-check in the notebook — not part of mastery or the certificate.