Пример #1
0
def test_sc_2():
    """
    Test the distribution.
    """
    sc = SecrecyCapacity(intrinsic_1, [0], [1], [2], bound_u=2)
    sc.optimize(x0=sc.construct_random_initial())
    d = sc.construct_distribution()
    assert total_correlation(d, [[3], [1]]) - total_correlation(d, [[3], [2]]) == pytest.approx(0)
Пример #2
0
def test_sc_2():
    """
    Test the distribution.
    """
    sc = SecrecyCapacity(intrinsic_1, [0], [1], [2], bound_u=2)
    sc.optimize(x0=sc.construct_random_initial())
    d = sc.construct_distribution()
    assert total_correlation(d, [[3], [1]]) - total_correlation(
        d, [[3], [2]]) == pytest.approx(0)
Пример #3
0
def test_bounds(dist):
    """
    I[X:Y v Z] <= I[X:Y]
    I[X:Y v Z] <= I[X:Y|Z]
    """
    imi = IMI.intrinsic_total_correlation(dist, [[0], [1]], [2])
    mi = total_correlation(dist, [[0], [1]])
    cmi = total_correlation(dist, [[0], [1]], [2])
    assert imi <= mi + 1e-10
    assert imi <= cmi + 1e-10
def test_bounds(dist):
    """
    I[X:Y v Z] <= I[X:Y]
    I[X:Y v Z] <= I[X:Y|Z]
    """
    imi = IMI.intrinsic_total_correlation(dist, [[0], [1]], [2])
    mi = total_correlation(dist, [[0], [1]])
    cmi = total_correlation(dist, [[0], [1]], [2])
    assert imi <= mi + 1e-10
    assert imi <= cmi + 1e-10
Пример #5
0
def test_cohesion_1(dist):
    """
    Test that k=1 is the total correlation.
    """
    tc = total_correlation(dist)
    c = cohesion(dist, k=1)
    assert tc == pytest.approx(c)
Пример #6
0
def test_itc5():
    """
    Test with initial condition.
    """
    itc = IMI.IntrinsicTotalCorrelation(dist1, [[0], [1]], [2])
    itc.optimize(x0=np.eye(4).ravel(), niter=5)
    d = itc.construct_distribution()
    print(d)
    val = total_correlation(d, [[0], [1]], [3])
    assert val == pytest.approx(0)
def test_itc5():
    """
    Test with initial condition.
    """
    itc = IMI.IntrinsicTotalCorrelation(dist1, [[0], [1]], [2])
    itc.optimize(x0=np.eye(4).ravel(), niter=5)
    d = itc.construct_distribution()
    print(d)
    val = total_correlation(d, [[0], [1]], [3])
    assert val == pytest.approx(0)