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

    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)
예제 #2
0
def test_lladser_ci():
    """lladser_ci estimate using defaults contains p with 95% prob"""

    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)
예제 #3
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)
예제 #4
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)
예제 #5
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 th
    # 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 the threshold much lower and do more reps. For 0.93 and 1000 reps,
    # the binomial distribution tells us that the test will pass more
    # often than 99%.
    reps = 1000
    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.93)
예제 #6
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 th
    # 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 the threshold much lower and do more reps. For 0.93 and 1000 reps,
    # the binomial distribution tells us that the test will pass more
    # often than 99%.
    reps = 1000
    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.93)
예제 #7
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]))
예제 #8
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]))