Did I find the right examples for you? yes no

All Samples(4)  |  Call(3)  |  Derive(0)  |  Import(1)
Create a Finite Random Variable representing a binomial distribution.

Returns a RandomSymbol.

Examples
========

>>> from sympy.stats import Binomial, density
>>> from sympy import S
(more...)

        def Binomial(name, n, p, succ=1, fail=0):
    """
    Create a Finite Random Variable representing a binomial distribution.

    Returns a RandomSymbol.

    Examples
    ========

    >>> from sympy.stats import Binomial, density
    >>> from sympy import S

    >>> X = Binomial('X', 4, S.Half) # Four "coin flips"
    >>> density(X).dict
    {0: 1/16, 1: 1/4, 2: 3/8, 3: 1/4, 4: 1/16}
    """

    return rv(name, BinomialDistribution, n, p, succ, fail)
        


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,
    for n in nvals:
        for p in pvals:
            X = Binomial('X', n, p)
            assert Eq(E(X), n*p)
            assert Eq(variance(X), n*p*(1 - p))
            if n > 0 and 0 < p < 1:
                assert Eq(skewness(X), (1 - 2*p)/sqrt(n*p*(1 - p)))