def _int_var_rbf(self, X, hyp, jitter=1e-8):
"""
Posterior integral variance of the Gaussian Process quadrature.
X - vector (1, 2*xdim**2+xdim)
hyp - kernel hyperparameters [s2, el_1, ... el_d]
"""
# reshape X to SP matrix
X = np.reshape(X, (self.n, self.d))
# set kernel hyper-parameters
s2, el = hyp[0], hyp[1:]
self.kern.param_array[0] = s2 # variance
self.kern.param_array[1:] = el # lengthscale
K = self.kern.K(X)
L = np.diag(el ** 2)
# posterior variance of the integral
ks = s2 * np.sqrt(det(L + np.eye(self.d))) * multivariate_normal(mean=np.zeros(self.d), cov=L).pdf(X)
postvar = -ks.dot(solve(K + jitter * np.eye(self.n), ks.T))
return postvar
评论列表
文章目录