Exemplo n.º 1
0
def test_lladser_point_estimates():
    s = [5, 1, 5, 1, 2, 3, 1, 5, 3, 2, 5, 3]
    r = 3
    observed = list(_lladser_point_estimates(s, r))
    assert_equal(len(observed), 3)

    for k in range(3):
        x = observed[k]
        t = x[2]
        assert_equal(x[0], (r - 1) / t)

    # Estimator has variance of (1-p)^2/(r-2),
    # which for r=7 and p=0.5 is 0.05
    seq = "WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW"
    reps = 1000
    sum = 0
    for i in range(reps):
        p, _, _ = list(_lladser_point_estimates(seq, r=7))[0]
        sum += p
    assert_true(0.45 < sum / reps and sum / reps < 0.55)
Exemplo n.º 2
0
def test_lladser_point_estimates():
    s = [5, 1, 5, 1, 2, 3, 1, 5, 3, 2, 5, 3]
    r = 3
    observed = list(_lladser_point_estimates(s, r))
    assert_equal(len(observed), 3)

    for k in range(3):
        x = observed[k]
        t = x[2]
        assert_equal(x[0], (r - 1) / t)

    # Estimator has variance of (1-p)^2/(r-2),
    # which for r=7 and p=0.5 is 0.05
    seq = "WBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBWBW"
    reps = 1000
    sum = 0
    for i in range(reps):
        p, _, _ = list(_lladser_point_estimates(seq, r=7))[0]
        sum += p
    assert_true(0.45 < sum / reps and sum / reps < 0.55)
Exemplo n.º 3
0
def test_lladser_point_estimates_invalid_r():
    with assert_raises(ValueError):
        list(_lladser_point_estimates([5, 1, 5, 1, 2, 3, 1, 5, 3, 2, 5, 3], 2))
Exemplo n.º 4
0
def test_lladser_point_estimates_invalid_r():
    with assert_raises(ValueError):
        list(_lladser_point_estimates([5, 1, 5, 1, 2, 3, 1, 5, 3, 2, 5, 3], 2))