Example #1
0
 def test_normal(self):
     """
     Weak test of normal distributions.
     """
     standard = NormalDistribution(0, 1)
     for idx in xrange(100000):
         event = standard.next()
         self.assertGreater(event, -5)
         self.assertLess(event, 5)
 def test_normal(self):
     """
     Weak test of normal distributions.
     """
     standard = NormalDistribution(0, 1)
     for idx in xrange(100000):
         event = standard.next()
         self.assertGreater(event, -5)
         self.assertLess(event, 5)
Example #3
0
    def test_normal_mean(self):
        """
        Assert that the mean approximates the distribution.
        """
        dist = NormalDistribution(0, 1)
        samples = 1000000
        total = sum(dist.next() for idx in xrange(samples))
        mean = total / samples

        self.assertAlmostEqual(mean, 0.0, places=2)
    def test_normal_mean(self):
        """
        Assert that the mean approximates the distribution.
        """
        dist    = NormalDistribution(0, 1)
        samples = 1000000
        total   = sum(dist.next() for idx in xrange(samples))
        mean    = total / samples

        self.assertAlmostEqual(mean, 0.0, places=2)