|go ahead... be a heretic|
Random numbers Perl ok! (I think)by liz (Monsignor)
|on Oct 12, 2003 at 09:35 UTC||Need Help??|
The NRC Handelsblad this Saturday had an article about pseudo-random number sequences. They mentioned the work of Heiko Bauke and Stephan Mertens: Entropy of Pseudo Random Numbers. According to the article in the NRC, it seems that many random number generators tend to generate longer sequences of zero's than you might want or expect. The article also claims that Bauke and Mertens indicate that by removing the 0's from random number sequences, you improve the quality of the random number sequence. I've tried to make heads or tails from the original article by Bauke and Mertens, but it is waaay out of my league. So I hope the assumptions of the NRC article are correct.
Anyway, I decided to see whether the standard Perl random number generator would suffer from this problem, and created the following program:
The program basically draws random numbers and puts them into a string. A regular expression is used to find out whether the number was the same as the previous time. If not, it will score the number of times the previously drawn random number was drawn consecutively.
The program will run until interrupted with a Control-C. Then it will display the result.
I let this run on my iBook last night (I guess in total for about 9 hours or so) and came up with the following results.
If 3. is true, then I don't think any "normal" use of Perl would need to worry. I can't remember ever drawing close to 2G random numbers in a single run ;-)
Since this was fun to do, I'd thought I'd share this.