Random number generator object.
Want to see pretty graphs? Log in now!
npm install hrandom
|8||downloads in the last week|
|18||downloads in the last month|
|Last Published By|
|Version||1.1.2 last updated 10 months ago|
An efficient Mersenne Twister implementation using the Java Random interface.
The original authors are Takuji Nishimura and Makoto Matsumoto
The library itself is a constructor that returns a '''Random''' object. It is not necessary to use ''new'' before the constructor.
var Random = require('random'); var random = new Random(42);
The Random object implements next(), nextInt(), and nextBoolean() as per Java's API. nextElement and shuffle are some random functions that are often done to arrays. Each element in the range has an equal chance of being selected.
'''next()''' - Returns a value between [0..1) in increments of 2^-32. '''nextInt(length = 4294967295) ''' - Returns an int between [0..length). '''nextBoolean()''' - Returns either true or false.
'''nextElement(array)''' - Returns an element from the arrayj. '''shuffle(array)''' - Returns a new array with the contents of the passed in array shuffled.