Random numbers have been shown to be valuable
in sampling, simulations, modeling, data encryption,
gambling and even musical composition
The mathematician, Robert R. Coveyou, said: “The genera- tion of random numbers is too important to be left to chance.”
Random numbers are used in sampling,
simulations, modeling, data encryption,
gambling and even musical composition.
A random number is one selected from
a set of equally possible values. Any
sequence of random numbers must be statistically independent of the others.
There are two major methods of random
number generation, each with their own
strengths and applications: Pseudo-Random
Number Generators (PRNGs) and True
Random Number Generators (TRNGs).
These can be compared by three characteris-
tics: efficiency, determinism and periodicity.
Efficiency means that many numbers can be
produced quickly. Determinism means that
the sequence can be reproduced, provided
that the starting point is known. Periodicity
means that the sequence eventually repeats
itself. The methods are compared in Figure 1.
These characteristics make PRNGs more
suitable for sampling, simulations, mod-
eling and musical composition, whereas
TRNGs are more suitable for data encryp-
tion and gambling.
There are statistical test suites to
evaluate randomness. Three of the more
common ones are Diehard, Crypt-XS and
NIST. The NIST tests are built on hypoth-
esis testing, whether a specific sequence
of zeroes and ones is random or not. The
battery of 15 tests evaluates frequencies,
cumulative sums, runs, ranks and period-
icity. After the tests have been applied, a
comparison of how well the results match
their theoretical distribution can be done
by performing a goodness of fit of the
distribution of the p-values to a uniform
distribution. One evaluation method is to
compare the mean and variances of the
p-values to those for a uniform distribu-
tion. Another evaluation method is to
compute a chi-square statistic based on the
frequency counts of p-values among bins.
The procedure to generate PRNGs often
Figure 1: Comparison of two major methods of random number generation
Figure 2: Example of an equation to generate
Pseudo-Random Number Generators
Figure 3: SAS can use the standard normal
distribution with a seed.