@grandom/mt19937
TypeScript icon, indicating that this package has built-in type declarations

1.0.6 • Public • Published

@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

Package Sidebar

Install

npm i @grandom/mt19937

Weekly Downloads

307

Version

1.0.6

License

BSD-3-Clause

Unpacked Size

41.2 kB

Total Files

6

Last publish

Collaborators

  • richrdkng