next up previous contents
Next: The Random Function Up: Randomization, Statistics and Visualization Previous: Randomization, Statistics and Visualization


This section explores some of the basic Darwin functions for randomization.

A number generator starts with an initial number s0 and produces a sequence of numbers $s_{1}, s_{2}, \dots$. This initial number s0 is called the seed for the sequence. If the number generator was producing a truly random sequence of numbers, then having seen the partial sequence $s_{0}, s_{1}, s_{2}, \ldots, s_{i}$, for any i, it is impossible to predict the number si+1.

Producing truly random sequences is impossible or at least extremely difficult (and hints at some deep philosophic issues). Instead, most languages provide functions to generate pseudo random numbers. Pseudo-random sequences also begin with a seed s0 and produce a sequence $s_{1}, s_{2}, \ldots$. However, pseudo-random sequences have a period, that is, there exists an i such that $s_{i}=s_{0}, s_{i+1}=s_{1}, \ldots$ and it is theoretically possible to invert the generation function which takes $s_{0}, s_{1},
\ldots, s_{i-1}$ and produces si. In other words, we could deduce the si having seen $s_{0}, s_{1},
\ldots, s_{i-1}$. In practice, for most applications, these pseudo random generators are more than sufficient.


Gaston Gonnet