Exemplo n.º 1
0
 def test_sumprod(self,thr=1e-6):
     """ Test the sum of products of several mean functions.
     """
     m1 = mean.one()
     m2 = mean.linear(a=np.random.rand(self.D))
     m3 = mean.one()
     m4 = mean.linear(a=np.random.rand(self.D))
     self.run_verifications(2.3*m1+m2*1.2+m3*m4,thr)
Exemplo n.º 2
0
 def test_prodsum(self,thr=1e-6):
     """ Test the product of sums of several mean functions.
     """
     m1 = mean.one()
     m2 = mean.linear(a=np.random.rand(self.D))
     m3 = mean.one()
     m4 = mean.linear(a=np.random.rand(self.D))
     self.run_verifications((2.3+m1)*(m2+1.2)*(m3+m4),thr)
Exemplo n.º 3
0
 def test_pow(self,thr=1e-6):
     """ Test power of a mean function.
     """
     n,D,X = self.n,self.D,self.X
     m1 = mean.one()
     m2 = mean.linear(a=np.random.rand(self.D))
     m = 1.2*m1 * m2**2
     d = np.linalg.norm( 1.2*m1(X)*m2(X)**2 - m(X) )
     self.assertLessEqual(d,thr)
     self.run_verifications(m,thr)
Exemplo n.º 4
0
 def test_prod(self,thr=1e-6):
     """ Test the product of several mean functions.
     """
     n,D,X = self.n,self.D,self.X
     m1 = mean.one()
     m2 = mean.linear(a=np.random.rand(self.D))
     m = m1*m2*1.7
     d = np.linalg.norm( m1(X)*m2(X)*1.7 - m(X) )
     self.assertLessEqual(d,thr)
     self.run_verifications(m,thr)
Exemplo n.º 5
0
 def test_sum(self,thr=1e-6):
     """ Test the sum of several meanfunctions.
     """
     n,D,X = self.n,self.D,self.X
     m1 = mean.one()
     m2 = mean.linear(a=np.random.rand(self.D))
     m = m1+m2+1.2
     d = np.linalg.norm( m1(X)+m2(X)+1.2 - m(X) )
     self.assertLessEqual(d,thr)
     self.run_verifications(m,thr)
Exemplo n.º 6
0
 def test_ep(self,thr=1e-4):
     """ Test expectation propagation approximate inference.
     """
     im = inf.ep
     cf,mf,lf = 1.1*cov.se(ell=0.8),mean.zero(),lik.erf()
     self.run_verifications(im,cf,mf,lf,thr)
     lf = lik.gauss(sn=0.2)
     self.run_verifications(im,cf,mf,lf,thr)
     mf = 2.3*mean.one()
     self.run_verifications(im,cf,mf,lf,thr)
     cf = 1.3*cov.se(ell=[0.8,0.7,0.3])
     self.run_verifications(im,cf,mf,lf,thr)
     mf = 1.3*mean.linear(a=[0.8,0.7,0.3])
     self.run_verifications(im,cf,mf,lf,thr)
Exemplo n.º 7
0
 def test_exact(self,thr=1e-4):
     """ Test exact inference.
     """
     im = inf.exact
     cf,mf,lf = 1.1*cov.se(ell=0.8),mean.zero(),lik.gauss(sn=1e-5)
     self.run_verifications(im,cf,mf,lf,thr)
     lf = lik.gauss(sn=0.2)
     self.run_verifications(im,cf,mf,lf,thr)
     mf = 2.3*mean.one()
     self.run_verifications(im,cf,mf,lf,thr)
     cf = 1.3*cov.se(ell=[0.8,0.7,0.3])
     self.run_verifications(im,cf,mf,lf,thr)
     mf = 1.3*mean.linear(a=[0.8,0.7,0.3])
     self.run_verifications(im,cf,mf,lf,thr)
Exemplo n.º 8
0
 def test_linear(self,thr=1e-6):
     """ Test one mean.
     """
     n,D,X = self.n,self.D,self.X
     m = mean.linear(a=np.random.randn(D))
     self.run_verifications(m,thr)