Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 15

Random Number Generation

Random Number
• Random numbers are a necessary basic ingredient
in the simulation of almost all discrete systems.
Most computer languages have a subroutine,
object, or function that will generate a random
number. Similarly simulation languages generate
random numbers that are used to generate event
limes and other random variables.
Properties of Random Numbers
• A sequence of random numbers, W1, W2, .. , must have two
important statistical properties, uniformity and independence.
Each random number Ri, is an independent sample drawn
from a continuous uniform distribution between zero and 1.
• Some consequences of the uniformity and independence
properties are the following:
• 1. If the interval (0,1) is divided into n classes, or subintervals
of equal length, the expected number of observations m each
interval is N/n where A' is the total number of observations.
• 2. The probability of observing a value in a particular interval is
of the previous values drawn
GENERATION OF PSEUDO-RANDOM
NUMBERS
• Pseudo means false, so false random numbers are
being generated. The goal of any generation
scheme, is to produce a sequence of numbers
between zero and 1 which simulates, or imitates,
the ideal properties of uniform distribution and
independence as closely as possible.
• When generating pseudo-random numbers, certain
problems or errors can occur. These errors, or
departures from ideal randomness, are all related to
the properties stated previously.
ERRORS, OR DEPARTURES FROM IDEAL
RANDOMNESS
1.The generated numbers may not be uniformly distributed.
2.The generated numbers may be discrete -valued instead
continuous valued
3.The mean of the generated numbers may be too high or too low.
4.The variance of the generated numbers may be too high or low
5.There may be dependence. The following are examples:
• (a)Autocorrelation between numbers.
• (b)Numbers successively higher or lower than adjacent numbers.
• (c) Several numbers above the mean followed by several numbers
below the mean.
• Usually, random numbers are generated by a digital computer as
part of the simulation.
Considerations for Random Number
Generation Methods
• Numerous methods can be used to generate the values. In
selecting among these methods, or routines, there are a number
of important considerations.
1. The routine should be fast. . The total cost can be managed by
selecting a computationally efficient method of random-number
generation.
2. The routine should be portable to different computers, and
ideally to different programming languages .This is desirable so that
the simulation program produces the same results wherever it is
executed.
3. The routine should have a sufficiently long cycle. The cycle length,
or period, represents the length of the random-number sequence
before previous numbers begin to repeat themselves in an earlier
order
Considerations for Random Number
Generation Methods…….
4. The random numbers should be replicable. Given
the starting point (or conditions), it should be possible
to generate the same set of random numbers,
completely independent of the system that is being
simulated. This is helpful for debugging purpose and is
a means of facilitating comparisons between systems.
5. Most important, and as indicated previously, the
generated random numbers should closely
approximate the ideal statistical properties of
uniformity and independences
METHODS
1. Random number may be drawn from the random
number table stored in the memory of the
computer. This process, however, is neither practical
nor economical. It is a very slow process and the
numbers occupy a large portion of the computer
memory. Even on methodological ground it is
objectionable to use the same set of random
numbers again and again. Therefore, several
methods of generating random numbers internally
by the computer have been evolved. The necessary
formulae occupy relatively little space.
METHODS

• An electronic device may be constructed as


part of the digital computer to generate true
random numbers. The method however is
expensive.
METHODS
Mid-square method: In mid-square method of
generating pseudo-random numbers, a four digit
number is taken. By squaring it a high digit figure is
obtained from which the middle four digits are
picked. This yields the second random number and
the process is repeated and a sequence of pseudo-
random numbers is obtained. For example, if
Limitations of

• The series may vanish because a random number


obtained is . 0000
• A random number reproduces itself. For example, .
X7=8625 , X8=8625, X9=8625
• A loop occurs, for example X11=6100 , X12=8100,X13= 4100,
X14=2100, X15=6100 , and the circle continues in a circle.
• This method is slow since many multiplications and
divisions are required to access the middle digits in a fixed
word binary computer.
METHODS

• Pseudo-random numbers may also be


generated by arithmetic operations .A
frequently used method is the congruence
method or the residue method, which ids
described by the expression :
• X i+1 = (ari +b)(modulo m) ………………(1)
• Where a, b and m are constants and ri, ri+1 are
the ith and (i+1)th random numbers. The
expression implies multiplying of a by r,
addition of b and then dividing by m .Then, ri+1
is remainder or residue. To begin the process
of random number generation, in addition to
a, b and m, the value of r0 is also required. It
may be random number and is called seed
• The congruence random number generator
may be of the additive, multiplicative or mixed
type.
• Additive = X i+1 = a+ri (modulo m)
• Multiplicative= X i+1 = ari (modulo m)
• Mixed= X i+1 = (ari +b)(modulo m)
ILLUSTRATIONS
• Refer to Word document

You might also like