From 8008df39ebdf80c9340ce8407e490e7df451c41c Mon Sep 17 00:00:00 2001 From: Arno Solin Date: Sat, 9 Nov 2013 21:09:22 +0000 Subject: [PATCH] Added the sde representation to Matern32 --- GPy/kern/kern.py | 5 +++++ GPy/kern/parts/Matern32.py | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/GPy/kern/kern.py b/GPy/kern/kern.py index 805c6b43..74def8cd 100644 --- a/GPy/kern/kern.py +++ b/GPy/kern/kern.py @@ -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 + diff --git a/GPy/kern/parts/Matern32.py b/GPy/kern/parts/Matern32.py index 40da79f0..2828a455 100644 --- a/GPy/kern/parts/Matern32.py +++ b/GPy/kern/parts/Matern32.py @@ -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) +