def test_cgcre_2(crvs):
    """
    Test that independent RVs have CGCRE = GCRE.
    """
    d = miwin()
    rv = (set([0, 1, 2]) - set(crvs)).pop()
    ccre1 = CGCRE(d, rv, crvs)
    ccre2 = CGCRE(d, rv)
    assert GCRE(d)[rv] == pytest.approx(mean(ccre1))
    assert GCRE(d)[rv] == pytest.approx(mean(ccre2))
    assert standard_deviation(ccre1) == pytest.approx(0)
Esempio n. 2
0
def test_cgcre_2():
    """
    Test that independent RVs have CGCRE = GCRE.
    """
    d = miwin()
    for crvs in combinations([0, 1, 2], 2):
        rv = (set([0, 1, 2]) - set(crvs)).pop()
        ccre1 = CGCRE(d, rv, crvs)
        ccre2 = CGCRE(d, rv)
        yield assert_almost_equal, GCRE(d)[rv], mean(ccre1)
        yield assert_almost_equal, GCRE(d)[rv], mean(ccre2)
        yield assert_almost_equal, standard_deviation(ccre1), 0
Esempio n. 3
0
def test_gcre_4():
    """
    Test that equal-length uniform distributions all have the same GCRE.
    """
    gcres = [GCRE(uniform(i, i + 5)) for i in range(-5, 1)]
    for gcre in gcres:
        yield assert_almost_equal, gcre, gcres[0]
def test_gcre_3():
    """
    Test that the GCRE fails on non-numeric events.
    """
    dist = Xor()
    with pytest.raises(TypeError):
        GCRE(dist)
Esempio n. 5
0
def test_cgcre_1():
    """
    Test the CGCRE against known values.
    """
    d = conditional_uniform2()
    cgcre = CGCRE(d, 1, [0])
    uniforms = [GCRE(uniform(i)) for i in range(1, 6)]
    assert_array_almost_equal(cgcre.outcomes, uniforms)
Esempio n. 6
0
def test_gcre_1():
    """
    Test the GCRE against known values for the uniform distribution.
    """
    dists = [uniform(-n // 2, n // 2) for n in range(2, 23, 2)]
    results = [
        0.5, 1.31127812, 2.06831826, 2.80927657, 3.54316518, 4.27328199,
        5.00113503, 5.72751654, 6.45288453, 7.17752308, 7.90161817
    ]
    for d, r in zip(dists, results):
        yield assert_almost_equal, r, GCRE(d)
Esempio n. 7
0
def test_gcre_32():
    """
    Test the GCRE of a multivariate distribution.
    """
    d = miwin()
    assert_array_almost_equal(GCRE(d), [3.34415526, 3.27909534, 2.56831826])
def test_gcre_32():
    """
    Test the GCRE of a multivariate distribution.
    """
    d = miwin()
    assert np.allclose(GCRE(d), [3.34415526, 3.27909534, 2.56831826])
def test_gcre_1(n, val):
    """
    Test the GCRE against known values for the uniform distribution.
    """
    dist = uniform(-n // 2, n // 2)
    assert GCRE(dist) == pytest.approx(val)
def test_gcre_4(i):
    """
    Test that equal-length uniform distributions all have the same GCRE.
    """
    gcre = GCRE(uniform(i, i + 5))
    assert gcre == pytest.approx(GCRE(uniform(-5, 0)))