def nbinom(self,samples):
"""
Sampling from a Negative binomial distribution
Parameters:
mu= poissonon mean
r controls the deviation from the poisson
This makes the negative binomial distribution suitable as a robust
alternative to the Poisson, which approaches the Poisson for large r,
but which has larger variance than the Poisson for small r.
------------------------------------------------------------------------
- samples: number of values that will be returned.
"""
mu=float(self.__params[0])
r=float(self.__params[1])
p=(r*1.0)/(r+mu)
distro=nbinom(r,p)
f=distro.rvs(size=samples)
return f
评论列表
文章目录