Exemplo n.º 1
0
def test_rdnxor():
    """ Test the RdnXor distribution """
    d = RdnXor()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert i1 == pytest.approx(1)
    assert i2 == pytest.approx(1)
    assert i12 == pytest.approx(2)
    assert r == pytest.approx(1)
Exemplo n.º 2
0
def test_subtle():
    """ Test the Subtle distribution """
    d = Subtle()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert i1 == pytest.approx(0.91829583405448956)
    assert i2 == pytest.approx(0.91829583405448956)
    assert i12 == pytest.approx(1.5849625007211561)
    assert r == pytest.approx(0)
Exemplo n.º 3
0
def test_or():
    """ Test the Or distribution """
    d = Or()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert i1 == pytest.approx(0.31127812445913294)
    assert i2 == pytest.approx(0.31127812445913294)
    assert i12 == pytest.approx(0.81127812445913294)
    assert r == pytest.approx(0)
Exemplo n.º 4
0
def test_rdnxor():
    """ Test the RdnXor distribution """
    d = RdnXor()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert_almost_equal(i1, 1)
    assert_almost_equal(i2, 1)
    assert_almost_equal(i12, 2)
    assert_almost_equal(r, 1)
Exemplo n.º 5
0
def test_imperfectrdn():
    """ Test the ImperfectRdn distribution """
    d = ImperfectRdn()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert i1 == pytest.approx(1)
    assert i2 == pytest.approx(0.98959007894024409)
    assert i12 == pytest.approx(1)
    assert r == pytest.approx(0)
Exemplo n.º 6
0
def test_subtle():
    """ Test the Subtle distribution """
    d = Subtle()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert_almost_equal(i1, 0.91829583405448956)
    assert_almost_equal(i2, 0.91829583405448956)
    assert_almost_equal(i12, 1.5849625007211561)
    assert_almost_equal(r, 0)
Exemplo n.º 7
0
def test_or():
    """ Test the Or distribution """
    d = Or()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert_almost_equal(i1, 0.31127812445913294)
    assert_almost_equal(i2, 0.31127812445913294)
    assert_almost_equal(i12, 0.81127812445913294)
    assert_almost_equal(r, 0)
Exemplo n.º 8
0
def test_rdnxor():
    """ Test the RdnXor distribution """
    d = RdnXor()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert_almost_equal(i1, 1)
    assert_almost_equal(i2, 1)
    assert_almost_equal(i12, 2)
    assert_almost_equal(r, 1)
Exemplo n.º 9
0
def test_imperfectrdn():
    """ Test the ImperfectRdn distribution """
    d = ImperfectRdn()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert_almost_equal(i1, 1)
    assert_almost_equal(i2, 0.98959007894024409)
    assert_almost_equal(i12, 1)
    assert_almost_equal(r, 0)
Exemplo n.º 10
0
def test_subtle():
    """ Test the Subtle distribution """
    d = Subtle()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert_almost_equal(i1, 0.91829583405448956)
    assert_almost_equal(i2, 0.91829583405448956)
    assert_almost_equal(i12, 1.5849625007211561)
    assert_almost_equal(r, 0)
Exemplo n.º 11
0
def test_or():
    """ Test the Or distribution """
    d = Or()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert_almost_equal(i1, 0.31127812445913294)
    assert_almost_equal(i2, 0.31127812445913294)
    assert_almost_equal(i12, 0.81127812445913294)
    assert_almost_equal(r, 0)
Exemplo n.º 12
0
def test_imperfectrdn():
    """ Test the ImperfectRdn distribution """
    d = ImperfectRdn()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert_almost_equal(i1, 1)
    assert_almost_equal(i2, 0.98959007894024409)
    assert_almost_equal(i12, 1)
    assert_almost_equal(r, 0)
Exemplo n.º 13
0
def test_rdnxor():
    """ Test the RdnXor distribution """
    d = RdnXor()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert i1 == pytest.approx(1)
    assert i2 == pytest.approx(1)
    assert i12 == pytest.approx(2)
    assert r == pytest.approx(1)
Exemplo n.º 14
0
def test_or():
    """ Test the Or distribution """
    d = Or()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert i1 == pytest.approx(0.31127812445913294)
    assert i2 == pytest.approx(0.31127812445913294)
    assert i12 == pytest.approx(0.81127812445913294)
    assert r == pytest.approx(0)
Exemplo n.º 15
0
def test_subtle():
    """ Test the Subtle distribution """
    d = Subtle()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert i1 == pytest.approx(0.91829583405448956)
    assert i2 == pytest.approx(0.91829583405448956)
    assert i12 == pytest.approx(1.5849625007211561)
    assert r == pytest.approx(0)
Exemplo n.º 16
0
def test_imperfectrdn():
    """ Test the ImperfectRdn distribution """
    d = ImperfectRdn()
    d = pruned_samplespace(d)
    d = insert_meet(d, -1, [[0], [1]])
    i1 = mutual_information(d, [0], [2])
    i2 = mutual_information(d, [1], [2])
    i12 = mutual_information(d, [0, 1], [2])
    r = mutual_information(d, [2], [3])
    assert i1 == pytest.approx(1)
    assert i2 == pytest.approx(0.98959007894024409)
    assert i12 == pytest.approx(1)
    assert r == pytest.approx(0)