panthrMath/distributions/nbinom.js
function rnbinom(size, prob) {
      var rg;

      if (size <= 0 || prob <= 0 || prob > 1) {
         return function() { return NaN; };
      }
      if (prob === 1) { return function() { return 0; }; }
      rg = rgamma(size, (1 - prob) / prob);
      return function() { return rpois(rg())(); };
   }
function rnbinom(size, prob) {
      var rg;

      if (size <= 0 || prob <= 0 || prob > 1) {
         return function() { return NaN; };
      }
      if (prob === 1) { return function() { return 0; }; }
      rg = rgamma(size, (1 - prob) / prob);
      return function() { return rpois(rg())(); };
   }
function rnbinom ( size , prob ) { var rg ; if ( size <= 0 || prob <= 0 || prob > 1 ) { return function ( ) { return NaN ; } ; } if ( prob === 1 ) { return function ( ) { return 0 ; } ; } rg = rgamma ( size , ( 1 - prob ) / prob ) ; return function ( ) { return rpois ( rg ( ) ) ( ) ; } ; }
Returns a random variate from the negative binomial distribution.

`size` must be strictly positive, and `prob` must be in `(0, 1]`.

@fullName rnbinom(size, prob)()
@memberof nbinom
Returns a random variate from the negative binomial distribution .