Esempio n. 1
0
def test_renyi_entropy_3(alpha):
    """
    Test that negative orders raise ValueErrors.
    """
    d = uniform(8)
    with pytest.raises(ValueError):
        renyi_entropy(d, alpha)
Esempio n. 2
0
def test_renyi_entropy_3(alpha):
    """
    Test that negative orders raise ValueErrors.
    """
    d = uniform(8)
    with pytest.raises(ValueError):
        renyi_entropy(d, alpha)
Esempio n. 3
0
def test_renyi_entropy_2(alpha):
    """
    Test the Renyi entropy of joint distributions.
    """
    d = Distribution(['00', '11', '22', '33'], [1 / 4] * 4)
    assert renyi_entropy(d, alpha) == pytest.approx(2)
    assert renyi_entropy(d, alpha, [0]) == pytest.approx(2)
    assert renyi_entropy(d, alpha, [1]) == pytest.approx(2)
Esempio n. 4
0
def test_renyi_entropy_2(alpha):
    """
    Test the Renyi entropy of joint distributions.
    """
    d = Distribution(['00', '11', '22', '33'], [1/4]*4)
    assert renyi_entropy(d, alpha) == pytest.approx(2)
    assert renyi_entropy(d, alpha, [0]) == pytest.approx(2)
    assert renyi_entropy(d, alpha, [1]) == pytest.approx(2)
Esempio n. 5
0
def test_renyi_entropy_2():
    """
    Test the Renyi entropy of joint distributions.
    """
    d = Distribution(['00', '11', '22', '33'], [1/4]*4)
    for alpha in [0, 1/2, 1, 2, 5, np.inf]:
        yield assert_almost_equal, renyi_entropy(d, alpha), 2
        yield assert_almost_equal, renyi_entropy(d, alpha, [0]), 2
        yield assert_almost_equal, renyi_entropy(d, alpha, [1]), 2
def test_renyi(alpha):
    """
    Consistency test for Renyi entropy and Renyi divergence
    """
    dist1 = Distribution(['0', '1', '2'], [1/4, 1/2, 1/4])
    uniform = Distribution(['0', '1', '2'], [1/3, 1/3, 1/3])
    h = renyi_entropy(dist1, alpha)
    h_u = renyi_entropy(uniform, alpha)
    div = renyi_divergence(dist1, uniform, alpha)
    assert h == pytest.approx(h_u - div)
def test_renyi(alpha):
    """
    Consistency test for Renyi entropy and Renyi divergence
    """
    dist1 = Distribution(['0', '1', '2'], [1/4, 1/2, 1/4])
    uniform = Distribution(['0', '1', '2'], [1/3, 1/3, 1/3])
    h = renyi_entropy(dist1, alpha)
    h_u = renyi_entropy(uniform, alpha)
    div = renyi_divergence(dist1, uniform, alpha)
    assert h == pytest.approx(h_u - div)
def test_renyi():
    """
    Consistency test for Renyi entropy and Renyi divergence
    """
    dist1 = Distribution(['0', '1', '2'], [1/4, 1/2, 1/4])
    uniform = Distribution(['0', '1', '2'], [1/3, 1/3, 1/3])
    alphas = [0, 1, 2, 0.5]
    for alpha in alphas:
        h = renyi_entropy(dist1, alpha)
        h_u = renyi_entropy(uniform, alpha)
        div = renyi_divergence(dist1, uniform, alpha)
        assert_almost_equal(h, h_u - div)
Esempio n. 9
0
def test_renyi():
    """
    Consistency test for Renyi entropy and Renyi divergence
    """
    dist1 = Distribution(['0', '1', '2'], [1 / 4, 1 / 2, 1 / 4])
    uniform = Distribution(['0', '1', '2'], [1 / 3, 1 / 3, 1 / 3])
    alphas = [0, 1, 2, 0.5]
    for alpha in alphas:
        h = renyi_entropy(dist1, alpha)
        h_u = renyi_entropy(uniform, alpha)
        div = renyi_divergence(dist1, uniform, alpha)
        assert_almost_equal(h, h_u - div)
Esempio n. 10
0
def test_renyi_entropy_1(alpha):
    """
    Test that the Renyi entropy of a uniform distirbution is indipendent of the
    order.
    """
    d = uniform(8)
    assert renyi_entropy(d, alpha) == pytest.approx(3)
Esempio n. 11
0
def test_renyi_entropy_1(alpha):
    """
    Test that the Renyi entropy of a uniform distirbution is indipendent of the
    order.
    """
    d = uniform(8)
    assert renyi_entropy(d, alpha) == pytest.approx(3)
Esempio n. 12
0
def test_renyi_entropy_1():
    """
    Test that the Renyi entropy of a uniform distirbution is indipendent of the
    order.
    """
    d = uniform(8)
    for alpha in [0, 1/2, 1, 2, 5, np.inf]:
        yield assert_almost_equal, renyi_entropy(d, alpha), 3