The RANDU pseudo-random number generator

On my homepage I have for awhile mentioned that I wanted to get my symposium project posted someday.

I’ve finally had a chance to touch up the code I used in the symposium and I’ll briefly mention here what this is all about.

In the late 60’s IBM developed a random number generator for its System/360 computers called RANDU. The algorithm was designed to be fast and have an easy implementation. Unfortunately it had a lot of deficiencies associated with it as well, including some glaring anomalies which are visible if you plot RANDU-generated points in 3 dimensions.

View of RANDU points looking like a uninteresting random distribution in a cube (click to enlarge)

This view of a RANDU-derived point distribution doesn’t look so bad. But if you rotate around the view a little bit, you’ll see this:

View of RANDU points looking like a set of planes (click to enlarge)

That doesn’t look very random at all. This type of testing is referred to as spectral testing, and it carries on to greater than 3 dimensions even (although it’s hard for us to visualize of course). Spectral testing is just one of a series of different tests that scholars use to determine how “random” psuedo-random number generators really are.

RANDU was bad in other ways too. Although it could output up to 2^32 or so different numbers it started repeating numbers long before that point (which makes the output not-very-random at all).

Anyways, this was the essence of my symposium project. It was a program I used to aid my demonstration, written in Qt 3 on Linux and then cross-compiled to Windows using a free (as in beer) Borland compiler running under Wine (I forgot what patch I used to eventually make it work). (The Qt 3 I used came with C++ GUI Programming with Qt 3 as a non-commercial license).

The program itself was derived from a series of programs I used in my Computer Graphics class (where we basically implemented 3-D primitives ourselves instead of with OpenGL — this was the first time I got to use OpenGL’s 3-D features), so that’s what the rotation and scale features are for (as in, I didn’t take them out).

As I mentioned, I ported the program to Qt 4. I used this as my opportunity to learn how to use the git source control program, which I’m liking more and more as we go. The final result is available from this link, with 3 random number generators, including RANDU.

I’ve fixed many stupid programming mistakes but a lot of the history is still evident in the code (such as scaling all the random numbers to 0-1000.0 arbitrarily. :))