def test_marginal_expected_cost(self): marg_hist = dokHist(m=1) marg_hist.upcount(0, 50) marg_hist.upcount(0.5, 25) marg_hist.upcount(1.5, 25) bid = 1.5 ec = expected_cost(marg_hist, bid) self.assertAlmostEqual(ec, 0.28125) ec = expected_cost(marg_hist, 0) self.assertAlmostEqual(ec, 0.0)
def test_expected_cost(self): hist = dokHist(m=2, isdensity=True) hist.set([0, 30], 0.5) hist.set([30, 0], 0.5) bid = [25, 25] ec = expected_cost(hist, bid) self.assertAlmostEqual(ec, 0.0) bid = [31, 31] ec = expected_cost(hist, bid) self.assertAlmostEqual(ec, 29.5)