def test_estimate(self): print "Testing parameter estimation of Dirichlet distribution ..." sys.stdout.flush() myalpha = 10.0 * np.random.rand(10) p = Distributions.Dirichlet({'alpha': myalpha}) dat = p.sample(50000) p = Distributions.Dirichlet({'alpha': np.random.rand(10)}) p.estimate(dat) alpha = p.param['alpha'] self.assertTrue( np.max(np.abs(alpha - myalpha)) < self.TolParam, 'Difference in alpha parameter for Dirichlet distribution greater than ' + str(self.TolParam))
def test_loglik(self): print "Testing log-likelihood of Dirichlet distribution ... " sys.stdout.flush() p = Distributions.Dirichlet({'alpha': self.alpha}) l = p.loglik(self.X) for k in range(len(self.LL)): self.assertTrue( np.abs(l[k] - self.LL[k]) < self.Tol, 'Difference in log-likelihood for Dirichlet greater than ' + str(self.Tol))