I am quite new to Gaussian processes. A Gaussian Process looks like the following:
Where the dark blue line denotes the mean, and the filled-area denotes the mean+std and mean-std respectively.
From what I know, we can calculate the predicted mean function as follows
- $K$ denotes the kernel used
- $x_*$ denotes the x-coordinate to be predicted
- $x_d$ denotes all the 'training data'/previously sampled data):
$$ m( y_* | y_d) = \mu(x_*) + K(x_*, x_d) K(x_d, x_d)^{-1} (y_d - \mu (x_d)) $$
and the covariance function as follows:
$$ C(y_* | y_d) = K(x_*, x_*) - K(x_*, x_d) K(x_d, x_d)^{-1} K(x_d, x_*) $$
As I am currently new to Gaussian processes and try to understand the process before going into implementations, I started working through this blog-post. Here, the author calculates the following to end up with the standard-deviation:
K_ss = kernel(Xtest, Xtest)
K_s = kernel(Xtrain, Xtest, param)
K = kernel(Xtrain, Xtrain, param)
L = np.linalg.cholesky(K + 0.00005*np.eye(len(Xtrain)))
Lk = np.linalg.solve(L, K_s)
s2 = np.diag(K_ss) - np.sum(Lk**2, axis=0)
stdv = np.sqrt(s2)
My initial thought was that the covariance-function $C(y_* | y_d)$ can be used to calculate the standard deviation for each sampled data point in the above graph. However, looking at the code, I don't quite understand how this is done.
So my question is: How is the standard deviation calculated? And how can I then arrive at a graph like the above one?