new require("MersenneTwister")(seed)
Instantiates a new Mersenne Twister.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
seed |
number |
<optional> |
The initial seed value. |
- Since:
- 0.1.0
- Source:
- MersenneTwister.js, line 46
A standalone, pure JavaScript implementation of the Mersenne Twister pseudo random number generator. Compatible with Node.js, requirejs and browser environments. Packages are available for npm, Jam and Bower.
- Version:
- 0.1.1
- License:
- See the attached LICENSE file.
- Source:
- MersenneTwister.js, line 12
Methods
-
<static> random() → {number}
-
A static version of
rnd
on a randomly seeded instance.- Source:
- MersenneTwister.js, line 220
Returns:
- Type
- number
-
int() → {number}
-
Generates a random unsigned 32-bit integer.
- Since:
- 0.1.0
- Source:
- MersenneTwister.js, line 130
Returns:
- Type
- number
-
int31() → {number}
-
Generates a random unsigned 31-bit integer.
- Since:
- 0.1.0
- Source:
- MersenneTwister.js, line 171
Returns:
- Type
- number
-
real() → {number}
-
Generates a random real in the interval [0;1] with 32-bit resolution.
- Since:
- 0.1.0
- Source:
- MersenneTwister.js, line 181
Returns:
- Type
- number
-
realx() → {number}
-
Generates a random real in the interval ]0;1[ with 32-bit resolution.
- Since:
- 0.1.0
- Source:
- MersenneTwister.js, line 191
Returns:
- Type
- number
-
rnd() → {number}
-
Generates a random real in the interval [0;1[ with 32-bit resolution.
- Since:
- 0.1.0
- Source:
- MersenneTwister.js, line 201
Returns:
- Type
- number
-
rndHiRes() → {number}
-
Generates a random real in the interval [0;1[ with 53-bit resolution.
- Since:
- 0.1.0
- Source:
- MersenneTwister.js, line 211
Returns:
- Type
- number
-
seed(seed)
-
Initializes the state vector by using one unsigned 32-bit integer "seed", which may be zero.
Parameters:
Name Type Description seed
number The seed value.
- Since:
- 0.1.0
- Source:
- MersenneTwister.js, line 63
-
seedArray(vector)
-
Initializes the state vector by using an array key[] of unsigned 32-bit integers of the specified length. If length is smaller than 624, then each array of 32-bit integers gives distinct initial state vector. This is useful if you want a larger seed space than 32-bit word.
Parameters:
Name Type Description vector
array The seed vector.
- Since:
- 0.1.0
- Source:
- MersenneTwister.js, line 84