Skip to content

boo1ean/mersenne-twister

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Mersenne Twister pseudorandom number generator

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •