Added capability for sinc covariance via sympy kernel.

This commit is contained in:
Neil Lawrence 2013-09-30 22:51:07 +01:00
parent 0d4fd01ae1
commit e06d889d35
4 changed files with 72 additions and 1 deletions

32
GPy/util/symbolic.py Normal file
View file

@ -0,0 +1,32 @@
from sympy import Function, S, oo, I, cos, sin
class sinc_grad(Function):
nargs = 1
def fdiff(self, argindex=1):
return ((2-x*x)*sin(self.args[0]) - 2*x*cos(x))/(x*x*x)
@classmethod
def eval(cls, x):
if x is S.Zero:
return S.Zero
else:
return (x*cos(x) - sin(x))/(x*x)
class sinc(Function):
nargs = 1
def fdiff(self, argindex=1):
return sinc_grad(self.args[0])
@classmethod
def eval(cls, x):
if x is S.Zero:
return S.One
else:
return sin(x)/x
def _eval_is_real(self):
return self.args[0].is_real