コード例 #1
0
def test_simple_rd_4():
    """
    Test against know result, using scipy.
    """
    dist = Distribution(['0', '1'], [1 / 2, 1 / 2])
    rd = RDCurve(dist, beta_num=10, alpha=0.0, distortion=residual_entropy)
    assert rd.distortions[0] == pytest.approx(1.0)
コード例 #2
0
ファイル: test_curves.py プロジェクト: psychon7/dit
def test_simple_rd_6():
    """
    Test against know result, using blahut-arimoto.
    """
    dist = Distribution(['0', '1'], [1/2, 1/2])
    rd = RDCurve(dist, rv=[0], beta_num=10, beta_max=None, method='ba', distortion=residual_entropy)
    assert rd.distortions[0] == pytest.approx(2.0)
コード例 #3
0
ファイル: test_curves.py プロジェクト: psychon7/dit
def test_simple_rd_3():
    """
    Test against know result, using scipy.
    """
    dist = Distribution(['00', '01', '10', '11'], [1/4]*4)
    rd = RDCurve(dist, rv=[0], crvs=[1], beta_num=10, alpha=0.5, distortion=maximum_correlation)
    assert rd.distortions[0] == pytest.approx(1.0)
コード例 #4
0
def test_simple_rd_5():
    """
    Test against know result, using blahut-arimoto.
    """
    dist = Distribution(['0', '1'], [1 / 2, 1 / 2])
    rd = RDCurve(dist, beta_num=10, method='ba')
    for r, d in zip(rd.rates, rd.distortions):
        assert r == pytest.approx(1 - entropy(d))
コード例 #5
0
def test_simple_rd_1():
    """
    Test against know result, using scipy.
    """
    dist = Distribution(['0', '1'], [1 / 2, 1 / 2])
    rd = RDCurve(dist, beta_num=10)
    for r, d in zip(rd.rates, rd.distortions):
        assert r == pytest.approx(1 - entropy(d))