def test_consistency(self): N = 5000 parameters = {'p':.6} samples = [] for i in range(N): samples.append(rbernoulli(**parameters)) H = np.bincount(samples)*1./N l0 = exp(flib.bernoulli(0, **parameters)) l1 = exp(flib.bernoulli(1, **parameters)) assert_array_almost_equal(H, [l0,l1], 2) # Check normalization assert_almost_equal(l0+l1, 1, 4)
def test_consistency(self): N = 5000 parameters = {'p': .6} samples = [] for i in range(N): samples.append(rbernoulli(**parameters)) H = np.bincount(samples) * 1. / N l0 = exp(flib.bernoulli(0, **parameters)) l1 = exp(flib.bernoulli(1, **parameters)) assert_array_almost_equal(H, [l0, l1], 1) # Check normalization assert_almost_equal(l0 + l1, 1, 4)
def test_calling(self): a = flib.bernoulli([0,1,1,0], .4) b = flib.bernoulli([0,1,1,0], [.4, .4, .4, .4]) assert_array_equal(b,a)
def test_calling(self): a = flib.bernoulli([0, 1, 1, 0], .4) b = flib.bernoulli([0, 1, 1, 0], [.4, .4, .4, .4]) assert_array_equal(b, a)