Did I find the right examples for you? yes no

All Samples(2)  |  Call(1)  |  Derive(0)  |  Import(1)
Create a continuous random variable with an Erlang distribution.

The density of the Erlang distribution is given by

.. math::
    f(x) := \frac{\lambda^k x^{k-1} e^{-\lambda x}}{(k-1)!}

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

Parameters(more...)

        def Erlang(name, k, l):
    r"""
    Create a continuous random variable with an Erlang distribution.

    The density of the Erlang distribution is given by

    .. math::
        f(x) := \frac{\lambda^k x^{k-1} e^{-\lambda x}}{(k-1)!}

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

    Parameters
    ==========

    k : Integer
    l : Real number, `\lambda > 0`, the rate

    Returns
    =======

    A RandomSymbol.

    Examples
    ========

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

    >>> k = Symbol("k", integer=True, positive=True)
    >>> l = Symbol("l", positive=True)
    >>> z = Symbol("z")

    >>> X = Erlang("x", k, l)

    >>> D = density(X)(z)
    >>> pprint(D, use_unicode=False)
     k  k - 1  -l*z
    l *z     *e
    ---------------
        gamma(k)

    >>> C = cdf(X, meijerg=True)(z)
    >>> pprint(C, use_unicode=False)
    /  k*lowergamma(k, 0)   k*lowergamma(k, l*z)
    |- ------------------ + --------------------  for z >= 0
    <     gamma(k + 1)          gamma(k + 1)
    |
    \                     0                       otherwise

    >>> simplify(E(X))
    k/l

    >>> simplify(variance(X))
    k/l**2

    References
    ==========

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

    return rv(name, GammaDistribution, (k, 1/l))
        


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_erlang():
    k = Symbol("k", integer=True, positive=True)
    l = Symbol("l", positive=True)
 
    X = Erlang("x", k, l)