예제 #1
0
def test_weibull_numeric():
    # Test for integers and rationals
    a = 1
    bvals = [Rational(1, 2), 1, Rational(3, 2), Integer(5)]
    for b in bvals:
        X = Weibull('x', a, b)
        assert simplify(E(X)) == simplify(a * gamma(1 + 1/b))
        assert simplify(variance(X)) == simplify(
            a**2 * gamma(1 + 2/b) - E(X)**2)
예제 #2
0
def test_prefab_sampling():
    N = Normal('X', 0, 1)
    L = LogNormal('L', 0, 1)
    E = Exponential('Ex', 1)
    P = Pareto('P', 1, 3)
    W = Weibull('W', 1, 1)
    U = Uniform('U', 0, 1)
    B = Beta('B', 2, 5)
    G = Gamma('G', 1, 3)

    variables = [N, L, E, P, W, U, B, G]
    niter = 10
    for var in variables:
        for i in range(niter):
            assert sample(var) in var.pspace.domain.set
예제 #3
0
def test_weibull():
    a, b = symbols('a b', positive=True, real=True)
    X = Weibull('x', a, b)

    assert simplify(E(X)) == simplify(a * gamma(1 + 1/b))
    assert simplify(variance(X)) == simplify(a**2 * gamma(1 + 2/b) - E(X)**2)