Ejemplo n.º 1
0
 def test_goodness_of_fit(self):
     mx = 5
     trial = 100
     vals = [random.randint(0, mx).get() for _ in range(trial)]
     counts = numpy.histogram(vals, bins=numpy.arange(mx + 1))[0]
     expected = numpy.array([float(trial) / mx] * mx)
     self.assertTrue(hypothesis.chi_square_test(counts, expected))
Ejemplo n.º 2
0
 def test_goodness_of_fit_2(self):
     mx = 5
     # vals = random.randint(mx, size=(5, 20)).get()
     # counts = numpy.histogram(vals, bins=numpy.arange(mx + 1))[0]
     vals = random.randint(mx, size=(5, 20)).reshape(5 * 20)
     counts = numpy.histogram(numpy.asarray(vals), bins=numpy.arange(mx + 1))[0]
     expected = numpy.array([float(vals.size) / mx] * mx)
     self.assertTrue(hypothesis.chi_square_test(counts, expected))