Example #1
0
 def test_hypergeometric_pmf_sum_up_to_one(self, test_range, n, y_j):
     for x in test_range:
         probs = [
             prob for _, prob in info_theory._hypergeometric_pmf(n, x, y_j)
         ]
         sum_prob = sum(probs)
         self.assertNear(sum_prob, 1.0, EPSILON)
Example #2
0
 def testHypergeometricPmf_LargeN(self):
     expected_results = [(0, 0.9508937), (1, 0.0482198), (2, 0.0008794),
                         (3, 7.1e-06), (4, 2.5e-08), (5, 0.0)]
     results = list(info_theory._hypergeometric_pmf(1000, 5, 10))
     for expected_result, result in zip(expected_results, results):
         self.assertEqual(expected_result[0], result[0])
         self.assertNear(expected_result[1], result[1], EPSILON)
Example #3
0
 def testHypergeometricPmf_SumUpToOne(self):
   for x in range(1000, 10000):
     probs = [
         prob for _, prob in info_theory._hypergeometric_pmf(10000, x, 1000)
     ]
     sum_prob = sum(probs)
     self.assertNear(sum_prob, 1.0, EPSILON)
Example #4
0
 def testHypergeometricPmf(self):
     expected_results = [(0, 0.75), (1, 0.25)]
     results = list(info_theory._hypergeometric_pmf(4, 1, 1))
     for expected_result, result in zip(expected_results, results):
         self.assertEqual(expected_result[0], result[0])
         self.assertNear(expected_result[1], result[1], EPSILON)