sympy.stats.FiniteRV() function in Python
Last Updated :
01 Jun, 2020
With the help of sympy.stats.FiniteRV()
method, we can create a random variable gives a dictionary of density by using sympy.stats.FiniteRV()
method.
Syntax : sympy.stats.FiniteRV(name, dict)
Return : Return the variable having dictionary of density.
Example #1 :
In this example, we can see that by using sympy.stats.FiniteRV()
method, we are able to create the random variable which denotes the dictionary of densities by using this method.
from sympy.stats import FiniteRV, P, E
density = { 0 : . 1 , 1 : . 2 , 2 : . 3 , 3 : . 4 }
X = FiniteRV( 'X' , density)
print (E(X))
gfg = P(X > 2 )
print (gfg)
|
Output :
2.00000000000000
0.40000000000000
Example #2 :
from sympy.stats import FiniteRV, P, E
density = { 0 : . 11 , 1 : . 20 , 2 : . 13 , 3 : . 4 , 4 : 0.16 }
X = FiniteRV( 'X' , density)
print (E(X))
gfg = P(X > = 3 )
print (gfg)
|
Output :
2.30000000000000
0.56000000000000
Share your thoughts in the comments
Please Login to comment...