Example #1
0
 def test_expected_value(self):
     for i, pdfs in enumerate(zip(self.priors, self.posteriors)):
         prior, posterior = pdfs
         with self.subTest(i=i):
             bayesparam = beer.BayesianParameter(prior, posterior)
             self.assertArraysAlmostEqual(
                 bayesparam.expected_value().numpy(),
                 posterior.expected_sufficient_statistics.numpy())
Example #2
0
 def test_create(self):
     for i, pdfs in enumerate(zip(self.priors, self.posteriors)):
         prior, posterior = pdfs
         with self.subTest(i=i):
             bayesparam = beer.BayesianParameter(prior, posterior)
             self.assertArraysAlmostEqual(
                 bayesparam.natural_grad.numpy(),
                 np.zeros(len(bayesparam.natural_grad)))
Example #3
0
 def test_expected_value(self):
     for i in range(self.nparams):
         with self.subTest(i=i):
             pdfs = zip(self.priors[i], self.posteriors[i])
             params = [
                 beer.BayesianParameter(prior, posterior)
                 for prior, posterior in pdfs
             ]
             param_set = beer.BayesianParameterSet(params)
             for j, param in enumerate(param_set):
                 posterior = self.posteriors[i][j]
                 self.assertArraysAlmostEqual(
                     param.expected_value().numpy(),
                     posterior.expected_sufficient_statistics.numpy())
Example #4
0
 def test_create(self):
     for i in range(self.nparams):
         with self.subTest(i=i):
             pdfs = zip(self.priors[i], self.posteriors[i])
             params = [
                 beer.BayesianParameter(prior, posterior)
                 for prior, posterior in pdfs
             ]
             param_set = beer.BayesianParameterSet(params)
             self.assertEqual(len(params), len(param_set))
             for param in param_set:
                 self.assertArraysAlmostEqual(
                     param.natural_grad.numpy(),
                     np.zeros(len(param.natural_grad)))