def test_ccre_1(crvs):
    """
    Test that independent RVs have CCRE = CRE.
    """
    d = miwin()
    rv = (set([0, 1, 2]) - set(crvs)).pop()
    ccre1 = CCRE(d, rv, crvs)
    ccre2 = CCRE(d, rv)
    assert CRE(d)[rv] == pytest.approx(mean(ccre1))
    assert CRE(d)[rv] == pytest.approx(mean(ccre2))
    assert standard_deviation(ccre1) == pytest.approx(0)
Beispiel #2
0
def test_ccre_1():
    """
    Test that independent RVs have CCRE = CRE.
    """
    d = miwin()
    for crvs in combinations([0, 1, 2], 2):
        rv = (set([0, 1, 2]) - set(crvs)).pop()
        ccre1 = CCRE(d, rv, crvs)
        ccre2 = CCRE(d, rv)
        yield assert_almost_equal, CRE(d)[rv], mean(ccre1)
        yield assert_almost_equal, CRE(d)[rv], mean(ccre2)
        yield assert_almost_equal, standard_deviation(ccre1), 0
def test_cre_3():
    """
    Test that the CRE fails when the events are not numbers.
    """
    dist = Xor()
    with pytest.raises(TypeError):
        CRE(dist)
Beispiel #4
0
def test_ccre_3():
    """
    Test a correlated distribution.
    """
    d = conditional_uniform2()
    ccre = CCRE(d, 1, [0])
    uniforms = sorted([CRE(uniform(i - 2, 3)) for i in range(5)])
    assert_array_almost_equal(ccre.outcomes, uniforms)
Beispiel #5
0
def test_ccre_2():
    """
    Test a correlated distribution.
    """
    d = conditional_uniform1()
    ccre = CCRE(d, 1, [0])
    uniforms = [CRE(uniform(i)) for i in range(1, 6)]
    assert_array_almost_equal(ccre.outcomes, uniforms)
Beispiel #6
0
def test_ccre_3():
    """
    Test a correlated distribution.
    """
    d = conditional_uniform2()
    ccre = CCRE(d, 1, [0])
    uniforms = sorted(CRE(uniform(i - 2, 3)) for i in range(5))
    assert np.allclose(ccre.outcomes, uniforms)
Beispiel #7
0
def test_cre_1():
    """
    Test the CRE against known values for several uniform distributions.
    """
    dists = [uniform(-n // 2, n // 2) for n in range(2, 23, 2)]
    results = [
        0.5, 0.81127812, 1.15002242, 1.49799845, 1.85028649, 2.20496373,
        2.56111354, 2.91823997, 3.27604979, 3.6343579, 3.99304129
    ]
    for d, r in zip(dists, results):
        yield assert_almost_equal, r, CRE(d)
Beispiel #8
0
def test_cre_2():
    """
    Test the CRE of a multivariate distribution (CRE is of each marginal).
    """
    d = miwin()
    assert_array_almost_equal(CRE(d), [3.34415526, 3.27909534, 2.56831826])
def test_cre_2():
    """
    Test the CRE of a multivariate distribution (CRE is of each marginal).
    """
    d = miwin()
    assert np.allclose(CRE(d), [3.34415526, 3.27909534, 2.56831826])
def test_cre_1(n, val):
    """
    Test the CRE against known values for several uniform distributions.
    """
    dist = uniform(-n // 2, n // 2)
    assert CRE(dist) == pytest.approx(val)