Added the sde representation to Matern32

This commit is contained in:
Arno Solin 2013-11-09 21:09:22 +00:00
parent 7eba2f97e1
commit 8008df39eb
2 changed files with 20 additions and 0 deletions

View file

@ -574,6 +574,10 @@ class kern(Parameterized):
else:
raise NotImplementedError, "Cannot plot a kernel with more than two input dimensions"
def sde(self):
# TODO: should support adding kernels together
return self.parts[0].sde()
from GPy.core.model import Model
class Kern_check_model(Model):
@ -794,3 +798,4 @@ def kern_test(kern, X=None, X2=None, output_ind=None, verbose=False):
return False
return pass_checks

View file

@ -137,3 +137,18 @@ class Matern32(Kernpart):
# print "OLD \n", np.dot(F1lower,F1lower.T), "\n \n"
# return(G)
return(self.lengthscale ** 3 / (12.*np.sqrt(3) * self.variance) * G + 1. / self.variance * np.dot(Flower, Flower.T) + self.lengthscale ** 2 / (3.*self.variance) * np.dot(F1lower, F1lower.T))
def sde(self):
"""
Return the state space representation of the covariance.
"""
foo = np.sqrt(3)/self.lengthscale
F = np.array([[0, 1], [-foo**2, -2*foo]])
L = np.array([[0], [1]])
Qc = np.array([12*np.sqrt(3) / self.lengthscale**3 * self.variance])
H = np.array([[1, 0]])
Pinf = np.array([[self.variance, 0],
[0, 3*self.variance/(self.lengthscale**2)]])
# TODO: return the derivatives as well
return (F, L, Qc, H, Pinf)