Function binomial

  • binomial(state: RngState, n: number, p: number): number
  • Generate a binomially-distributed random number; the number of successes in n trials each with probability p.

    The approach follows the BRTS algorithm of Hormann 1992 for large min(n * p, n * (1 - p)) > 10 and uses an inversion algorithm for small n * p.

    Parameters

    • state: RngState

      Random number state

    • n: number

      Number of trials

    • p: number

      Per-trial probability of success

    Returns number

Generated using TypeDoc