コード例 #1
0
def test_fci1():
    """
    Test known values.
    """
    d = Distribution(['000', '011', '101', '110'], [1 / 4] * 4)
    assert F(d) == pytest.approx(2.0)
    assert F(d, [[0], [1]]) == pytest.approx(0.0)
    assert F(d, [[0], [1]], [2]) == pytest.approx(1.0)
コード例 #2
0
def test_fci2():
    """
    Test known values w/ rv names.
    """
    d = Distribution(['000', '011', '101', '110'], [1 / 4] * 4)
    d.set_rv_names('XYZ')
    assert F(d) == pytest.approx(2.0)
    assert F(d, ['X', 'Y']) == pytest.approx(0.0)
    assert F(d, ['X', 'Y'], 'Z') == pytest.approx(1.0)
コード例 #3
0
def test_fci3():
    """
    Test against known values
    """
    outcomes = [
        '000',
        'a00',
        '00c',
        'a0c',
        '011',
        'a11',
        '101',
        'b01',
        '01d',
        'a1d',
        '10d',
        'b0d',
        '110',
        'b10',
        '11c',
        'b1c',
    ]
    pmf = [1 / 16] * 16
    d = Distribution(outcomes, pmf)
    assert F(d) == pytest.approx(2.0)
コード例 #4
0
def test_cis2(dist):
    """
    Test that the common informations are ordered correctly.
    """
    k = K(dist)
    j = J(dist)
    b = B(dist)
    c = C(dist)
    g = G(dist)
    f = F(dist)
    m = M(dist)
    assert k <= j + epsilon
    assert j <= b + epsilon
    assert b <= c + epsilon
    assert c <= g + epsilon
    assert g <= f + epsilon
    assert f <= m + epsilon