mt

mersenne-twister

Mersenne Twister pseudorandom number generator

Showing:

Popularity

Downloads/wk

125K

GitHub Stars

95

Maintenance

Last Commit

5yrs ago

Contributors

2

Package

Dependencies

0

Size (min+gzip)

0.8KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Pseudorandom number generator Build Status

Mersenne Twister pseudorandom number generator.

Origin source (generator interface was changed)

Algorithm - http://en.wikipedia.org/wiki/Mersenne_twister

Installation

$ npm install mersenne-twister

Usage

var MersenneTwister = require('mersenne-twister');
var generator = new MersenneTwister();

// Generates a random number on [0,1) real interval (same interval as Math.random)
generator.random();

// [0, 4294967295]
generator.random_int();

// [0,1]
generator.random_incl();

// (0,1)
generator.random_excl();

// [0,1) with 53-bit resolution
generator.random_long();

// [0, 2147483647]
generator.random_int31();

Seeding

If you want to use a specific seed in order to get a repeatable random sequence, pass an integer into the constructor:

var generator = new MersenneTwister(123);

and that will always produce the same random sequence.

Also you can do it on existing generator instance:

generator.init_seed(123);

License

See source

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial