in reply to Re^3: Mersenne Twister
in thread Mersenne Twister
The Mersenne Twister is a popular pseudo-random number generator (PRNG) because it has good distribution properties and a long period length (2^19937 - 1) before the sequence repeats. It passes all the diehard tests of randomness, and nearly all of the TestUO1 tests. (Wikipedia is a reasonable source of info for this: https://en.wikipedia.org/wiki/Mersenne_Twister).
The algorithm you describe is a Linear Congruential Generator (LCG). These have global correlation structures that cause issues at the square root or cubed root of the period length.
Perl's rand() uses the drand48 algorithm on all operating systems since 5.20 (https://metacpan.org/release/RJBS/perl-5.20.0/view/pod/perldelta.pod#rand-now-uses-a-consistent-random-number-generator). This has a longer period length (2^48) than the standard ANSI C rand (2^31) but is still an LCG and thus has issues with correlation structures. Some useful illustrations are at https://wellington.pm.org/archive/200704/randomness/index.html, for example slide7, slide8 and slide 14.
Whether all the above matters depends on the application. If it is just selecting from a small pool of items a small number of times then the choice of PRNG is unlikely to be an issue. Applications with larger data sets require better quality PRNGs.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Mersenne Twister
by harangzsolt33 (Deacon) on Jan 06, 2024 at 00:44 UTC |