Sampling from negative binomial


I would like to know how in metropolis hasting (MH) a sample from normal distribution is transformed into a discrete sample from negative binomial? as far as I am concerned the default proposal distribution is normal for MH but I could not find what transformation is used in case of sampling from negative binomial. I know for example that “Interval” transformation is used for uniform distribution. My guess is that maybe the proposal used for negative binomial should not be normal. Please let me know if I am wrong.

Please let me know where I can read more on this.

Also why in pymc3 scipy.stats.poisson is used to draw samples instead of using spicy.stats.nbinom?


Perhaps this might help?

Thanks but it does not answer my question.

If I am not mistaken in PyMC we round the proposal locations to the nearest integer for discrete variables. These are the relevant lines:

For your second question, the NegativeBinomial can be parametrized as mixture of Poisson distributions whose rate follows a gamma distribution: Negative binomial distribution - Wikipedia

I don’t know exactly if there is any advantage in using this parametrization to generate random samples, or if it was perhaps developed before scipy’s implementation…

Thanks Ricardo. I noticed this too but for positive discrete variables q is not guaranteed to be positive so I do not know what should be done. Should we change the proposal distribution from normal to something else, e.g. Poisson, or we should keep it normal and reject the negative updates?

For negative values the negative binomial will yield a probability of zero and therefore those jumps are never accepted. It is definitely possible to use different proposal distributions that only propose positive values, but then you have to use a different proposal for each parameter. Discrete parameters are generally challenging to sample.