Did I find the right examples for you? yes no

All Samples(33)  |  Call(25)  |  Derive(0)  |  Import(8)
Create a Finite Random Variable representing a fair die.

Returns a RandomSymbol.

>>> from sympy.stats import Die, density

>>> D6 = Die('D6', 6) # Six sided Die
>>> density(D6).dict
{1: 1/6, 2: 1/6, 3: 1/6, 4: 1/6, 5: 1/6, 6: 1/6}
(more...)

        def Die(name, sides=6):
    """
    Create a Finite Random Variable representing a fair die.

    Returns a RandomSymbol.

    >>> from sympy.stats import Die, density

    >>> D6 = Die('D6', 6) # Six sided Die
    >>> density(D6).dict
    {1: 1/6, 2: 1/6, 3: 1/6, 4: 1/6, 5: 1/6, 6: 1/6}

    >>> D4 = Die('D4', 4) # Four sided Die
    >>> density(D4).dict
    {1: 1/4, 2: 1/4, 3: 1/4, 4: 1/4}
    """

    return rv(name, DieDistribution, sides)
        


src/s/y/sympy-HEAD/sympy/stats/tests/test_finite_rv.py   sympy(Download)
from sympy import (EmptySet, FiniteSet, S, Symbol, Interval, exp, erf, sqrt,
        symbols, simplify, Eq, cos, And, Tuple, Or, Dict, sympify, binomial,
        factor)
from sympy.stats import (DiscreteUniform, Die, Bernoulli, Coin, Binomial,
        Hypergeometric, P, E, variance, covariance, skewness, sample, density,
def test_dice():
    # TODO: Make iid method!
    X, Y, Z = Die('X', 6), Die('Y', 6), Die('Z', 6)
    a, b = symbols('a b')
 
def test_given():
    X = Die('X', 6)
    assert density(X, X > 5) == {S(6): S(1)}
    assert where(X > 2, X > 5).as_boolean() == Eq(X.symbol, 6)
    assert sample(X, X > 5) == 6

src/s/y/sympy-HEAD/sympy/stats/tests/test_rv.py   sympy(Download)
from sympy import (EmptySet, FiniteSet, S, Symbol, Interval, exp, erf, sqrt,
        symbols, simplify, Eq, cos, And, Tuple, integrate, oo, sin, Sum, Basic,
        DiracDelta)
from sympy.stats import (Die, Normal, Exponential, P, E, variance, covariance,
        skewness, density, given, independent, dependent, where, pspace,
def test_where():
    X, Y = Die('X'), Die('Y')
    Z = Normal('Z', 0, 1)
 
    assert where(Z**2 <= 1).set == Interval(-1, 1)
def test_Sample():
    X = Die('X', 6)
    Y = Normal('Y', 0, 1)
    z = Symbol('z')
 
    assert sample(X) in [1, 2, 3, 4, 5, 6]

src/s/y/sympy-HEAD/sympy/printing/pretty/tests/test_pretty.py   sympy(Download)
def test_RandomDomain():
    from sympy.stats import Normal, Die, Exponential, pspace, where
    X = Normal('x1', 0, 1)
    assert upretty(where(X > 0)) == u("Domain: x₁ > 0")
 
    D = Die('d1', 6)
    assert upretty(where(D > 4)) == u('Domain: d₁ = 5 ∨ d₁ = 6')

src/s/y/sympy-HEAD/sympy/printing/tests/test_str.py   sympy(Download)
def test_RandomDomain():
    from sympy.stats import Normal, Die, Exponential, pspace, where
    X = Normal('x1', 0, 1)
    assert str(where(X > 0)) == "Domain: x1 > 0"
 
    D = Die('d1', 6)
    assert str(where(D > 4)) == "Domain: Or(d1 == 5, d1 == 6)"

src/s/y/sympy-HEAD/sympy/printing/tests/test_latex.py   sympy(Download)
def test_latex_RandomDomain():
    from sympy.stats import Normal, Die, Exponential, pspace, where
    X = Normal('x1', 0, 1)
    assert latex(where(X > 0)) == "Domain: x_{1} > 0"
 
    D = Die('d1', 6)
    assert latex(where(D > 4)) == r"Domain: d_{1} = 5 \vee d_{1} = 6"

src/s/y/sympy-0.7.5/sympy/printing/pretty/tests/test_pretty.py   sympy(Download)
def test_RandomDomain():
    from sympy.stats import Normal, Die, Exponential, pspace, where
    X = Normal('x1', 0, 1)
    assert upretty(where(X > 0)) == u("Domain: x₁ > 0")
 
    D = Die('d1', 6)
    assert upretty(where(D > 4)) == u('Domain: d₁ = 5 ∨ d₁ = 6')

src/s/y/sympy-0.7.5/sympy/printing/tests/test_str.py   sympy(Download)
def test_RandomDomain():
    from sympy.stats import Normal, Die, Exponential, pspace, where
    X = Normal('x1', 0, 1)
    assert str(where(X > 0)) == "Domain: x1 > 0"
 
    D = Die('d1', 6)
    assert str(where(D > 4)) == "Domain: Or(d1 == 5, d1 == 6)"

src/s/y/sympy-0.7.5/sympy/printing/tests/test_latex.py   sympy(Download)
def test_latex_RandomDomain():
    from sympy.stats import Normal, Die, Exponential, pspace, where
    X = Normal('x1', 0, 1)
    assert latex(where(X > 0)) == "Domain: x_{1} > 0"
 
    D = Die('d1', 6)
    assert latex(where(D > 4)) == r"Domain: d_{1} = 5 \vee d_{1} = 6"