HomeLanguagesSympy – stats.DiscreteUniform() in Python

Sympy – stats.DiscreteUniform() in Python

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.




# Import sympy and DiscreteUniform
from sympy.stats import DiscreteUniform, density
from sympy import symbols
  
# Using stats.DiscreteUniform() method
X = DiscreteUniform('X', symbols('g f g'))
gfg = density(X).dict
  
print(gfg)


Output :

{g: 1/3, f: 1/3}

Example #2 :




# Import sympy and DiscreteUniform
from sympy.stats import DiscreteUniform, density
from sympy import symbols
  
# Using stats.DiscreteUniform() method
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}

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

Most Popular

Dominic
32548 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6922 POSTS0 COMMENTS
Nicole Veronica
12039 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12144 POSTS0 COMMENTS
Shaida Kate Naidoo
7059 POSTS0 COMMENTS
Ted Musemwa
7300 POSTS0 COMMENTS
Thapelo Manthata
7016 POSTS0 COMMENTS
Umr Jansen
7005 POSTS0 COMMENTS