From Noisy Observations to Two Predictions
A Gaussian process calculation becomes concrete when the training and test inputs are fixed. The prior covariance between those inputs determines a joint Gaussian distribution; measurement noise changes the covariance of the observations, but it does not change the prior covariance of the latent test values. Conditioning the joint distribution then gives posterior means and a covariance matrix for the test values. Keeping these pieces separate is essential: the posterior covariance describes uncertainty about the latent process, not uncertainty about a future noisy measurement.
Let \((\Omega,\mathcal{F},\mathbb{P})\) be a probability space, and let \((F(x))_{x\in\mathcal{X}}\) be a Gaussian process on an input set \(\mathcal{X}\). This means that every finite vector of process values has a multivariate Gaussian distribution. Write its mean function as \(m(x)=\mathbb{E}[F(x)]\), and its covariance kernel as \(k(x,x')=\operatorname{Cov}(F(x),F(x'))\). At two distinct training inputs \(x_1,x_2\), suppose the observations are \(Y_i=F(x_i)+\epsilon_i\), where the errors are independent \(N(0,\sigma^2)\) variables, independent of the process, and \(\sigma^2>0\). We want to predict the latent values \(F(z_1),F(z_2)\) at two test inputs.
The observation covariance is invertible under the stated positive-noise assumption. Indeed, \(K\) is a covariance matrix, so \(v^{\mathsf T}Kv\ge0\) for every vector \(v\). Thus for any nonzero \(v\), \(v^{\mathsf T}Cv=v^{\mathsf T}Kv+\sigma^2v^{\mathsf T}v>0\). The calculation below applies to a general Gaussian process, then uses a simple kernel that makes every entry exact.
Why the Conditioning Formula Works
Proof. Put \(X=(F(x_1),F(x_2))^{\mathsf T}\), \(Z=(F(z_1),F(z_2))^{\mathsf T}\), and \(Y=X+\epsilon\), where \(\epsilon=(\epsilon_1,\epsilon_2)^{\mathsf T}\). Finite-dimensional Gaussianity and independence of the Gaussian noise imply that \((Z,Y)\) is jointly Gaussian. Its means are \(m_*\) and \(m_X\). Independence of \(\epsilon\) from the process gives \(\operatorname{Cov}(Y)=K+\sigma^2 I=C\) and \(\operatorname{Cov}(Z,Y)=B\).
Define the residual \(R=Z-m_*-BC^{-1}(Y-m_X)\). It is a linear transformation of a jointly Gaussian vector, hence is jointly Gaussian with \(Y\). Directly expanding its covariance with \(Y\) gives \(\operatorname{Cov}(R,Y)=B-BC^{-1}C=0\). Jointly Gaussian vectors with zero cross-covariance are independent, the standard independence property of Gaussian vectors. Therefore \(R\) is independent of \(Y\), and its conditional mean given \(Y=y\) is its unconditional mean, zero. Rearranging the definition of \(R\) gives the stated conditional mean. Expanding the residual covariance gives \(\operatorname{Cov}(R)=K_*-BC^{-1}B^{\mathsf T}\): the two cross terms are each \(BC^{-1}B^{\mathsf T}\), while the covariance of \(BC^{-1}(Y-m_X)\) is \(BC^{-1}CC^{-1}B^{\mathsf T}=BC^{-1}B^{\mathsf T}\). Since \(R\) is independent of \(Y\), this residual covariance is also the conditional covariance. \(\square\)
Proof. The residual \(R\) in the theorem has covariance \(K_*-BC^{-1}B^{\mathsf T}\). For any fixed vector \(a\), \(a^{\mathsf T}(K_*-BC^{-1}B^{\mathsf T})a=\operatorname{Var}(a^{\mathsf T}R)\ge0\). This is exactly the definition of positive semidefiniteness. \(\square\)
A Kernel with Exact Covariances
For the examples, take \(\mathcal{X}=\mathbb{R}\), zero prior mean, and \(k(x,x')=1+xx'\). This is a valid covariance kernel: for any finite inputs \(u_1,\ldots,u_n\) and real coefficients \(a_1,\ldots,a_n\),
Thus every finite covariance matrix generated by this kernel is positive semidefinite. Equivalently, the process can be represented as \(F(x)=A+Bx\), where \(A\) and \(B\) are independent standard normal variables. The examples use training inputs \(-1,1\) and test inputs \(0,2\). With \(k(x,x')=1+xx'\), the training covariance entries are \(k(-1,-1)=2\), \(k(-1,1)=0\), \(k(1,-1)=0\), and \(k(1,1)=2\). The test covariance entries are \(k(0,0)=1\), \(k(0,2)=1\), \(k(2,0)=1\), and \(k(2,2)=5\). The cross-covariance entries, with test inputs in rows and training inputs in columns, are \(k(0,-1)=1\), \(k(0,1)=1\), \(k(2,-1)=-1\), and \(k(2,1)=3\).
Worked Example: Two Observations with Noise Variance One-Half
Observe \(y_1=1\) at \(x_1=-1\) and \(y_2=2\) at \(x_2=1\), with independent measurement errors of variance \(\sigma^2=\tfrac12\). Find the posterior means, variances, and covariance of \(F(0)\) and \(F(2)\).
The matrices from the kernel calculations above are \(K=\begin{bmatrix}2&0\\0&2\end{bmatrix}\), \(K_*=\begin{bmatrix}1&1\\1&5\end{bmatrix}\), and \(B=\begin{bmatrix}1&1\\-1&3\end{bmatrix}\). The observation covariance is
For the posterior mean, \(m_X=m_*=0\) and \(y=(1,2)^{\mathsf T}\). First, \(C^{-1}y=(\tfrac25,\tfrac45)^{\mathsf T}\). Multiplying by \(B\) gives the mean at \(0\) as \(\tfrac25+\tfrac45=\tfrac65\), and the mean at \(2\) as \(-\tfrac25+3\cdot\tfrac45=-\tfrac25+\tfrac{12}5=2\). The posterior mean vector is therefore \((\tfrac65,2)^{\mathsf T}\).
For the covariance, multiplication gives \(BB^{\mathsf T}=\begin{bmatrix}2&2\\2&10\end{bmatrix}\). Since \(C^{-1}=\tfrac25 I\), the subtracted matrix is \(BC^{-1}B^{\mathsf T}=\tfrac25BB^{\mathsf T}=\begin{bmatrix}\tfrac45&\tfrac45\\\tfrac45&4\end{bmatrix}\). Hence
The latent posterior variances are \(\tfrac15\) at \(0\) and \(1\) at \(2\), and their posterior covariance is \(\tfrac15\). As a check, the determinant of the posterior covariance is \(\tfrac15\cdot1-(\tfrac15)^2=\tfrac4{25}>0\), and both diagonal entries are positive. Substituting the mean back into the formula also checks it: \(B(\tfrac25,\tfrac45)^{\mathsf T}=(\tfrac65,2)^{\mathsf T}\), as calculated.
Worked Example: Changing the Observed Values
Keep the same four inputs and noise variance \(\tfrac12\), but suppose the observations are \(y_1=2\) and \(y_2=-1\). Recalculate the posterior predictions.
The observation covariance remains \(C=\begin{bmatrix}\tfrac52&0\\0&\tfrac52\end{bmatrix}\), so \(C^{-1}=\begin{bmatrix}\tfrac25&0\\0&\tfrac25\end{bmatrix}\). Now \(C^{-1}y=(\tfrac45,-\tfrac25)^{\mathsf T}\). Thus the posterior mean at \(0\) is \(\tfrac45-\tfrac25=\tfrac25\), and at \(2\) it is \(-\tfrac45+3(-\tfrac25)=-\tfrac45-\tfrac65=-2\). The mean vector is \((\tfrac25,-2)^{\mathsf T}\).
The inputs, kernel, and noise variance have not changed, so \(K_*\) and \(BC^{-1}B^{\mathsf T}\) are still \(\begin{bmatrix}1&1\\1&5\end{bmatrix}\) and \(\begin{bmatrix}\tfrac45&\tfrac45\\\tfrac45&4\end{bmatrix}\). Subtracting gives posterior covariance \(\begin{bmatrix}\tfrac15&\tfrac15\\\tfrac15&1\end{bmatrix}\). Check the mean by multiplying \(B(\tfrac45,-\tfrac25)^{\mathsf T}\): the first component is \(\tfrac45-\tfrac25=\tfrac25\), and the second is \(-\tfrac45-\tfrac65=-2\). This illustrates the distinction between the posterior mean, which depends on the observed values, and posterior covariance, which in this Gaussian model depends on the inputs, kernel, and noise level, not on the realized observations.
Worked Example: Increasing the Noise Variance
Return to observations \(y=(1,2)^{\mathsf T}\), but set the measurement-noise variance to \(1\). Find the predictions at \(0\) and \(2\), showing how this change affects the calculation.
The training covariance is still \(K=\begin{bmatrix}2&0\\0&2\end{bmatrix}\), but now \(C=K+I=\begin{bmatrix}3&0\\0&3\end{bmatrix}\) and \(C^{-1}=\begin{bmatrix}\tfrac13&0\\0&\tfrac13\end{bmatrix}\). Thus \(C^{-1}y=(\tfrac13,\tfrac23)^{\mathsf T}\). Multiplication by \(B\) gives the posterior means \(\tfrac13+\tfrac23=1\) at \(0\) and \(-\tfrac13+3\cdot\tfrac23=-\tfrac13+2=\tfrac53\) at \(2\).
From the entries of \(B\), \(BB^{\mathsf T}=\begin{bmatrix}1^2+1^2&1(-1)+1(3)\\1(-1)+1(3)&(-1)^2+3^2\end{bmatrix}=\begin{bmatrix}2&2\\2&10\end{bmatrix}\). Therefore \(BC^{-1}B^{\mathsf T}=\tfrac13BB^{\mathsf T}=\begin{bmatrix}\tfrac23&\tfrac23\\\tfrac23&\tfrac{10}3\end{bmatrix}\). Subtracting this from \(K_*=\begin{bmatrix}1&1\\1&5\end{bmatrix}\) yields posterior covariance \(\begin{bmatrix}\tfrac13&\tfrac13\\\tfrac13&\tfrac53\end{bmatrix}\). Its determinant is \(\tfrac13\cdot\tfrac53-(\tfrac13)^2=\tfrac59-\tfrac19=\tfrac49>0\). Finally, \(B(\tfrac13,\tfrac23)^{\mathsf T}=(1,\tfrac53)^{\mathsf T}\), checking the mean. Compared with noise variance \(\tfrac12\), the larger noise pulls the mean at \(0\) from \(\tfrac65\) to \(1\), and raises the posterior variance there from \(\tfrac15\) to \(\tfrac13\).
A Common Error: Leaving Noise Out
The observation covariance is not just \(K\). It is \(K+\sigma^2I\), because the observed values include independent measurement errors. In the first worked example, omitting the noise would incorrectly use \(K^{-1}=\tfrac12I\) instead of \(C^{-1}=\tfrac25I\). The resulting incorrect mean at \(0\) would be \((1,1)\tfrac12(1,2)^{\mathsf T}=\tfrac32\), rather than the correct \(\tfrac65\). The incorrect variance at \(0\) would be \(1-(1,1)\tfrac12 I(1,1)^{\mathsf T}=1-\tfrac12(2)=0\), rather than \(\tfrac15\). This is not a harmless change in notation: it treats the noisy observations as if they were exact latent process values.
Another useful distinction is between a latent prediction and a future noisy observation. The variance calculated above is for \(F(z_r)\). If a new independent measurement \(F(z_r)+\epsilon_{\mathrm{new}}\) is predicted, its variance is the latent posterior variance plus \(\sigma^2\). Its covariance with a latent value at a different test input is unchanged, because the new measurement error is independent. Always identify which quantity is being predicted before reporting uncertainty.
Check Your Understanding
Use the kernel \(k(x,x')=1+xx'\) and the conditioning formulas to answer these questions. Show the matrix products and check the resulting covariance matrices.
- With training inputs \(-1,1\), test inputs \(0,2\), noise variance \(\tfrac12\), and observations \((0,0)^{\mathsf T}\), find the posterior mean vector and covariance matrix.
- For the same inputs and noise variance, calculate the observation covariance matrix when the measurement errors are independent with variance \(\tfrac12\). Why is it not equal to the training covariance matrix?
- Using observations \((1,2)^{\mathsf T}\) and noise variance \(1\), verify the posterior mean at \(0\) by substituting into \(BC^{-1}y\).
- Explain why the covariance between the two latent test values remains the same when the observed values change but the inputs, kernel, and noise variance are fixed.
- In the first worked example, what variance would be reported for a future noisy measurement at input \(0\), rather than for the latent value \(F(0)\)?