def test_maxlikelihood(self): ''' Test function of Maximum Likelihood Estimate. ''' def probfn(prob): return prob fn = ts.likelihood(probfn, self.estimates, log=True) dfn = cl.diffn(fn) chk = 7/10
def test_differentiate_makefunc(self): """ Make differentiate function test. """ def testfn(p): return 7 * math.log(p) + 3 * math.log(1 - p) testprob = 0.1 # @cl.diffn(testfn) # def resfn(x, dx): pass resfn = cl.diffn(testfn) def chkfn(p): return 7 * (1 / p) + 3 * (1 / (1 - p)) * (-1) res = resfn(testprob, self.dx) chk = chkfn(testprob) r = 2 # Convenient value for round... self.assertEqual(round(res, r), round(chk, r))