sklearn计算高斯过程的对数边际可能性是否为正?

时间:2019-02-18 06:45:41

标签: python scikit-learn gp

我正在检查sklearn对高斯过程(GP)的对数边际可能性的实现。该实现基于Rasmussen's Gaussian Processes for Machine Learning中的Algorithm 2.1,为方便起见,我还附上了它的快照:

enter image description here

但是,我经常遇到某些情况,其中该公式计算的对数似然为正。下面的示例代码是一个特定的示例:

import numpy as np 
from scipy.linalg import cholesky, cho_solve, solve_triangular
from sklearn.gaussian_process.kernels import Matern

kernel=Matern(nu=2.5)
x = np.array([1, 2, 3]).reshape(-1,1)
y = np.array([0.1, 0.2, 0.3])
noise=0
amp2=0.05 

K = kernel(x)

cov = amp2 * (K + 0*np.eye(x.shape[0])) 
cov[np.diag_indices_from(cov)] += noise
L = cholesky(cov, lower=True)
alpha = cho_solve((L, True), y)
logprob = -0.5 * np.dot(y, alpha) - np.log(np.diag(L)).sum() - \
      x.shape[0] / 2. * np.log(2 * np.pi)
print(logprob) # Result: 1.1359631938135135

我认为GP log Pr(y|x, M)的对数边际可能性应始终为非正数。为什么上面的代码会产生对数边际可能性?

谢谢!

0 个答案:

没有答案