3

I'm trying to generate random numbers from a given scipy stats random distribution, in my case a negative binomial distribution.

The documentation isn't entirely clear to me. Unfortunately, the documentation is a bit sparse: https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.nbinom.html

This should be really simple.

Cornelius Roemer
  • 3,772
  • 1
  • 24
  • 55

1 Answers1

2

The relevant method is rvs which stands for random variates.

You can generate a single random number drawn from a negative binomial distribution like this:

import scipy.stats
scipy.stats.nbinom.rvs(1,0.5) # returns 2 (or other random integer between 0 and +inf)
Cornelius Roemer
  • 3,772
  • 1
  • 24
  • 55