Random number generator
- Pseudo-random number generator
- The Mersenne Twister
is a popular one.
- Random "Seed"
- Pseudo-random number generators typically work by taking a
random "seed"
and then generating an apparently random sequence.
- Different seed, different sequence.
- But also a pitfall: Same seed, same sequence.
-
Therefore, use a unique seed each time,
e.g. seed based on the clock time
(second and nanosecond).
JavaScript random number generation demo.
Usage:
Freeze the seed key.
Set parameters.
Then generate random numbers.
Can view JavaScript code to see how it works.