class Test(unittest.TestCase):

    def setUp(self):
        self.arm = BanditArmBayesLaplace()

    def tearDown(self):
        pass

    def test_update(self):
        self.assertEqual(0, self.arm.trials)
        self.assertEqual(0, self.arm.successes)
        self.assertEqual(1.0 / 2.0, self.arm.probability)
        self.arm.update(1, 1)
        self.assertEqual(2.0 / 3.0, self.arm.probability)
        self.arm.update(1, 1)
        self.assertEqual(3.0 / 4.0, self.arm.probability)

    def test_update_p(self):
        self.arm.successes = 0
        self.arm.trials = 2
        self.arm._update_p()
        self.assertEqual(1.0 / 4.0, self.arm.probability)

        # test for BFF-521
        # if success > trials, it should use successes as the trials value
        self.arm.successes = 5
        self.arm.trials = 3
        self.arm._update_p()
        self.assertEqual(6.0 / 7.0, self.arm.probability)
Exemplo n.º 2
0
class Test(unittest.TestCase):
    def setUp(self):
        self.arm = BanditArmBayesLaplace()

    def tearDown(self):
        pass

    def test_update(self):
        self.assertEqual(0, self.arm.trials)
        self.assertEqual(0, self.arm.successes)
        self.assertEqual(1.0 / 2.0, self.arm.probability)
        self.arm.update(1, 1)
        self.assertEqual(2.0 / 3.0, self.arm.probability)
        self.arm.update(1, 1)
        self.assertEqual(3.0 / 4.0, self.arm.probability)

    def test_update_p(self):
        self.arm.successes = 0
        self.arm.trials = 2
        self.arm._update_p()
        self.assertEqual(1.0 / 4.0, self.arm.probability)

        # test for BFF-521
        # if success > trials, it should use successes as the trials value
        self.arm.successes = 5
        self.arm.trials = 3
        self.arm._update_p()
        self.assertEqual(6.0 / 7.0, self.arm.probability)
Exemplo n.º 3
0
class Test(unittest.TestCase):
    def setUp(self):
        self.arm = BanditArmBayesLaplace()

    def tearDown(self):
        pass

    def test_update_p(self):
        self.arm.update(1, 1)
        self.assertEqual(2.0 / 3.0, self.arm.probability)
        self.arm.update(1, 1)
        self.assertEqual(3.0 / 4.0, self.arm.probability)
        self.arm.successes = 0
        self.assertEqual(2, self.arm.trials)
        self.arm._update_p()
        self.assertEqual(0.25, self.arm.probability)
Exemplo n.º 4
0
class Test(unittest.TestCase):

    def setUp(self):
        self.arm = BanditArmBayesLaplace()

    def tearDown(self):
        pass

    def test_update_p(self):
        self.arm.update(1, 1)
        self.assertEqual(2.0 / 3.0, self.arm.probability)
        self.arm.update(1, 1)
        self.assertEqual(3.0 / 4.0, self.arm.probability)
        self.arm.successes = 0
        self.assertEqual(2, self.arm.trials)
        self.arm._update_p()
        self.assertEqual(0.25, self.arm.probability)
 def setUp(self):
     self.arm = BanditArmBayesLaplace()
Exemplo n.º 6
0
 def setUp(self):
     self.arm = BanditArmBayesLaplace()