I'm looking for a random number generator in JavaScript which I can initialize with a certain seed and gives a deterministic result (according to that seed). It should be capable of providing random integers within a certain range, however I can work with a random number generator that spits doubles, too (just like Math.random()).
Basically I'm looking for an equivalent to java.util.Random as known in the Java World for JavaScript.
Is there something like this already built into JavaScript? Is there some (maybe HTML5 related API) which specifies such a thing? Is there a library providing such a random number generator?
I'm implementing a genetic algorithm in JavaScript and I need to be able to harvest the same results for the same inputs (including seed) for research.
The numbers generated are not truly random; typically, they form a sequence that repeats periodically, with a period so large that you can ignore it for ordinary purposes. The random number generator works by remembering a seed value which it uses to compute the next random number and also to compute a new seed.
A random seed is a starting point in generating random numbers. A random seed specifies the start point when a computer generates a random number sequence. This can be any number, but it usually comes from seconds on a computer system's clock (Henkemans & Lee, 2001).
This might help you, I just found it on the internet. It's apparently a replacement for Math.random()
http://davidbau.com/encode/seedrandom.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With