Esempio n. 1
0
def test_R5():
    """ Test that R fails on SDs """
    d = SD([1 / 4] * 4)
    with pytest.raises(ditException):
        R(d)
Esempio n. 2
0
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))
Esempio n. 3
0
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)
Esempio n. 4
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]))
Esempio n. 5
0
def test_R1():
    """ Test R for dependent variables """
    d = D(['00', '11'], [1 / 2, 1 / 2])
    assert R(d) == pytest.approx(0)
Esempio n. 6
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)
Esempio n. 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))
Esempio n. 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]))
Esempio n. 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)
Esempio n. 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)
Esempio n. 11
0
def test_R1():
    """ Test R for dependent variables """
    d = D(['00', '11'], [1 / 2, 1 / 2])
    assert_almost_equal(R(d), 0)