def test_prepare(self): d = Distribution(["A", "B", "C", "D"], [3, 3, -1, 0]) d.prepare() self.assertEqual(d.getNormalizingConstant(), 6) self.assertEqual(d["A"], 0.5) self.assertEqual(d["B"], 0.5) self.assertEqual(d["C"], 0.0) self.assertEqual(d["D"], 0.0)
def test_normalize(self): d = Distribution(["A", "B"], [3, 3]) self.assertEqual(d.normalize(), 6) self.assertEqual(d.getNormalizingConstant(), 6) self.assertEqual(d["A"], 0.5)