def test_R5():
    """ Test that R fails on SDs """
    d = SD([1 / 4] * 4)
    with pytest.raises(ditException):
        R(d)
def test_BR1():
    """ Test that B + R = H """
    d = D(['000', '001', '010', '100', '111'], [1 / 5] * 5)
    assert B(d) + R(d) == pytest.approx(H(d))
def test_R3():
    """ Test R for a generic distribution """
    d = D(['000', '011', '101', '110'], [1 / 4] * 4)
    assert R(d) == pytest.approx(0)
    assert R(d, [[0, 1], [2]]) == pytest.approx(1)
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_R1():
    """ Test R for dependent variables """
    d = D(['00', '11'], [1 / 2, 1 / 2])
    assert R(d) == pytest.approx(0)
def test_R2():
    """ Test R for independent variables """
    d = D(['00', '01', '10', '11'], [1 / 4] * 4)
    assert R(d) == pytest.approx(2)
    assert R(d, [[0], [1]]) == pytest.approx(2)
示例#7
0
def test_BR1():
    """ Test that B + R = H """
    d = D(['000', '001', '010', '100', '111'], [1 / 5] * 5)
    assert_almost_equal(B(d) + R(d), H(d))
示例#8
0
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]))
示例#9
0
def test_R3():
    """ Test R for a generic distribution """
    d = D(['000', '011', '101', '110'], [1 / 4] * 4)
    assert_almost_equal(R(d), 0)
    assert_almost_equal(R(d, [[0, 1], [2]]), 1)
示例#10
0
def test_R2():
    """ Test R for independent variables """
    d = D(['00', '01', '10', '11'], [1 / 4] * 4)
    assert_almost_equal(R(d), 2)
    assert_almost_equal(R(d, [[0], [1]]), 2)
示例#11
0
def test_R1():
    """ Test R for dependent variables """
    d = D(['00', '11'], [1 / 2, 1 / 2])
    assert_almost_equal(R(d), 0)