Sympy – stats.DiscreteUniform() in Python
Last Updated :
08 Jun, 2020
With the help of sympy.stats.DiscreteUniform()
method, we can get the random variable who is representing the discrete uniform values for input by using sympy.stats.DiscreteUniform()
method.
Syntax : sympy.stats.DiscreteUniform(list/tuple)
Return : Return the discrete uniform value.
Example #1 :
In this example we can see that by using sympy.stats.DiscreteUniform()
method, we are able to get the random variable representing the discrete uniform value by using this method.
from sympy.stats import DiscreteUniform, density
from sympy import symbols
X = DiscreteUniform( 'X' , symbols( 'g f g' ))
gfg = density(X). dict
print (gfg)
|
Output :
{g: 1/3, f: 1/3}
Example #2 :
from sympy.stats import DiscreteUniform, density
from sympy import symbols
Y = DiscreteUniform( 'Y' , list ( range ( 5 )))
gfg = density(Y). dict
print (gfg)
|
Output :
{0: 1/5, 1: 1/5, 2: 1/5, 3: 1/5, 4: 1/5}
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...