ContentsChapter 9 · Gaussian processes2 of 2

9.2

GP regression

In this chapter
  1. 9.1Bayesian linear regression
  2. 9.2GP regression
Before you readYou have measured the temperature at a few stops along a road. Where would you be least sure of your prediction between stops?
Watch: Easy introduction to Gaussian process regression · paretos

A Gaussian process (GP) is a distribution over functions in which any finite set of values f(x1),…,f(xn)f(x_1),\dots,f(x_n) is jointly Gaussian. A mean function gives their expected values, and a kernel k(x,x′)k(x,x') gives their covariance. The kernel must give a positive semi-definite covariance matrix for every set of inputs.

Take a zero mean and the squared-exponential kernel (also called the RBF kernel):

k(x,x′)=exp⁡ ⁣(−(x−x′)22ℓ2).k(x,x') = \exp\!\left(-\frac{(x-x')^2}{2\ell^2}\right).

Here k(x,x)=1k(x,x)=1 every input has prior variance one. The length scale ℓ\ell controls how far apart two inputs can be before their values stop moving together. Shorter length scales allow faster changes in a draw from the prior.

Condition on data

As in Bayesian linear regression, each observation is yi=f(xi)+εiy_i=f(x_i)+\varepsilon_i with independent Gaussian noise of variance σn2\sigma_n^2 Let KK be the matrix with entries Kij=k(xi,xj)K_{ij}=k(x_i,x_j) and let k∗k_* be the column with entries k(xi,x∗)k(x_i,x_*) for a new input x∗x_* The noisy observations have covariance A=K+σn2IA=K+\sigma_n^2 I Conditioning the joint Gaussian on the observed values yy gives

μ∗=k∗TA−1y,s∗2=k(x∗,x∗)−k∗TA−1k∗.\begin{aligned} \mu_* &= k_*^T A^{-1} y, \\ s_*^2 &= k(x_*,x_*) - k_*^T A^{-1} k_* . \end{aligned}

The mean is a weighted sum of the observations. The variance starts at the prior variance and subtracts what the data tell us. Notice that only the mean uses the observed heights yy with the kernel and noise fixed, the variance depends on where you measured, not on what you measured.

-3-2-10123-6-4-20246
Posterior mean and pointwise 95% band. Length scale 1.1. Middle dot at x -0.4. The 95% band is 1.13 units wide there.
The solid curve is the posterior mean; the shaded region is the pointwise 95% band. Drag the middle dot or move its slider. What happens to the band where the dot used to be?

Far from the observations, the RBF covariances in k∗k_* tend to zero: the mean returns to zero and the variance returns to one. The band shows uncertainty about the function f(x∗)f(x_*) For a new noisy observation, add σn2\sigma_n^2 to s∗2s_*^2

Recall
What does a shorter RBF length scale change?
Recall
If you change only the observed heights, can the GP posterior variance change?
Exercise
You observe one value y=4y=4 At a new input, k(x∗,x∗)=1k(x_*,x_*)=1 and k(x1,x∗)=12k(x_1,x_*)=\frac12 If k(x1,x1)=1k(x_1,x_1)=1 and the noise variance is 1, find the posterior mean and variance of f(x∗)f(x_*) in that order.
Exercise
A GP has two noiseless observations with K=[112121]K=\begin{bmatrix}1 & \frac12\\ \frac12 & 1\end{bmatrix} At a new input x∗x_* k∗=(12,12)Tk_*=(\frac12,\frac12)^T and k(x∗,x∗)=1k(x_*,x_*)=1 Find the posterior variance of f(x∗)f(x_*)