Home Business & Finance The mathematics of financial models

# UNIFORM NUMBER GENERATION

Given the discussion in the introduction, the need to generate standard uniform numbers should be obvious to the reader. While there are many ways of generating a uniform number, I will discuss three of the more common methods used by practitioners.

## Random Sampling

As suggested by the name, there is an element of randomization associated with this method of producing uniform numbers. In practice, uniform numbers are generated randomly using some well-defined system (e.g., computer clock, linear congruential generators, and so on) or some natural phenomena (e.g., the time between each Geiger counter click in the decay of a radioactive substance). Despite the soundness associated with use of a natural phenomenon to produce random numbers, due to the ease of practical implementation, one usually resorts to the use of a well-defined system to generate random numbers.

The generation of a uniform number is a standard feature in many programming languages. Table 4.1 shows the two functions in Microsoft Excel that can be used to generate random numbers.

TABLE 4.1 Generation of Random Numbers Using Excel While the first function in Table 4.1 generates a random number in the interval (0,1), the second generates random integers in a prespecified interval. Since the focus of this section is to generate uniform numbers in the interval (0,1), I will restrict my comments to the generation of a standard uniform number. Thus, unless otherwise mentioned, whenever I make reference to a number generator, it is implicitly assumed to be one that generates a uniform number in the interval (0,1).

Table 4.1 shows how easy it is to generate a random uniform number in Microsoft Excel. Furthermore, it is important for one to realize that the numbers generated using the function “=rand()” is based on an algorithm. As a consequence, the generated uniform numbers are in fact pseudo-random. Given this backdrop, it is imperative for the user of these random numbers to know how “good” these pseudo-random number generators are – where the term “good” refers to properties like the uniformity associated with the generated numbers, the speed at which the numbers can be generated, the length of sequence of generated numbers before the sequence gets repeated, and so on.

Like many pseudo-random-number generators, the one in Microsoft Excel also uses a predefined system to generate its random numbers. As can be seen from the Microsoft Support document, the Microsoft Excel function creates this random number by taking the sum of 3 random numbers and then taking the fractional part of the sum. The consequence of this is the ability to generate random numbers with a periodicity of 1013 (i.e., 1013 numbers need to be generated before the numbers are repeated). This idea was based on 1982/1987 papers by Wichman and Hill. The reader may also be interested to note that these random numbers do pass the Diehard tests (which are a collection of statistical tests put together by Professor George Marsaglia that any good random-number generator should pass).

•  The term well-defined system is an oxymoron when used to generate random numbers, in that the numbers generated are not truly random (as it has been predetermined by some algorithm). In fact once a certain threshold of generated numbers (also sometimes called periodicity) has been exceeded, these numbers tend to be repeated (and hence defeating the notion of randomness). As a consequence, practitioners are constantly looking for a random number generator with a very high periodicity (and hence a low likelihood of repetition).
•  For example, in C++, the uniform number can be randomly generated using the function rand() located in stdlib.h (the standard library).
•  An example of a bad number generator is the ill-famed IBM linear congruential pseudo number-generator RANDU, which is given by the recursive relation Vj+1 = 65539 * Vjmod(231), where V0 is odd and is usually set to the value 1. (This number can be easily converted into the (0,1) interval by dividing it by 231). RANDU was widely considered to be a very poorly designed number generator simply because it failed the spectral test (which is a test that can be used to evaluate the randomness associated with linear congruential generators). See also Marsaglia (1968).
•  i.cs.hku.hk/~diehard/. Found a mistake? Please highlight the word and press Shift + Enter Subjects