Did I find the right examples for you? yes no

All Samples(6)  |  Call(4)  |  Derive(0)  |  Import(2)
Create a Continuous Random Variable with a Beta distribution.

The density of the Beta distribution is given by

.. math::
    f(x) := \frac{x^{\alpha-1}(1-x)^{\beta-1}} {\mathrm{B}(\alpha,\beta)}

with :math:`x \in [0,1]`.

Parameters(more...)

        def Beta(name, alpha, beta):
    r"""
    Create a Continuous Random Variable with a Beta distribution.

    The density of the Beta distribution is given by

    .. math::
        f(x) := \frac{x^{\alpha-1}(1-x)^{\beta-1}} {\mathrm{B}(\alpha,\beta)}

    with :math:`x \in [0,1]`.

    Parameters
    ==========

    alpha : Real number, `\alpha > 0`, a shape
    beta : Real number, `\beta > 0`, a shape

    Returns
    =======

    A RandomSymbol.

    Examples
    ========

    >>> from sympy.stats import Beta, density, E, variance
    >>> from sympy import Symbol, simplify, pprint

    >>> alpha = Symbol("alpha", positive=True)
    >>> beta = Symbol("beta", positive=True)
    >>> z = Symbol("z")

    >>> X = Beta("x", alpha, beta)

    >>> D = density(X)(z)
    >>> pprint(D, use_unicode=False)
     alpha - 1         beta - 1
    z         *(-z + 1)        *gamma(alpha + beta)
    -----------------------------------------------
                gamma(alpha)*gamma(beta)

    >>> simplify(E(X, meijerg=True))
    alpha/(alpha + beta)

    >>> simplify(variance(X, meijerg=True))  #doctest: +SKIP
    alpha*beta/((alpha + beta)**2*(alpha + beta + 1))

    References
    ==========

    .. [1] http://en.wikipedia.org/wiki/Beta_distribution
    .. [2] http://mathworld.wolfram.com/BetaDistribution.html
    """

    return rv(name, BetaDistribution, (alpha, beta))
        


src/s/y/sympy-HEAD/sympy/stats/tests/test_continuous_rv.py   sympy(Download)
from sympy.stats import (P, E, where, density, variance, covariance, skewness,
                         given, pspace, cdf, ContinuousRV, sample,
                         Arcsin, Benini, Beta, BetaPrime, Cauchy,
                         Chi, ChiSquared,
                         ChiNoncentral, Dagum, Erlang, Exponential,
def test_beta():
    a, b = symbols('alpha beta', positive=True)
 
    B = Beta('x', a, b)
 
    assert pspace(B).domain.set == Interval(0, 1)
 
    dens = density(B)
    # Full symbolic solution is too much, test with numeric version
    a, b = 1, 2
    B = Beta('x', a, b)
    assert E(B) == a / S(a + b)
    assert variance(B) == (a*b) / S((a + b)**2 * (a + b + 1))

src/s/y/sympy-HEAD/sympy/stats/tests/test_mix.py   sympy(Download)
from sympy.stats import Poisson, Beta
from sympy.stats.rv import pspace, ProductPSpace, density
from sympy.stats.drv_types import PoissonDistribution
from sympy import Symbol, Eq
 
def test_density():
    x = Symbol('x')
    l = Symbol('l', positive=True)
    rate = Beta(l, 2, 3)