sympy.stats.Cauchy() in Python
With the help of sympy.stats.Cauchy()
method, we can get the continuous random variable which represents the cauchy distribution.
Syntax :
sympy.stats.Cauchy(name, x, gamma)
Where, x and gamma is a real number and gamma is greater 0.
Return : Return the continuous random variable.
Example #1 :
In this example we can see that by using sympy.stats.Cauchy()
method, we are able to get the continuous random variable representing the cauchy distribution by using this method.
# Import sympy and cauchy from sympy.stats import Cauchy, density from sympy import Symbol x0 = Symbol( "x0" ) gamma = Symbol( "gamma" , positive = True ) z = Symbol( "z" ) # Using sympy.stats.Cauchy() method X = Cauchy( "x" , x0, gamma) gfg = density(X)(z) print (gfg) |
Output :
1/(pi*gamma*(1 + (-x0 + z)**2/gamma**2))
Example #2 :
# Import sympy and cauchy from sympy.stats import Cauchy, density from sympy import Symbol x0 = 2 gamma = 3 z = 0.5 # Using sympy.stats.Cauchy() method X = Cauchy( "x" , x0, gamma) gfg = density(X)(z) print (gfg) |
Output :
0.266666666666667/pi
Contact Us