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

    Function rbinom

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

      For size * min(prob, 1 - prob) >= 30 (algorithm BTPE) the stream can depart from R's: R's final acceptance test has two Stirling corrections with the wrong sign, and here the signs are right (setSeed(439); rbinom(1, 10000, 0.5) is 4879, R 5023). Below 30 (inversion) the stream is R's.

      Parameters

      • n: number

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

      • size: number

        Number of trials.

      • prob: number

        Probability of success in each trial.

      Returns number[]

      An array of n values; NaN for invalid parameters.

      setSeed(1);
      rbinom(5, 10, 0.5); // [4, 4, 5, 7, 4]