Docsity

Random Number Generation-Modeling and Simulation-Handouts, Lecture notes of Mathematical Modeling and Simulation

Toggle sidebar
bg1
5.1 Random Number Generation
Random numbers form an essential part of the Monte Carlo method. The term
random number is generally used for uniform random number.
Initially, manual methods were employed, including coin flipping, dice
rolling, card shuffling, and roulette wheels.
In 1955 the RAND Corporation published a well known table of a million
random digits that may be used in forming such a table. The advantage
of this method is reproducibility; its disadvantage is its lack of speed
and the risk of exhausting the table.
In view of these difficulties, John von Neumann suggested the mid-
square method, using the arithmetic operations of a computer. His idea
was to take the square of the preceding random number and extract the
middle digits. For instance, if we are generating four-digit numbers and
arrive at 5232, we square it, obtain 27,373,824; the next number consists
of the middle four digits (namely, 3738 ) and the procedure is repeated.
This raises a logical question: how can such sequences, defined in a
completely deterministic way, be random?
The answer is that they are not really random, but only seem so, and are in
fact referred to as pseudo-random or quasi-random; still we call them
random, with the appropriate reservation.
Von Neumann's method was also slow and awkward for
statistical analysis; in addition the sequences tend to cyclic, and
once a zero was encountered the sequence stopped.
The random numbers generated by this or any other method are
"good" ones if they are uniformly distributed, statistically
independent, and reproducible.
A good method is, moreover, necessarily fast and requires
minimum memory capacity.
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Random Number Generation-Modeling and Simulation-Handouts and more Lecture notes Mathematical Modeling and Simulation in PDF only on Docsity!

5.1 Random Number Generation

Random numbers form an essential part of the Monte Carlo method. The term random number is generally used for uniform random number.

Initially, manual methods were employed, including coin flipping, dice rolling, card shuffling, and roulette wheels.In 1955 the RAND Corporation published a well known table of a million random digits that may be used in forming such a table. The advantage of this method is reproducibility; its disadvantage is its lack of speed and the risk of exhausting the table.In view of these difficulties, John von Neumann suggested the mid- square method, using the arithmetic operations of a computer. His idea was to take the square of the preceding random number and extract the middle digits. For instance, if we are generating four-digit numbers and arrive at 5232, we square it, obtain 27,373,824; the next number consists of the middle four digits (namely, 3738 ) and the procedure is repeated.This raises a logical question: how can such sequences, defined in a completely deterministic way, be random?The answer is that they are not really random, but only seem so, and are in fact referred to as pseudo-random or quasi-random; still we call them random, with the appropriate reservation.

Von Neumann's method was also slow and awkward for statistical analysis; in addition the sequences tend to cyclic, and once a zero was encountered the sequence stopped.

The random numbers generated by this or any other method are "good" ones if they are uniformly distributed, statistically independent, and reproducible.

A good method is, moreover, necessarily fast and requires minimum memory capacity.

Some Notations and Concepts in Number Theory

for Random Numbers

When the difference of two numbers S and T is evenly divisible by an integer M ,

then s is termed as “ congruent to T modulo M ”. It is written as

S TmodM (5.2)

For instance, consider 27 = 7 mod 5****.

Here, S is 27 ; T is 7 with a difference of 20. It is evenly divisible by 5.

The quotient (S – T )/M is an integer i.e. (27 – 7)/5 = 4.

If S, T and M satisfy Eq. (5.2), then two further relations exist:

1. S, T and M have same remainder after division by M. For example, 27 = 7 mod 5,

and 5

2. Also, the following relation exists: (S – T) = I ×M. (5.3)

Where, I is an integer.

For instance, 27 = 7 mod 5 means that 27 – 7 = 4 ×5.

When we look carefully into the second relation, we see that the S may have many possible values when T and M are given. These are known as collection.

For instance, S = 7 mod 5, which implies S = T + I ×M

Table 5.1 A Collection of S (S = 7 mod 5)

I - 1 0 1 2 3 4
S 2 7 12 17 22 27

The smallest positive number in the collection of S is known as the least positive residue. This table has the least positive residue equal to 2.

5.1.1 Congruential Generators

Congruent methods are generally based on following:

X (^) i  1 ( aXic )(mod m ), i  1 , 2 , , n. (5.6)

Where, the multiplier a, the increment c,

and the modulus m are nonnegative integers.

The modulo notation ( mod m) means that

X (^) i  1 ( aXicmki ), (5.7)

where, ki =[( a Xi + c ) / m ] denotes the largest positive integer in (aXi+ c)/m.

Given an initial starting value Xo. It is also called the seed.

Equation 5.6 yields a congruence relationship (modulo m) for any value i of the sequence { Xi }.

Generators that produce random numbers according to above equation are called mixed congruent generators.

5.2 How to Generate a Random Variable

Let us now consider some procedures for generating random variable values from different known distributions.

These procedures are based on the following three methods:

inverse transform method,composition method, andacceptance-rejection method.

Some Known frequency distributions as probability distribution functions

UNIFORM Distribution:

The u is a uniform deviate with probability density function of the following form:

    ,

0 1

0

1 , ( ) otherwise

u f u (5.12)

It remains fixed over the range [0, 1] and goes to zero after the range.

It is also termed a pulse of fixed height and duration.

EXPONENTIAL Distribution:

The v is a standard exponential deviate with probability density function of the following form:

otherwise ,

e , v

g(v)

v 0

It is a rapidly decreasing function as the value of v is allowed to increase.

5.2.1 Inverse Transform Method

We present the procedure to a continuous problems, where a random variable x can take any value between a given interval (say a < x < b ). Let the p(x)dx is the probability that x falls in dx interval about x. The function p(x) is called the probability distribution and satisfies the following:





p(x)dx  1. (5.15)

Then we define F(x) as a cumulative probability distribution as following:

 

x F(x) P(w) dw. (5.16)

The value of x is determined with given F(x) and a random number  such that

 = F(x) (5.17)

The procedure is illustrated in Fig. 5.5. Here, we are given with a random number and a curve F(x) as a function of x in the domain, then the value of x is decided by

equation for  and F(x). The method has been applied to several frequency

distributions in following examples.

Figure 5.5 The decision of x by a random numberin the range [0, 1] and accumulative probability distribution.

0.0 0.5 1.0 1.5 2.0 2.5 3.

0.

0.

0.

0.

0.

1.

x

F(x)

Example 5.

For a typical exponential distribution, what is procedure to find the random variate?

Solution: An exponential variate X has the following probability distribution function:

  otherwise ,

e , x , f(x)

x / 0 0

0

By inverse transform method, we have the F(X) as

U  F(X) 1  ex/

so that X  ln( 1 U).

Since 1 – U is distributed in the same way as U, we have the X as following:

X ln(U).

For sampling purposes we may assume,  = 1: if V is sampled from the standard exponential distribution exp(1) then X = V is from exp(). We can write the following algorithm for the process:

 Generate U from u(0, 1).  Then compute : X  ln(U).  Finally, output the value of X.

Although this technique seems very simple, the computation of the natural logarithm on a digital computer includes a power series expansion (or some equivalent approximation technique) for each uniform variate generated. Common applications of Monte Carlo methods in simulation of real systems will be done in detail using above procedures in next sections.