Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@grandom/mt19937

grandom-library1.7kBSD-3-Clause1.0.6TypeScript support: included

Configurable Mersenne Twister PRNG implementation written in TypeScript.

mersenne, twister, mt19937, seed, random, number, generator, seedable, rng, prng, srng, sprng, mersennetwister, mersenne-twister, randomness, rand

readme

@grandom/mt19937

Configurable Mersenne Twister PRNG implementation written in TypeScript.

Install

npm i @grandom/mt19937

Usage

import MT19937 from '@grandom/mt19937'

// create a new MT19937 instance with seed 12345
const random = new MT19937(12345)

// a random integer in range [0, 4294967295]
// use this for common random integer generation
const randomInt32 = random.randomInt32()

// a random integer in range [0, 2147483647]
const randomInt31 = random.randomInt31()

// a random float in range [0.0, 1.0]
const randomFloat1 = random.randomFloat1()

// a random float in range [0.0, 1.0) - same as Math.random()
// use this for common random float generation
const randomFloat2 = random.randomFloat2()

// a random float in range (0.0, 1.0)
const randomFloat3 = random.randomFloat3()

// a random float in range [0.0, 1.0) with 53-bit resolution.
const randomFloatRes53 = random.randomFloatRes53()

License

BSD-3-Clause @ Richard King

changelog

1.0.6 (2023-09-25)

Performance Improvements

  • deps: bump @types/jest from 29.5.4 to 29.5.5 (4292ab6)

1.0.5 (2023-09-14)

Performance Improvements

  • deps: bump jest from 29.6.4 to 29.7.0 (ec4fea4)

1.0.4 (2023-09-14)

Performance Improvements

  • deps: bump rollup from 3.29.0 to 3.29.1 (a03f31d)

1.0.3 (2023-09-06)

Performance Improvements

  • deps: bump rollup from 3.28.1 to 3.29.0 (99185e6)

1.0.2 (2023-08-29)

Performance Improvements

  • deps: bump @rollup/plugin-typescript from 11.1.2 to 11.1.3 (da9a82d)

1.0.1 (2023-08-24)

Performance Improvements

  • deps: bump jest from 29.6.3 to 29.6.4 (039a5c9)

1.0.0 (2023-08-19)

Features