def boom(self): """ Return the boom.MvnModel corresponding to this object's parameters. """ import BayesBoom.boom as boom return boom.MvnModel(boom.Vector(self._mu), boom.SpdMatrix(self._Sigma))
def _default_initial_state_prior(self, sdy): """ The default prior to use for the initial state vector. """ dim = self.nseasons - 1 return boom.MvnModel( boom.Vector(np.zeros(dim).astype(float)), boom.SpdMatrix(np.diag(np.full(dim, float(sdy)))))
def test_parameters(self): """When parameters are modified outside the object, the object properties should change. This is testing that pointers are being stored. """ zeros = boom.Vector(np.array([0, 0, 0])) model = boom.MvnModel(zeros, self.Sigma) mu_prm = model.mean_parameter new_mu = boom.Vector(np.array([3.0, 2.0, 1.0])) mu_prm.set(new_mu) self.assertLess((model.mu - new_mu).normsq(), 1e-5)
def test_data(self): model = boom.MvnModel(self.mu, self.Sigma) model.set_data(boom.Matrix(self.data)) model.mle() self.assertLess(model.siginv.Mdist(self.mu, model.mu), .05)
def test_moments(self): model = boom.MvnModel(self.mu, self.Sigma) self.assertLess((model.mu - self.mu).normsq(), 1e-5) self.assertTrue( np.allclose(model.Sigma.to_numpy(), self.Sigma.to_numpy()))
def slab(self): return boom.MvnModel(R.to_boom_vector(self._prior_mean), R.to_boom_spd(np.diag(self._prior_sd**2)))
def slab(self): return boom.MvnModel(boom.Vector(self._mean), boom.SpdMatrix(self._precision), True)