Ejemplo n.º 1
0
 def test_init(self):
     rg = RandomGenerator(self.brng())
     state = rg.state
     rg.standard_normal(1)
     rg.standard_normal(1)
     rg.state = state
     new_state = rg.state
     assert_(comp_state(state, new_state))
Ejemplo n.º 2
0
 def test_reset_state_gauss(self):
     rg = RandomGenerator(self.brng(*self.seed))
     rg.standard_normal()
     state = rg.state
     n1 = rg.standard_normal(size=10)
     rg2 = RandomGenerator(self.brng())
     rg2.state = state
     n2 = rg2.standard_normal(size=10)
     assert_array_equal(n1, n2)
Ejemplo n.º 3
0
    def test_gauss_inv(self):
        n = 25
        rs = RandomGenerator(self.brng(*self.data1['seed']))
        gauss = rs.standard_normal(n)
        assert_allclose(gauss, gauss_from_uint(self.data1['data'], n, 'dsfmt'))

        rs = RandomGenerator(self.brng(*self.data2['seed']))
        gauss = rs.standard_normal(25)
        assert_allclose(gauss, gauss_from_uint(self.data2['data'], n, 'dsfmt'))
Ejemplo n.º 4
0
 def test_normal_zig_floats(self):
     rg = RandomGenerator(self.brng())
     warmup(rg)
     state = rg.state
     r1 = rg.standard_normal(11, dtype=np.float32)
     rg2 = RandomGenerator(self.brng())
     warmup(rg2)
     rg2.state = state
     r2 = rg2.standard_normal(11, dtype=np.float32)
     assert_array_equal(r1, r2)
     assert_equal(r1.dtype, np.float32)
     assert_(comp_state(rg.state, rg2.state))