Friday, June 12, 2026
HomeLanguagessympy.stats.Gamma() function in Python

sympy.stats.Gamma() function in Python

With the help of sympy.stats.Gamma() method, we can create a continuous random variable with a Gamma distribution. The density of the Gamma distribution is given by

with x in [0, 1].

Syntax:  sympy.stats.Gamma(name, k, theta)

Parameters:
 k: real number, k>0
 theta:  real number, theta>0

Returns: a continuous random variable with a Gamma distribution.

Example #1 :

Python3




# import sympy, Gamma, density, Symbol, pprint
from sympy.stats import Gamma, density
from sympy import Symbol, pprint
  
k = Symbol("k", positive = True)
theta = Symbol("theta", positive = True)
z = Symbol("z")
  
# using sympy.stats.Gamma() method
X = Gamma("x", k, theta)
gamVar = density((X)(z))
  
pprint(gamVar)


Output:

                 -z  
                -----
     -k  k - 1  theta
theta  *z     *e     
---------------------
       Gamma(k)  

Example #2 :

Python3




# import sympy, Gamma, density, Symbol, pprint
from sympy.stats import Gamma, density
from sympy import Symbol, pprint
  
z = Symbol("z")
  
# using sympy.stats.Gamma() method
X = Gamma("x", 1 / 3, 45)
gamVar = density((X)(z))
  
pprint(gamVar)


Output:

           -z     
           ---    
   3 ____   45    
   \/ 75 *e       
------------------
    2/3           
15*z   *Gamma(1/3)
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32515 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6897 POSTS0 COMMENTS
Nicole Veronica
12013 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12109 POSTS0 COMMENTS
Shaida Kate Naidoo
7019 POSTS0 COMMENTS
Ted Musemwa
7262 POSTS0 COMMENTS
Thapelo Manthata
6976 POSTS0 COMMENTS
Umr Jansen
6963 POSTS0 COMMENTS