Thursday, October 16, 2025
HomeLanguagessympy.stats.Uniform() in Python

sympy.stats.Uniform() in Python

With the help of sympy.stats.Uniform() method, we can get the continuous random variable which represents the Uniform distribution.

Syntax : sympy.stats.Uniform(name, left, right)
Where, left and right are real number, -oo < left, left < right < +oo

Return : Return the continuous random variable.

Example #1 :
In this example we can see that by using sympy.stats.Uniform() method, we are able to get the continuous random variable representing Uniform distribution by using this method.




# Import sympy and Uniform
from sympy.stats import Uniform, density
from sympy import Symbol, pprint
  
z = Symbol("z")
a = Symbol("a", positive = True)
b = Symbol("b", positive = True)
  
# Using sympy.stats.Uniform() method
X = Uniform("x", a, b)
gfg = density(X)(z)
  
pprint(gfg)


Output :

/ 1
|—— for And(b >= z, a <= z)
<-a + b
|
\ 0 otherwise

Example #2 :




# Import sympy and Uniform
from sympy.stats import Uniform, density
from sympy import Symbol, pprint
  
z = 0.3
a = -3
b = 4
  
# Using sympy.stats.Uniform() method
X = Uniform("x", a, b)
gfg = density(X)(z)
  
pprint(gfg)


Output :

1/7

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

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS