Did I find the right examples for you? yes no

# sympy.stats.Gamma

All Samples(4)  |  Call(3)  |  Derive(0)  |  Import(1)
Create a continuous random variable with a Gamma distribution.

The density of the Gamma distribution is given by

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

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

Parameters(more...)


        def Gamma(name, k, theta):
r"""
Create a continuous random variable with a Gamma distribution.

The density of the Gamma distribution is given by

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

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

Parameters
==========

k : Real number, k > 0, a shape
theta : Real number, \theta > 0, a scale

Returns
=======

A RandomSymbol.

Examples
========

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

>>> k = Symbol("k", positive=True)
>>> theta = Symbol("theta", positive=True)
>>> z = Symbol("z")

>>> X = Gamma("x", k, theta)

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

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

>>> E(X)
theta*gamma(k + 1)/gamma(k)

>>> V = simplify(variance(X))
>>> pprint(V, use_unicode=False)
2
k*theta

References
==========

.. [1] http://en.wikipedia.org/wiki/Gamma_distribution
"""



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_gamma():
k = Symbol("k", positive=True)
theta = Symbol("theta", positive=True)

X = Gamma('x', k, theta)

            (0, True))
# assert simplify(variance(X)) == k*theta**2  # handled numerically below
assert E(X) == moment(X, 1)

k, theta = symbols('k theta', real=True, bounded=True, positive=True)
X = Gamma('x', k, theta)