Exemple #1
0
def test_lladser_ci():
    """lladser_ci estimate using defaults contains p with 95% prob"""

    np.random.seed(12345678)
    reps = 100
    sum = 0
    for i in range(reps):
        fake_obs, exp_p = create_fake_observation()
        (low, high) = lladser_ci(fake_obs, r=10)
        if (low <= exp_p <= high):
            sum += 1

    assert_true(sum/reps >= 0.95)
Exemple #2
0
def test_lladser_ci_f3():
    """lladser_ci estimate using f=3 contains p with 95% prob"""

    # Test different values of f=3 and r=14, which lie exactly on the
    # 95% interval line. For 100 reps using simple cumulative binomial
    # probs we expect to have more than 5 misses of the interval in 38%
    # of all test runs. To make this test pass reliable we thus have to
    # set a defined seed
    np.random.seed(12345678)
    reps = 100
    sum = 0
    for i in range(reps):
        # re-create the obs for every estimate, such that they are truly
        # independent events
        fake_obs, exp_p = create_fake_observation()
        (low, high) = lladser_ci(fake_obs, r=14, f=3)
        if (low <= exp_p <= high):
            sum += 1

    assert_true(sum/reps >= 0.95)
Exemple #3
0
def test_lladser_ci_nan():
    """lladser_ci returns nan if sample is too short to make an estimate"""

    obs = lladser_ci([3], r=4)
    assert_true(len(obs) == 2 and np.isnan(obs[0]) and np.isnan(obs[1]))