Added the product of kernels defined on the same space + a few bugs fixed in the prod_orthogonal

This commit is contained in:
Nicolas 2013-02-20 17:44:40 +00:00
parent 1ccf061b8f
commit a0eca5ec9a
5 changed files with 107 additions and 15 deletions

View file

@ -18,6 +18,7 @@ from Brownian import Brownian as Brownianpart
from periodic_exponential import periodic_exponential as periodic_exponentialpart
from periodic_Matern32 import periodic_Matern32 as periodic_Matern32part
from periodic_Matern52 import periodic_Matern52 as periodic_Matern52part
from product import product as productpart
from product_orthogonal import product_orthogonal as product_orthogonalpart
#TODO these s=constructors are not as clean as we'd like. Tidy the code up
#using meta-classes to make the objects construct properly wthout them.
@ -242,10 +243,21 @@ def periodic_Matern52(D,variance=1., lengthscale=None, period=2*np.pi,n_freq=10,
part = periodic_Matern52part(D,variance, lengthscale, period, n_freq, lower, upper)
return kern(D, [part])
def product(k1,k2):
"""
Construct a product kernel over D from two kernels over D
:param k1, k2: the kernels to multiply
:type k1, k2: kernpart
:rtype: kernel object
"""
part = productpart(k1,k2)
return kern(k1.D, [part])
def product_orthogonal(k1,k2):
"""
Construct a product kernel
Construct a product kernel over D1 x D2 from a kernel over D1 and another over D2.
:param k1, k2: the kernels to multiply
:type k1, k2: kernpart
:rtype: kernel object