I know this is really random, but the notion of random numbers has fascinated me for as long as I can remember. In my early BASIC programming days, I was delighted to find the RAND function. Mostly I used it to draw randomly colored dots in random places on the screen, and maybe even thought of actual uses for it (dice? checkbook balancing?) It was definitely a simpler time, software-wise.

Recently I mentioned to my patient spouse that I had just read an interesting way to create random numbers, and she responded, almost on cue, “Why would anyone want to create random numbers?” What a set-up. This post is my answer to her (Hi, honey.)

We benefit from random numbers, and their engineered counterparts, pseudo-random numbers, in many ways. When you play a game on your phone or computer, it uses unpredictable numbers to help it decide where to position troops on a battlefield, aliens in space, angry birds, or cards in a solitaire game, or how to respond to your last move. Many work-at-home folk use a thumb-sized device that allows remote computer access by showing a fresh new 6-digit security number every minute of every day until its battery runs out. Many forms of data encryption, such as those used by your on-line bank, also use un-guessable numbers to protect your data. You know the shuffle mode on your music player? Well, it’s sorta random. And, believe it or not, a respected method for solving an entire class of complex math problems requires the use of high-quality random numbers.

The astute reader (yes, you definitely qualify) has doubtlessly noticed that I used quite a collection of vague alternatives and adjectives for “random” in the preceding paragraph. Unpredictable, unguessable, secure, “sorta.” Pseudo-random. High-quality?

Let’s start with the music shuffler. It does use a pseudo-random number generator, but it also weighs in other factors. With a truly random number series, a given song might be played twice in a row, or even three times. Statistically, that should, on the average, take a long time. But if it happened, the listener would likely think the shuffler was broken, rather than thinking, “Hey, random!” So its algorithm precludes too-frequent repetition. Other factors it considers include which songs have already been played, and which ones you have listened to the most (that makes sense – it wants you to be happy.)

Security login and encryption keys, on the other hand, can’t be just “sorta random.” They have to be strictly predictable, because the number sent (by you, or by your secure browser) has to exactly match the number the other end is expecting.

Game play is a lot less taxing for a random number generator. Even if the solitaire program deals the exact same game twice in a row, only Rainman would be likely to figure it out. But if it did it four times in a row, even I might start to get suspicious.

So there are different requirements for different uses of random numbers. How does one control the quality of “randomness”, you might ask. Well, there’s one pretty clear dividing line. Numbers generated through the use of a computer algorithm, regardless of how clever, are pseudo-random at best. The series of numbers can always be repeated if you repeat the process with the same starting number, called the “seed.” This turns out to be useful for security applications, or even if you just want to try the same solitaire hand again.

To produce true randomness, some element of nature must be introduced. It may be something a simple as the passage of time. You could use time by letting the seed be your computer’s idea of how many seconds have elapsed since January 1, 1970, a popular starting point for Unix computer system clocks. There are other natural phenomena which can be exploited to produce true randomness. Some computer security systems generate a code based on the movements of the user’s mouse during a specified interval. Electronic circuits inherently produce random noise, like the sound you hear between AM radio stations. This noise is usually filtered out, but for random number generation, the noise can be extracted.

My favorite method of generating “true” random numbers was invented by Silicon Graphics employees Bob Mende, Landon Curt Noll, and Sanjev Sisodiya in 1996. They pointed a video camera at a rack full of lava lamps, and use the resulting pixelated randomness to create a string of random numbers. (I know you are thinking it: “What were they smoking?”)

In The Quark and the Jaguar, Murray Gell-Mann tells of being twice-surprised when he found a book of random numbers on a university shelf. He was surprised, first, that anyone would go to the trouble of printing a book of random numbers. Then he was further surprised when he found an errata sheet inserted into the book, because some of the random numbers on one of the pages were “wrong.” How can random numbers be wrong? (I suppose it’s asking deep questions like that that gets you on the path to being a world-class theoretical physicist.)

Perhaps the easiest way to explain the importance of good random numbers is to describe the Monte Carlo method of solving complex problems. The method was invented in the 1940s by John von Neumann, Stanislaw Ulam and Nicholas Metropolis, while they were working on nuclear weapon projects (Manhattan Project) in the Los Alamos National Laboratory. It was allegedly named for the casino where one of Ulam’s relatives consistently lost all of his money.

The Monte Carlo method applies when many unpredictable factors can affect an outcome. The theorist establishes or hypothesizes a formula describing the behavior of a system. Then the theorist uses a large set of random inputs to see how the “system” reacts to them. If the reaction makes sense to the theorist, then the formula has value.

Here’s where the tricky part comes in. If the random number are not truly random, that is, if they are biased in some way, the results of the analysis are not trustworthy. The example in Wikipedia link above shows how the Monte Carlo method can be used to calculate the value of pi. If you inscribe a circle in a square, the area of the circle divided by the area of the square is pi/4. You can calculate whether a given point is inside or outside the circle.

If you then pick a uniform distribution of points scattered across the area of the square, you can calculate an approximation of pi. But if the distribution is not uniform (that is, not truly random) the approximation will be off.

If you are interested in more details, you can find a “Monte Carlo thought experiment” and my own Monte Carlo computer simulation, RIGHT HERE.

My goodness, this post has taken a rather pedantic turn. I don’t suppose it would help to start musing about the psychosocial implications of preferring randomness, rather than predictability. Fortunately I’m not the only one: just look at the stars!

Let’s save that for another time. I’ll close with a wish for you, that your life will be **predictable** enough to be **comfortable**, and **random** enough to be **fun**!