Beispiel #1
0
def test_p5():
    """ Test some joint, marginal, and conditional perplexities """
    d = D(['00', '01', '10', '11'], [1 / 4] * 4)
    assert_almost_equal(P(d), 4)
    assert_almost_equal(P(d, [0]), 2)
    assert_almost_equal(P(d, [1]), 2)
    assert_almost_equal(P(d, [0], [1]), 2)
    assert_almost_equal(P(d, [1], [0]), 2)
Beispiel #2
0
def test_p5():
    """ Test some joint, marginal, and conditional perplexities """
    d = D(['00', '01', '10', '11'], [1 / 4] * 4)
    assert P(d) == pytest.approx(4)
    assert P(d, [0]) == pytest.approx(2)
    assert P(d, [1]) == pytest.approx(2)
    assert P(d, [0], [1]) == pytest.approx(2)
    assert P(d, [1], [0]) == pytest.approx(2)
Beispiel #3
0
def test_p6():
    """ Test some joint and conditional perplexities """
    d = D(['00', '11'], [1 / 2] * 2)
    assert P(d) == pytest.approx(2)
    assert P(d, [0], [1]) == pytest.approx(1)
    assert P(d, [1], [0]) == pytest.approx(1)
Beispiel #4
0
def test_p4(i):
    """ Test some simple base cases using D with varying bases """
    d = D([str(_) for _ in range(i)], [1 / i] * i)
    d.set_base(i)
    assert P(d) == pytest.approx(i)
Beispiel #5
0
def test_p3(i):
    """ Test some simple base cases using D """
    d = D([str(_) for _ in range(i)], [1 / i] * i)
    assert P(d) == pytest.approx(i)
Beispiel #6
0
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)
Beispiel #7
0
def test_p1(i):
    """ Test some simple base cases using SD """
    assert P(SD([1 / i] * i)) == pytest.approx(i)
Beispiel #8
0
def test_p6():
    """ Test some joint and conditional perplexities """
    d = D(['00', '11'], [1 / 2] * 2)
    assert_almost_equal(P(d), 2)
    assert_almost_equal(P(d, [0], [1]), 1)
    assert_almost_equal(P(d, [1], [0]), 1)
Beispiel #9
0
def test_p4():
    """ Test some simple base cases using D with varying bases """
    for i in range(2, 10):
        d = D([str(_) for _ in range(i)], [1 / i] * i)
        d.set_base(i)
        yield assert_almost_equal, P(d), i
Beispiel #10
0
def test_p3():
    """ Test some simple base cases using D """
    for i in range(2, 10):
        d = D([str(_) for _ in range(i)], [1 / i] * i)
        yield assert_almost_equal, P(d), i
Beispiel #11
0
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
Beispiel #12
0
def test_p1():
    """ Test some simple base cases using SD """
    for i in range(2, 10):
        yield assert_almost_equal, P(SD([1 / i] * i)), i