Skip to main content

Random

class Random 

A random number generator based on Mulberry32.

Constructors

constructor

public new Randomstate: number: Random

Parameters

Methods

floatArray

public floatArraysize: numberfrom: number = 0to: number = 1: number[]

Get an array filled with random floats in the given range.

Parameters

  • size: number

    The size of the array.

  • from: number = 0

    The start of the range.

  • to: number = 1

    The end of the range.


gauss

public gaussmean: number = 0stdev: number = 1: number

Get a random float from a gaussian distribution.

Parameters

  • mean: number = 0

    The mean of the distribution.

  • stdev: number = 1

    The standard deviation of the distribution.


intArray

public intArraysize: numberfrom: number = 0to: number = 4294967296: number[]

Get an array filled with random integers in the given range.

Parameters

  • size: number

    The size of the array.

  • from: number = 0

    The start of the range.

  • to: number = 4294967296

    The end of the range. Exclusive.


nextFloat

public nextFloatfrom: number = 0to: number = 1: number

Get the next random float in the given range.

Parameters

  • from: number = 0

    The start of the range.

  • to: number = 1

    The end of the range.


nextInt

public nextIntfrom: number = 0to: number = 4294967296: number

Get the next random integer in the given range.

Parameters

  • from: number = 0

    The start of the range.

  • to: number = 4294967296

    The end of the range. Exclusive.


spawn

public spawn(): Random

Create a new independent generator.