Beispiel #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, -6)
         self.assertLess(event, 6)
Beispiel #2
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, -6)
         self.assertLess(event, 6)
Beispiel #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)
Beispiel #4
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)
Beispiel #5
0
    def test_normal_stddev(self):
        """
        Test the standard deviation computation for a normal distribution
        """
        cases = (
            ((0, 1), 1),
            ((12.4, 1.2), 1.2),
        )

        for args, stddev in cases:
            dist = NormalDistribution(*args)
            self.assertAlmostEqual(dist.get_stddev(), stddev, places=4)
Beispiel #6
0
    def test_normal_variance(self):
        """
        Test the variance computation for a normal distribution
        """
        cases = (
            ((0, 1), 1),
            ((12.4, 1.2), 1.44),
        )

        for args, variance in cases:
            dist = NormalDistribution(*args)
            self.assertAlmostEqual(dist.get_variance(), variance, places=4)
Beispiel #7
0
    def test_normal_get_mean(self):
        """
        Test the mean computation for a normal distribution
        """
        cases = (
            ((0, 1), 0),
            ((12.4, 1.2), 12.4),
        )

        for args, mean in cases:
            dist = NormalDistribution(*args)
            self.assertAlmostEqual(dist.get_mean(), mean, places=4)
Beispiel #8
0
    def test_normal_stddev(self):
        """
        Test the standard deviation computation for a normal distribution
        """
        cases = (
            ((0, 1), 1),
            ((12.4, 1.2), 1.2),
        )

        for args, stddev in cases:
            dist = NormalDistribution(*args)
            self.assertAlmostEqual(dist.get_stddev(), stddev, places=4)
Beispiel #9
0
    def test_normal_variance(self):
        """
        Test the variance computation for a normal distribution
        """
        cases = (
            ((0, 1), 1),
            ((12.4, 1.2), 1.44),
        )

        for args, variance in cases:
            dist = NormalDistribution(*args)
            self.assertAlmostEqual(dist.get_variance(), variance, places=4)
Beispiel #10
0
    def test_normal_get_mean(self):
        """
        Test the mean computation for a normal distribution
        """
        cases = (
            ((0, 1), 0),
            ((12.4, 1.2), 12.4),
        )

        for args, mean in cases:
            dist = NormalDistribution(*args)
            self.assertAlmostEqual(dist.get_mean(), mean, places=4)