Random Numbers

A TS2068 contest entry

This program is of truly heroic dimensions. Since it is unlikely that any of our readers would want to key in the 35,665 bytes of the program, Mr. Lewis has agreed to supply tapes of the program for a charge of $8, which includes postage and handling within the US and Canada.

Send orders to:

Frederick M. Lewis
5 Sherwood Park Drive
Burnt Hills, NY 12027

The program includes a wealth of descriptive material and illustrative examples, as well as a useful bibliography.

The program is best described in Mr. Lewis’s own words:

This program is an interactive tutorial on random numbers, ways to generate and test them and on uses. Random numbers are not at all as simple as they seem intuitively to be. They are fascinating and allow us to solve complex mathematical and physical problems that could not otherwise be treated. Although we tend to think casually about them random numbers are difficult to define, impossible to test, impractical and difficult to generate by physical means (eg ‘true’ random numbers as by radio-active decay) and impossible to generate by computer except as so-called pseudorandom numbers, which are not really random but hopefully ‘act like’ they are.

We cannot really ‘test’ for randomness because a true infinite series will contain all possible sequences (called global random sample) but we must use a finite sample (called a local sample). If a coin flipped heads 1000 (or one million!) times we might be suspicious but could not rule the coin non-random. What we do is test a finite sample by selected tests to see if the numbers behave locally. Certain number sequences such as PI have passed all possible tests but cannot be called random because the next digit is always predictable.

Many pseudorandom generators have been devised for computer use. All have deficiencies such as short ‘periods’ after which they repeat.

Selected demonstrations from the program are described below.

HEADS OR TAILS

This program converts rnd no.s to 1’s (n<0.5) or 0’s (n>=0.5) to analyze a string of random numbers either in the computer generated form (0.nnnnn) or as single random digits keyed in individually at the user option.

Another program…

… plots a field of random x/y points to test for ‘order’ as revealed by any systematic pattern. This method shows order not detected by other tests. The patterns developed for single generators (test using plot 1 program) show that no generator is perfect and all develop some order. This program uses two generators to compute alternate numbers switching from the built in rnd generator to a program generator.

One routine plots Brownian trails, while another discusses tests for randomness:

One method used to test random-number samples is based on comparing the observed frequencies of occurrence of selected digits (one at a time) with expected frequencies for randomly distributed samples. The “chi square” distribution provides a test.

The need for this is illustrated by the fact that apparently random samples are often “skewed”. Consult any table of statistical data such as a list of populations of cities (any almanac) and note that the first digits are predominately digits 1-4 vs the less frequent digits 6-9.

One of the most spectacular demonstrations in the program, which generates Figure 1, is described as follows:

Process optimization is an important application. The demo simulates an actual optimization model that was designed to improve the performance of a polyurethane foam surfactant which is a function of the size distribution of foam cells. The 3-d surface represents the ‘quality’ as the dependent variable of a multiple regression analysis of quality vs reaction parameters. Optimization is achieved by estimating the position of the hill top performance via successive approximations to make the best product. The actual analysis was done on a main frame and lengthy for demo. So, though a 2068 can do the job it is only simulated in this program.

One of the most impressive parts of the program is the well-researched and extensive bibliography:

  • The Art of Computer Programming, Ed.2, Donald E. Knuth, Addison-Wesley, Vol. 2/Seminumerical Algorithms. (One of the best).
  • An Introduction to Probability Theory and its its Applications, William Feller, Vol. 1, Wiley, 1950, 1957, 1968 (this book is a timeless classic, it is still republished after 35 years- they call it simply “Volume One”).
  • Computer Simulation Techniques, Thomas Naylor et. al., Wiley., Chapter 3. (Good reference).
  • The Fractal Geometry of Nature, Benoit Mandelbrot, W. H. Freeman 1983.
  • Random Number Generators, Birger Jansson, Victor Pettersons Bokindustrie Aktiebolag.
  • On the Meaning of Randomness and Some Ways of Achieving it, Martin Gardner, Scientific American, July, 1968, page 116
  • On the Problems of Random Vibrations, and of Random Flights in One, Two and Three Dimensions, Lord Rayleigh, The London, Edinburgh and Dublin Philosophical Magazine and Journal of the Series xxxi, April, 1919, p. 321
Figure 1. The computer in process control
Figure 1. The computer in process control