def test_tc7(): """ Test T = I with two variables """ outcomes = ['00', '01', '11'] pmf = [1 / 3] * 3 d = D(outcomes, pmf) assert_almost_equal(T(d), I(d, [0], [1])) d.set_rv_names("XY") assert_almost_equal(T(d), I(d, ['X'], ['Y']))
def test_tc7(): """ Test T = I with two variables """ outcomes = ['00', '01', '11'] pmf = [1/3] * 3 d = D(outcomes, pmf) assert T(d) == pytest.approx(I(d, [0], [1])) d.set_rv_names("XY") assert T(d) == pytest.approx(I(d, ['X'], ['Y']))
def test_I3(): """ Test mutual information of overlapping variables """ outcomes = ['000', '011', '101', '110'] pmf = [1 / 4] * 4 d = D(outcomes, pmf) assert I(d, [0, 1], [1, 2]) == pytest.approx(2.0)
def test_I2(): """ Test mutual information of dependent variables """ outcomes = ['00', '11'] pmf = [1 / 2] * 2 d = D(outcomes, pmf) assert I(d, [0], [1]) == pytest.approx(1.0)
def test_I1(): """ Test mutual information of independent variables """ outcomes = ['00', '01', '10', '11'] pmf = [1 / 4] * 4 d = D(outcomes, pmf) assert I(d, [0], [1]) == pytest.approx(0.0)
def test_I3(): """ Test mutual information of overlapping variables """ outcomes = ['000', '011', '101', '110'] pmf = [1 / 4] * 4 d = D(outcomes, pmf) assert_almost_equal(I(d, [0, 1], [1, 2]), 2.0)
def test_I2(): """ Test mutual information of dependent variables """ outcomes = ['00', '11'] pmf = [1 / 2] * 2 d = D(outcomes, pmf) assert_almost_equal(I(d, [0], [1]), 1.0)
def test_I1(): """ Test mutual information of independent variables """ outcomes = ['00', '01', '10', '11'] pmf = [1 / 4] * 4 d = D(outcomes, pmf) assert_almost_equal(I(d, [0], [1]), 0.0)
def test_R4(): """ Test that R = H - I in two variables """ d = D(['00', '01', '11'], [1 / 3] * 3) assert R(d) == pytest.approx(H(d) - I(d, [0], [1]))
def test_B5(): """ Test B = I for two variables """ d = D(['00', '01', '11'], [1 / 3] * 3) assert B(d) == pytest.approx(I(d, [0], [1]))
def test_R4(): """ Test that R = H - I in two variables """ d = D(['00', '01', '11'], [1 / 3] * 3) assert_almost_equal(R(d), H(d) - I(d, [0], [1]))
def test_B5(): """ Test B = I for two variables """ d = D(['00', '01', '11'], [1 / 3] * 3) assert_almost_equal(B(d), I(d, [0], [1]))