Friday, October 10, 2025
HomeLanguagessympy.stats.Chi() in Python

sympy.stats.Chi() in Python

With the help of sympy.stats.Chi() method, we can get the continuous random variable which represents the chi distribution.

Syntax : sympy.stats.Chi(name, k)
Where, k is number of degree of freedom.
Return : Return the continuous random variable.

Example #1 :
In this example we can see that by using sympy.stats.Chi() method, we are able to get the continuous random variable representing the chi distribution by using this method.




# Import sympy and chi
from sympy.stats import Chi, density, E
from sympy import Symbol, simplify
  
k = Symbol("k", integer = True)
z = Symbol("z")
  
# Using sympy.stats.Chi() method
X = Chi("x", k)
gfg = density(X)(z)
  
print(gfg)


Output :

2**(1 – k/2)*z**(k – 1)*exp(-z**2/2)/gamma(k/2)

Example #2 :




# Import sympy and chi
from sympy.stats import Chi, density, E
from sympy import Symbol, simplify
  
k = 3
z = 2
  
# Using sympy.stats.Chi() method
X = Chi("x", k)
gfg = density(X)(z)
  
print(gfg)


Output :

4*sqrt(2)*exp(-2)/sqrt(pi)

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32349 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6715 POSTS0 COMMENTS
Nicole Veronica
11878 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6837 POSTS0 COMMENTS
Ted Musemwa
7097 POSTS0 COMMENTS
Thapelo Manthata
6792 POSTS0 COMMENTS
Umr Jansen
6791 POSTS0 COMMENTS