Beispiel #1
0
 def test_hermeroots(self) :
     assert_almost_equal(herme.hermeroots([1]), [])
     assert_almost_equal(herme.hermeroots([1, 1]), [-1])
     for i in range(2,5) :
         tgt = np.linspace(-1, 1, i)
         res = herme.hermeroots(herme.hermefromroots(tgt))
         assert_almost_equal(trim(res), trim(tgt))
 def test_hermeroots(self):
     assert_almost_equal(herme.hermeroots([1]), [])
     assert_almost_equal(herme.hermeroots([1, 1]), [-1])
     for i in range(2, 5):
         tgt = np.linspace(-1, 1, i)
         res = herme.hermeroots(herme.hermefromroots(tgt))
         assert_almost_equal(trim(res), trim(tgt))
def lnprob(theta):
    derivCoef = np.concatenate([[0.0, 1.0, 0.0, 0.0, 0.0, 0.0], theta])
    r = hermeroots(derivCoef)
    n = len(r) - 1
    isolated_roots = np.logical_or(
        np.abs(np.imag(r)) > 1e-6,
        np.abs(r) > np.sqrt(1.25 * n) + 1)
    origin_roots = np.logical_and(
        np.abs(np.real(r)) < 0.2, np.logical_not(isolated_roots))

    if (np.sum(origin_roots) == 1) and (np.sum(isolated_roots) == n):
        return 0.0
    else:
        return -np.inf