Exemplo n.º 1
0
def test_uniform():
    U = Uniform(-3, -1)
    assert U.mean == -2
    assert U.confidence(1) == (-3, -1)
    assert U.confidence(Rational(1,2)) == (Rational(-5,2), Rational(-3,2))
    assert U.pdf(-4) == 0
    assert U.pdf(-Rational(3,2)) == Rational(1,2)
    assert U.pdf(0) == 0
    assert U.cdf(-4) == 0
    assert U.cdf(-Rational(3,2)) == Rational(3,4)
    assert U.cdf(0) == 1
Exemplo n.º 2
0
def test_uniform():
    U = Uniform(-3, -1)
    assert U.mean == -2
    assert U.confidence(1) == (-3, -1)
    assert U.confidence(Rational(1, 2)) == (Rational(-5, 2), Rational(-3, 2))
    assert U.pdf(-4) == 0
    assert U.pdf(-Rational(3, 2)) == Rational(1, 2)
    assert U.pdf(0) == 0
    assert U.cdf(-4) == 0
    assert U.cdf(-Rational(3, 2)) == Rational(3, 4)
    assert U.cdf(0) == 1
Exemplo n.º 3
0
def test_uniform():
    U = Uniform(-3, -1)
    assert str(U) == "Uniform(-3, -1)"
    assert repr(U) == "Uniform(-3, -1)"
    x = U.random()
    assert x < -1 and x > -3
    assert U.mean == -2
    assert U.confidence(1) == (-3, -1)
    assert U.confidence(Rational(1,2)) == (Rational(-5,2), Rational(-3,2))
    assert U.pdf(-4) == 0
    assert U.pdf(-Rational(3,2)) == Rational(1,2)
    assert U.pdf(0) == 0
    assert U.cdf(-4) == 0
    assert U.cdf(-Rational(3,2)) == Rational(3,4)
    assert U.cdf(0) == 1