sympy.stats.ChiSquared() in python

• Last Updated : 05 Jun, 2020

With the help of sympy.stats.ChiSquared() method, we can get the continuous random variable representing the chi-squared distribution. Syntax : sympy.stats.ChiSquared(name, k)
Return : Return the continuous random variable.

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

 # Import sympy and chisquaredfrom sympy.stats import ChiSquared, densityfrom sympy import Symbol  k = Symbol("k", integer = True, positive = True)z = Symbol("z")  # Using sympy.stats.ChiSquared() methodX = ChiSquared("x", k)gfg = density(X)(z)  pprint(gfg)

Output :

-k k -z
— – – 1 —
2 2 2
2 *z *e
—————-
/k\
Gamma|-|
\2/

Example #2 :

 # Import sympy and chisquaredfrom sympy.stats import ChiSquared, densityfrom sympy import Symbol  k = 3z = 2  # Using sympy.stats.ChiSquared() methodX = ChiSquared("x", k)gfg = density(X)(z)  pprint(gfg)

Output :

-1
e
——
____
\/ pi

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning - Basic Level Course

My Personal Notes arrow_drop_up