Thursday, September 4, 2025
HomeLanguagessympy.stats.Geometric() in Python

sympy.stats.Geometric() in Python

With the help of sympy.stats.Geometric() method, we can get a random variable which denotes the geometric distribution.

Syntax : sympy.stats.Geometric(name, P)
Where, P stands for probability
Return : Return the random variable of geometric distribution.

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




# Import sympy and geometric
from sympy.stats import Geometric, density, E, variance
from sympy import Symbol, S
  
p = S.One / 5
  
# Using sympy.stats.Geometric() method
X = Geometric("x", p)
gfg = density(X)(z)
  
print(variance(X))


Output :

20

Example #2 :




# Import sympy and geometric
from sympy.stats import Geometric, density, E, variance
from sympy import Symbol, S
  
# Using sympy.stats.Geometric() method
X = Geometric("x", 0.4)
gfg = density(X)(z)
  
print(variance(X))


Output :

3.75000000000000

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

Most Popular

Dominic
32262 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6626 POSTS0 COMMENTS
Nicole Veronica
11799 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11856 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6696 POSTS0 COMMENTS
Umr Jansen
6716 POSTS0 COMMENTS