Interface RandomUniform

A configurable random number generator for the uniform distribution.

interface RandomUniform {
    source(source): RandomUniform;
    (max?): (() => number);
    (min, max): (() => number);
}

Hierarchy

  • Returns a function for generating random numbers with a uniform distribution. The minimum allowed value of a returned number is min (inclusive), and the maximum is max (exclusive). Min defaults to 0; if max is not specified, it defaults to 1.

    Parameters

    • Optional max: number

      The maximum allowed value of a returned number, defaults to 1.

    Returns (() => number)

      • (): number
      • Returns a function for generating random numbers with a uniform distribution. The minimum allowed value of a returned number is min (inclusive), and the maximum is max (exclusive). Min defaults to 0; if max is not specified, it defaults to 1.

        Returns number

  • Returns a function for generating random numbers with a uniform distribution. The minimum allowed value of a returned number is min (inclusive), and the maximum is max (exclusive).

    Parameters

    • min: number

      The minimum allowed value of a returned number.

    • max: number

      The maximum allowed value of a returned number.

    Returns (() => number)

      • (): number
      • Returns a function for generating random numbers with a uniform distribution. The minimum allowed value of a returned number is min (inclusive), and the maximum is max (exclusive).

        Returns number

Methods

Methods

  • Returns the same type of function for generating random numbers but where the given random number generator source is used as the source of randomness instead of Math.random. This is useful when a seeded random number generator is preferable to Math.random.

    Parameters

    • source: (() => number)

      Source (pseudo-)random number generator implementing the Math.random interface. The given random number generator must implement the same interface as Math.random and only return values in the range [0, 1).

        • (): number
        • Returns number

    Returns RandomUniform