Class Random

Classdesc

Random class

Constructors

  • Parameters

    • Optional seedOrRandom: number | RandomNumberGenerator = Math.random

      Control the random number generator used by the Random class instance. Pass a random number generator function with a uniform distribution over the half-open interval [0, 1[. If seed will pass it to ml-xsadd to create a seeded random number generator. If undefined will use Math.random.

    Returns Random

Methods

  • Returns an array of elements choosen from a list

    Type Parameters

    • T

    Parameters

    • values: T[]

      The values to choose from. If a number, the list will be a range of integer from 0 to that number.

    • Optional options: ChoiceOptions

      option object

    Returns T[]

    The choosen values

  • Parameters

    Returns number[]

  • Draw a random integer from a uniform distribution on [low, high). If only low is specified, the number is drawn on [0, low)

    Parameters

    • low: number

      The lower bound of the uniform distribution interval.

    • Optional high: number

      The higher bound of the uniform distribution interval.

    Returns number

  • Draw a random number from a uniform distribution on [0,1)

    Returns number

    The random number

  • Draw several random number from a uniform distribution on [0, 1)

    Parameters

    • size: number

      The number of number to draw

    Returns number[]

    • The list of drawn numbers.