示例#1
0
 def test_constant_random(self):
     x = AR.dist(
         rho=[100, 0, 0],
         sigma=0.1,
         init_dist=Normal.dist(-100.0, sigma=0.1),
         constant=True,
         shape=(6, ),
     )
     x_eval = x.eval()
     assert np.allclose(x_eval[:2], -100, rtol=0.1)
     assert np.allclose(x_eval[2:], 100, rtol=0.1)
示例#2
0
    def test_multivariate_init_dist(self):
        init_dist = Dirichlet.dist(a=np.full((5, 2), [1, 10]))
        x = AR.dist(rho=[0, 0], init_dist=init_dist, steps=0)

        x_eval = x.eval()
        assert x_eval.shape == (5, 2)

        init_dist_eval = init_dist.eval()
        init_dist_logp_eval = logp(init_dist, init_dist_eval).eval()
        x_logp_eval = logp(x, init_dist_eval).eval()
        assert x_logp_eval.shape == (5, )
        assert np.allclose(x_logp_eval, init_dist_logp_eval)