panthrMath/distributions/nbinom.js
function pnbinom(size, prob, lowerTail, logp) {
      logp = logp === true;
      lowerTail = lowerTail !== false;

      return function(x) {

         if (utils.hasNaN(x, size, prob) ||
             size < 0 || prob <= 0 || prob > 1 ||
             utils.isInfinite(size)) {
           return NaN;
         }
         if (size === 0) {
             return utils.adjustLower(x >= 0 ? 1 : 0, lowerTail, logp);
         }
         if (x < 0) { return utils.adjustLower(0, lowerTail, logp); }

         x = Math.floor(x + 1e-14);

         return beta.pbeta(size, x + 1, lowerTail, logp)(prob);
      };
   }
function pnbinom(size, prob, lowerTail, logp) {
      logp = logp === true;
      lowerTail = lowerTail !== false;

      return function(x) {

         if (utils.hasNaN(x, size, prob) ||
             size < 0 || prob <= 0 || prob > 1 ||
             utils.isInfinite(size)) {
           return NaN;
         }
         if (size === 0) {
             return utils.adjustLower(x >= 0 ? 1 : 0, lowerTail, logp);
         }
         if (x < 0) { return utils.adjustLower(0, lowerTail, logp); }

         x = Math.floor(x + 1e-14);

         return beta.pbeta(size, x + 1, lowerTail, logp)(prob);
      };
   }
function pnbinom ( size , prob , lowerTail , logp ) { logp = logp === true ; lowerTail = lowerTail !== false ; return function ( x ) { if ( utils . hasNaN ( x , size , prob ) || size < 0 || prob <= 0 || prob > 1 || utils . isInfinite ( size ) ) { return NaN ; } if ( size === 0 ) { return utils . adjustLower ( x >= 0 ? 1 : 0 , lowerTail , logp ) ; } if ( x < 0 ) { return utils . adjustLower ( 0 , lowerTail , logp ) ; } x = Math . floor ( x + 1e-14 ) ; return beta . pbeta ( size , x + 1 , lowerTail , logp ) ( prob ) ; } ; }
Evaluates the lower-tail cdf at `x` for the negative binomial distribution.

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

`lowerTail` defaults to `true`; if `lowerTail` is `false`, returns
the upper tail probability instead.

`logp` defaults to `false`; if `logp` is `true`, returns the logarithm
of the result.

@fullName pnbinom(size, prob, lowerTail, logp)(x)
@memberof nbinom
Evaluates the lower - tail cdf at x for the negative binomial distribution .