コード例 #1
0
def test_J6():
    """ Test a property of J from result 2 of the paper with base 10 """
    for i in range(2, 10):
        d = SD([1 / i] * i)
        d.set_base(10)
        yield assert_almost_equal, J(d), (i - 1) * (np.log10(i) -
                                                    np.log10(i - 1))
コード例 #2
0
ファイル: test_npscalardist.py プロジェクト: psychon7/dit
def test_init9():
    outcomes = [0, 1, 2]
    pmf = [1 / 3] * 3
    d1 = ScalarDistribution(outcomes, pmf)
    d2 = ScalarDistribution.from_distribution(d1, base=10)
    d1.set_base(10)
    assert d1.is_approx_equal(d2)
コード例 #3
0
ファイル: test_npscalardist.py プロジェクト: gto00002/dit
def test_init9():
    outcomes = [0, 1, 2]
    pmf = [1 / 3] * 3
    d1 = ScalarDistribution(outcomes, pmf)
    d2 = ScalarDistribution.from_distribution(d1, base=10)
    d1.set_base(10)
    assert_true(d1.is_approx_equal(d2))
コード例 #4
0
ファイル: test_extropy.py プロジェクト: vreuter/dit
def test_J5(i):
    """ Test a property of J from result 2 of the paper with a log base """
    d = SD([1/i]*i)
    d.set_base('e')
    assert J(d) == pytest.approx((i-1)*(np.log(i)-np.log(i-1)))
コード例 #5
0
ファイル: test_extropy.py プロジェクト: fiatflux/dit
def test_J8():
    for i in range(3, 10):
        d = SD([1/i]*i)
        d.set_base(i)
        assert(J(d) < H(d))
コード例 #6
0
ファイル: test_extropy.py プロジェクト: fiatflux/dit
def test_J6():
    for i in range(2, 10):
        d = SD([1/i]*i)
        d.set_base(10)
        assert_almost_equal(J(d), (i-1)*(np.log10(i)-np.log10(i-1)))
コード例 #7
0
ファイル: test_perplexity.py プロジェクト: liangkai/dit
def test_p2():
    """ Test some simple base cases using SD with varying bases """
    for i in range(2, 10):
        d = SD([1 / i] * i)
        d.set_base(i)
        yield assert_almost_equal, P(d), i
コード例 #8
0
ファイル: test_perplexity.py プロジェクト: psychon7/dit
def test_p2(i):
    """ Test some simple base cases using SD with varying bases """
    d = SD([1 / i] * i)
    d.set_base(i)
    assert P(d) == pytest.approx(i)
コード例 #9
0
ファイル: test_extropy.py プロジェクト: Autoplectic/dit
def test_J5(i):
    """ Test a property of J from result 2 of the paper with a log base """
    d = SD([1/i]*i)
    d.set_base('e')
    assert J(d) == pytest.approx((i-1)*(np.log(i)-np.log(i-1)))
コード例 #10
0
ファイル: test_perplexity.py プロジェクト: Autoplectic/dit
def test_p2(i):
    """ Test some simple base cases using SD with varying bases """
    d = SD([1/i]*i)
    d.set_base(i)
    assert P(d) == pytest.approx(i)
コード例 #11
0
ファイル: test_shannon.py プロジェクト: liangkai/dit
def test_H4():
    """ Test entropy in base 10 """
    d = SD([1 / 10] * 10)
    d.set_base(10)
    assert_almost_equal(H(d), 1.0)
コード例 #12
0
ファイル: test_extropy.py プロジェクト: chebee7i/dit
def test_J8():
    """ Test a property of J from result 1 of the paper using log bases """
    for i in range(3, 10):
        d = SD([1/i]*i)
        d.set_base(i)
        yield assert_true, J(d) < H(d)
コード例 #13
0
ファイル: test_extropy.py プロジェクト: chebee7i/dit
def test_J6():
    """ Test a property of J from result 2 of the paper with base 10 """
    for i in range(2, 10):
        d = SD([1/i]*i)
        d.set_base(10)
        yield assert_almost_equal, J(d), (i-1)*(np.log10(i)-np.log10(i-1))
コード例 #14
0
ファイル: test_shannon.py プロジェクト: fiatflux/dit
def test_H4():
    d = SD([1/10]*10)
    d.set_base(10)
    assert_almost_equal(H(d), 1.0)
コード例 #15
0
ファイル: test_extropy.py プロジェクト: vreuter/dit
def test_J6(i):
    """ Test a property of J from result 2 of the paper with base 10 """
    d = SD([1/i]*i)
    d.set_base(10)
    assert J(d) == pytest.approx((i-1)*(np.log10(i)-np.log10(i-1)))
コード例 #16
0
ファイル: test_extropy.py プロジェクト: vreuter/dit
def test_J8(i):
    """ Test a property of J from result 1 of the paper using log bases """
    d = SD([1/i]*i)
    d.set_base(i)
    assert J(d) < H(d)
コード例 #17
0
ファイル: test_extropy.py プロジェクト: Autoplectic/dit
def test_J6(i):
    """ Test a property of J from result 2 of the paper with base 10 """
    d = SD([1/i]*i)
    d.set_base(10)
    assert J(d) == pytest.approx((i-1)*(np.log10(i)-np.log10(i-1)))
コード例 #18
0
ファイル: test_extropy.py プロジェクト: Autoplectic/dit
def test_J8(i):
    """ Test a property of J from result 1 of the paper using log bases """
    d = SD([1/i]*i)
    d.set_base(i)
    assert J(d) < H(d)
コード例 #19
0
ファイル: test_perplexity.py プロジェクト: gto00002/dit
def test_p2():
    """ Test some simple base cases using SD with varying bases """
    for i in range(2, 10):
        d = SD([1 / i] * i)
        d.set_base(i)
        yield assert_almost_equal, P(d), i
コード例 #20
0
def test_J8():
    """ Test a property of J from result 1 of the paper using log bases """
    for i in range(3, 10):
        d = SD([1 / i] * i)
        d.set_base(i)
        yield assert_true, J(d) < H(d)
コード例 #21
0
ファイル: test_perplexity.py プロジェクト: fiatflux/dit
def test_p2():
    for i in range(2, 10):
        d = SD([1/i]*i)
        d.set_base(i)
        assert_almost_equal(P(d), i)
コード例 #22
0
ファイル: test_shannon.py プロジェクト: psychon7/dit
def test_H4():
    """ Test entropy in base 10 """
    d = SD([1 / 10] * 10)
    d.set_base(10)
    assert H(d) == pytest.approx(1.0)
コード例 #23
0
ファイル: test_shannon.py プロジェクト: chebee7i/dit
def test_H4():
    """ Test entropy in base 10 """
    d = SD([1/10]*10)
    d.set_base(10)
    assert_almost_equal(H(d), 1.0)