added a constructor for a generic sympy kernel

This commit is contained in:
James Hensman 2012-12-18 15:45:52 +00:00
parent 304947d6cd
commit e29dc1c9dd
3 changed files with 8 additions and 2 deletions

View file

@ -2,5 +2,5 @@
# Licensed under the BSD 3-clause license (see LICENSE.txt) # Licensed under the BSD 3-clause license (see LICENSE.txt)
from constructors import rbf, Matern32, Matern52, exponential, linear, white, bias, finite_dimensional, rbf_ARD, spline, Brownian, linear_ARD, rbf_sympy from constructors import rbf, Matern32, Matern52, exponential, linear, white, bias, finite_dimensional, rbf_ARD, spline, Brownian, linear_ARD, rbf_sympy, sympykern
from kern import kern from kern import kern

View file

@ -188,3 +188,9 @@ def rbf_sympy(D,variance=1., lengthscale=1.):
dist = parse_expr(dist_string) dist = parse_expr(dist_string)
f = rbf_variance*sp.exp(-dist/(2*rbf_lengthscale**2)) f = rbf_variance*sp.exp(-dist/(2*rbf_lengthscale**2))
return kern(D,[spkern(D,f,np.array([variance,lengthscale]))]) return kern(D,[spkern(D,f,np.array([variance,lengthscale]))])
def sympykern(D,k):
"""
A kernel from a symbolic sympy representation
"""
return kern(D,[spkern(D,k)])

View file

@ -140,5 +140,5 @@ class uncollapsed_sparse_GP(sparse_GP_regression):
""" """
sparse_GP_regression.plot(self,*args,**kwargs) sparse_GP_regression.plot(self,*args,**kwargs)
if self.Q==1: if self.Q==1:
pb.errorbar(self.Z[:,0],self.q_u_expectation[0][:,0],yerr=2*np.sqrt(np.diag(self.q_u_cov)),fmt=None,ecolor='b') pb.errorbar(self.Z[:,0],self.q_u_expectation[0][:,0],yerr=2.*np.sqrt(np.diag(self.q_u_cov)),fmt=None,ecolor='b')