Skip to content

Function: createRng() ​

ts
function createRng(seed): Rng;

Defined in: src/utils/rng.ts:41

Create a seeded pseudo-random number generator (mulberry32).

The same seed always yields the same sequence. The seed is reduced to an unsigned 32-bit integer, so seeds that differ only above 2^32 or in their fractional part give the same sequence.

mulberry32 is fast and statistically adequate for resampling and initialisation; it is not cryptographically secure.

Parameters ​

seed ​

number

Integer seed.

Returns ​

Rng

A function returning uniform numbers in [0, 1).

Throws ​

If seed is not a finite number.

Released under the MIT License.