Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Random

An LCG random number generator that resembles the behavior of java.util.random, i.e.:

    x(n+1) = (x(n) * a + c) % m

with m = 2^48, a = 25214903917 and c = 11.

Hierarchy

  • Random

Index

Constructors

Methods

Constructors

constructor

  • new Random(seed?: bigint): Random
  • Creates a new random number generator with an optional seed.

    Note that the seed in this implementation only has 48 bits of precision and therefore will generate the same numbers a java.util.random only if 0 <= seed < 2^48

    Parameters

    • Optional seed: bigint

    Returns Random

Methods

random

  • random(): number
  • random(end: number): number
  • random(start: number, end: number): number
  • Returns a random number in the interval 0 (inclusive) to 1 (exclusive).

    Returns number

  • Returns a random number in the interval 0 (inclusive) to end (exclusive).

    Parameters

    • end: number

    Returns number

  • Returns a random number in the interval start (inclusive) to end (exclusive).

    Parameters

    • start: number
    • end: number

    Returns number

randomInt

  • randomInt(): number
  • randomInt(end: number): number
  • randomInt(start: number, end: number): number
  • Returns a random integer number in the interval -2^31 (inclusive) to 2^31-1 (inclusive).

    Returns number

  • Returns a random integer number in the interval 0 (inclusive) to end-1 (inclusive).

    Parameters

    • end: number

    Returns number

  • Returns a random integer number in the interval start (inclusive) to end-1 (inclusive).

    Parameters

    • start: number
    • end: number

    Returns number

Generated using TypeDoc