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 drawsReturn : 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}