Randomness

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Simulation Course Notes Professor Linda Weiser Friedman

Modeling Random Phenomena

Random Numbers

Truly Random Numbers. May use coin flips, dice, roulette wheel, etc. [Sidebar: Are coin flips
truly random? How can we determine?] In reality, this method generally measures some
physical phenomenon that is expected to be random (e.g., radioactive decay or any source of
“noise”). May have to compensate for possible biases in the measurement process.

Ever wonder where the numbers in the Random Numbers Table at the back of your statistics
book came from? These tables wer produced starting in 1947 by the Rand Corporation, using an
electronic simulation of a roulette wheel attached to a computer, the results of which were
then carefully filtered and tested before being used to generate the table. The RAND table was
an important breakthrough in delivering random numbers, because such a large and carefully
prepared table had never before been available. It was eventually published in book form - A
Million Random Digits with 100,000 Normal Deviates, RAND Corporation, 1955.

Pseudorandom numbers. A pseudorandom number generator is an algorithm for generating a


sequence of numbers whose properties approximate the properties of sequences of random
numbers. The sequence is not truly random, but is deterministic, because it is completely
determined by an initial value, the seed (which may include truly random values).

PRNG
RN RN

Why not just use truly random numbers?


 Speed
 Reproducibility

Pseudorandom numbers are also used in cryptography.

Periodicity. Depending on the algorithm used, and the size of the seed, there is a finite period
during which the RNs generated are repetition-free. After that the sequence repeats.

Randomness in Simulations 1
Simulation Course Notes Professor Linda Weiser Friedman

Example of a Simple Pseudorandom Number Generator.

Middle-square method, an early pseudorandom number generator. A very early PRNG, used by
John von Neumann as early as 1946, is known as the middle-square method. The algorithm is as
follows, for each iteration:
1. Get a RN of n digits, where n is even.
2. Square it, and add zeros to the left to form a sequence of 2n digits.
3. Extract the middle n digits as the new RN
For example, squaring the number "1111" yields "1234321", which can be written as
"01234321", an 8-digit number being the square of a 4-digit number. This gives "2343" as the
new "random" number. Repeating this procedure gives "4896" as the next result, and so on.
Von Neumann used 10 digit numbers for this algorithm on an ENIAC computer.

A problem with the middle-square method is that all sequences eventually repeat themselves,
some very quickly (such as "0000"). Von Neumann was aware of this, but he found the
approach sufficient for his purposes, and was worried that mathematical "fixes" would simply
hide errors rather than remove them.

Properties of a good PRNG.


 Numbers generated should be random. (er, they should appear to be random, i.e., they
should act like random numbers)
 Numbers generated should be reproducible.
 Algorithm should be fast
 Efficient use of computer resources (time, space)
 Long period before cycling
 Should not degenerate to the same number over and over again. This sometimes
happens with the number 0000.

Testing.
How do we know that the “random” numbers generated by a PRNG are random? We know that
they are NOT since they can be predicted with certainty.

RNs generated in this way are tested for randomness (and lack of a pattern) using a several
statistical tests including, e.g., goodness of fit with the Uniform distribution.

[Sidebar: There has been a lot of controversy over the PRNG used for the RAND() function in MS
Excel. Apparently, even after repeated “fixes” it still failed to demonstrate randomness and
reproducibility. Somewhat better since the 2010 version, but still has issues.]

Randomness in Simulations 2

You might also like