sympy.stats.Hypergeometric() function in Python
Last Updated :
01 Jun, 2020
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.
from sympy.stats import Hypergeometric, density
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 :
from sympy.stats import Hypergeometric, density
X = Hypergeometric( 'X' , 2 , 1 , 1 )
gfg = density(X). dict
print (gfg)
|
Output :
{0: 1/2, 1: 1/2}
Share your thoughts in the comments
Please Login to comment...