How Random is Random
by Sean Kelly
of Takoma Park Middle School

Abstract

The object of this experiment is to determine how random computer random number generators actually are. In performing this experiment, multiple random number generators were tested using similar programs. One program moves a dot (pixel) around the computerŐs screen randomly, after which the resulting image was checked for any pattern or symmetry. Q-Basic and True Basic scored highest in this program, each with a non-symmetrical image. Anatoly PreygelŐs algorithm, however, created a near-linear design. Another program used generates a series of random integers between one and ten which were compared and tallied (an ideal program would generate about the same tally for each number) Only True Basic passed this program, the others had a range in the tallies of more than 3. The third program used is somewhere between the other two. It generated a string of random numbers, which it printed out in colors corresponding to the number printed (i.e. all ones are red, all twos are blue). The printed string was examined to try and find any repeats of color-patterns. Only AnatolyŐs algorithm didnŐt pass this test. The data from each language/algorithm on each of these tests was recorded and displayed next to the results of the other random number generators tested.

Introduction

Random number generators, contrary to popular opinion, are not truly random. Most, if not all random number generators on computers use an equation to generate a random number. Because of this, the output of random number generators are considered pseudo-random, and only attempt to mimic true random results.

To generate random numbers, a computer will use a formula or algorithm. The algorithm will generate a series of pseudo-random numbers which may be related to each other, depending on what the generator uses as a seed variable. The seed variable is the first number run through the algorithm. You canŐt program a random number generator that pulls numbers out of thin air, math just doesnŐt work that way. There is also no way to seed the generatorŐs initial run with a random number, unless that number is from another generator in the same program, in which case that generator would need a seed variable. This is why many pseudo-random number generators ask for a variable before you can get any ŇrandomÓ numbers. If the program doesnŐt ask for a seed variable, it may be using the computerŐs ŇclockÓ, a measurement of how much code the computer has gone through. After the generator is started, it shouldnŐt need a new seed. Many generators will use the last output as a seed for the next run.

This project tests the randomness of various random number generators. To do this, three testing programs were made to use with the random number generators of certain computer programming languages, as well as another independent random number algorithm that was used in a programming language (Anatoly Preygel donated one he derived last year).

The programming languages that were tested are TrueBasic (Mac) Qbasic (IBM), and TrueBasic with Anatoly PreygelŐs chaos program, x = 4x(1 - x), instead of the built-in random number generator.

Each program and was run 5 times per test language, using different seed variables each time, and the results were compared in a table or list. The ideal random number generator would show no repeat patterns in the pattern-test program, stated earlier, not show any symmetry in the pixel movement graphics program, stated earlier, and output statistically similar tallies for each integer one through nine in the third program used during testing.

Walt Houser CPCUG Coordinator.

CPCUG Science Fair Home Page