def test_bounded_normal_floor_ceil(self): """ Test the bounded normal with floor and ceil. """ standard = BoundedNormalDistribution(0, 1, floor=-1, ceil=1) for idx in xrange(100000): event = standard.next() self.assertGreaterEqual(event, -1) self.assertLessEqual(event, 1)
def test_bounded_normal(self): """ Perform same normal test with an unbounded, bounded normal. """ standard = BoundedNormalDistribution(0, 1) for idx in xrange(100000): event = standard.next() self.assertGreater(event, -6) self.assertLess(event, 6)
def test_bounded_normal_floor(self): """ Test the bounded normal with only a floor. """ standard = BoundedNormalDistribution(0, 1, floor=-1) for idx in xrange(100000): event = standard.next() self.assertGreaterEqual(event, -1) self.assertLess(event, 6)
def test_bounded_normal_mean(self): """ Perform same normal mean approximation with an unbounded, bounded normal. """ dist = BoundedNormalDistribution(0, 1) samples = 1000000 total = sum(dist.next() for idx in xrange(samples)) mean = total / samples self.assertAlmostEqual(mean, 0.0, places=2)