sympy.stats.NegativeBinomial() in Python
Last Updated :
08 Jun, 2020
With the help of sympy.stats.NegativeBinomial()
method, we can get the random variable representing the negative binomial distribution.
Syntax : sympy.stats.NegativeBinomial(name, r, p)
Return : Return the random variable.
Example #1 :
In this example we can see that by using sympy.stats.NegativeBinomial()
method, we are able to get the negative binomial distribution by using this method.
from sympy.stats import NegativeBinomial, density, E, variance
from sympy import Symbol, S
r = 5
p = S.One / 5
X = NegativeBinomial( "x" , r, p)
gfg = density(X)( 0.5 )
print (gfg)
|
Output :
0.360633043411166
Example #2 :
from sympy.stats import NegativeBinomial, density, E, variance
from sympy import Symbol, S
r = 4
p = 0.6
z = Symbol( "z" )
X = NegativeBinomial( "x" , r, p)
gfg = density(X)(z)
print (gfg)
|
Output :
0.0256*0.6**z*binomial(z + 3, z)
Share your thoughts in the comments
Please Login to comment...