Thursday, October 9, 2025
HomeLanguagessympy.stats.Hypergeometric() function in Python

sympy.stats.Hypergeometric() function in Python

Hypergeometric distribution is a distribution of discrete probability that defines the probability of success in draws. With the help of sympy.stats.Hypergeometric() method, we can get the finite random variable who denotes the value of hypergeometric distribution by using sympy.stats.Hypergeometric() method.

Syntax : sympy.stats.Hypergeometric(name, N, m, n)

Parameters :
name – It use to denote the distribution.
N – Total population of size N.
m – number of trials
n – number of draws

Return : Return the hypergeometric distribution.

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




# Import sympy and hypergeometric
from sympy.stats import Hypergeometric, density
  
  
# Using sympy.stats.Hypergeometric() method
# Taking 10 marbles, 5 white(success), 3 draws
X = Hypergeometric('X', 10, 5, 3
gfg = density(X).dict
  
print(gfg)


Output :

{0: 1/12, 1: 5/12, 2: 5/12, 3: 1/12}

Example #2 :




# Import sympy and hypergeometric
from sympy.stats import Hypergeometric, density
  
  
# Using sympy.stats.Hypergeometric() method
X = Hypergeometric('X', 2, 1, 1)
gfg = density(X).dict
  
print(gfg)


Output :

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

Most Popular

Dominic
32344 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6714 POSTS0 COMMENTS
Nicole Veronica
11877 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11940 POSTS0 COMMENTS
Shaida Kate Naidoo
6834 POSTS0 COMMENTS
Ted Musemwa
7094 POSTS0 COMMENTS
Thapelo Manthata
6789 POSTS0 COMMENTS
Umr Jansen
6791 POSTS0 COMMENTS