예제 #1
0
    def test_log_likelihood_set_params_call_correct(self, m):
        """after set_params, with log_likelihood alone"""
        uv = UVHP()
        uv.set_params(5, .2, 10)
        a = np.array([2, 3, 6])

        uv.log_likelihood(a, 1000)
        m.assert_called_with(a, 5., .2, 10., 1000)
예제 #2
0
    def test_fetch(self):
        uv = UVHP()
        uv.set_params(.5, .4, .2)

        pars1 = np.array(uv._fetch_params())
        pars2 = np.array([.5, .4, .2])

        np.testing.assert_allclose(pars1, pars2)
예제 #3
0
    def test_getter(self):

        uv = UVHP()
        uv._mu, uv._alpha, uv._theta = .5, .4, .3

        pars1 = np.array(uv.get_params())
        pars2 = np.array([.5, .4, .3])

        np.testing.assert_allclose(pars1, pars2)
예제 #4
0
    def test_simple_fixture_ok(self):
        uv = UVHP()
        uv.set_params(5, .2, 10)
        T = 15.

        a = np.array([3, 4, 6, 8.2, 9., 12.])

        mu, alpha, theta = uv.get_params()

        comp = mu * T + alpha * np.sum(1 - np.exp(-theta * (T - a)))

        sum = 0
        for i in range(len(a)):
            s = mu
            for j in range(i):
                s += alpha * theta * np.exp(-theta * (a[i] - a[j]))
            sum += np.log(s)

        computed = uv.log_likelihood(a, T)
        test = sum - comp

        self.assertAlmostEqual(computed, test)
예제 #5
0
    def test_log_likelihood_calls_correct(self, m):
        uv = UVHP()
        a = np.array([2, 3, 6])

        uv.log_likelihood_with_params(a, .3, .2, 10., 1000)
        m.assert_called()
예제 #6
0
 def setUp(self):
     self.uv = UVHP()
     self.uv.set_params(5, .3, 10.)
예제 #7
0
 def test_params_start_none(self):
     uv = UVHP()
     self.assertIsNone(uv._alpha)
     self.assertIsNone(uv._mu)
     self.assertIsNone(uv._theta)
예제 #8
0
    def setUp(self):
        fpath = os.path.join(os.path.dirname(__file__), 'tfx_fixture.npy')
        self.arr = np.load(fpath)

        self.uv = UVHP()
예제 #9
0
 def setUp(self):
     self.uv = UVHP()
     self.uv.set_params(.5, .2, 10.)