Initialize the PRNG with a seed. Reset the sequence if called with the same seed.
Value of the seed (Positive integer) )
const rng = new PRNG();
rng.initialize(19650218);
assert.equal(
[rng.random(), rng.random(), rng.random(),]
[0.5414691786281765, 0.11225925898179412, 0.9725827916990966]
)
// Initialize again with the same seed resets the sequence
rng.initialize(19650218);
assert.equal(
[rng.random(), rng.random(), rng.random(),]
[0.5414691786281765, 0.11225925898179412, 0.9725827916990966]
Returns a random float in range 0 <=x < 1.
TODO: The original Mercenne code returns 32 bits precision, in JS we have 53 bits of precision, that might mess up our results. I need to check if the conversion is done properly
A simple Pseudo Random Number Generator class