rStats.js v1.3.0
    Preparing search index...

    Function rnbinom

    • Random numbers from the negative binomial distribution. Equivalent to R's rnbinom().

      Parameters

      • n: number

        Number of values to generate (fractions are truncated, as in R).

      • size: number

        Target number of successes (dispersion parameter; need not be an integer).

      • options: { mu?: number; prob?: number }
        • Optionalmu?: number

          Mean (alternative parametrization). Give exactly one of prob and mu.

        • Optionalprob?: number

          Probability of success in each trial. Give exactly one of prob and mu.

      Returns number[]

      An array of n values; NaN for invalid parameters.

      TypeError unless exactly one of prob and mu is given.

      setSeed(1);
      rnbinom(5, 3, { prob: 0.5 }); // [3, 2, 2, 2, 2]
      rnbinom(5, 3, { mu: 2 });