Lousy Random Number Generators

Over at Jeff Atwood’s blog, Coding Horror, I noticed a nice round-up of random number generation. I tried to post a quick comment but it kept being rejected so I’ve blogged it here instead.

Anyone interested in a small but ‘highly’ random generator that suffers from few points of failure should check out the mersenne twister pseudo-random number generator algorithm. This work is fairly recent (1998). I believe it has been implemented in the .NET framework?

The problem that plagues most generators occurs when you require a huge set of random numbers for large simulations (such as Monte Carlo simulations, for instance).

A word of advice: never, never attempt to roll your own generator or ‘improve’ an existing one. The results will be at best less than random, and at worst dangerous! It’s in the same sin category as using Bubble Sort. A most heinous crime!

http://www.bedaux.net/mtrand/ includes a reference to the original paper.
http://en.wikipedia.org/wiki/Mersenne_twister

Bruce Schneier’s book Applied Cryptography (John Wiley & Sons, 1994) is a great place to start if you are interested in random numbers from the point of view of cryptography.