Basics of Modelling and Simulation
Basics of Modelling and Simulation
Basics of Modelling
and Simulation
RANDOM
NUMBER
RANDOM NUMBER
Random Number can be defined as numbers that show no consistent pattern, with
each number in a series and are neither affected in any way by the preceding number,
nor predictable from it.
One way to get random digits is to simply start with an arbitrary number with a
specified number of digits, for example 4 digits.
The result is a series of digits that appear randomly distributed as though generated
by throwing a die or spinning a wheel. This type of algorithm is called a congruential
generator.
RANDOM NUMBER
Generating a random number series from a single seed works fine with most
simulations that rely upon generating random events under the control of
probabilities (Monte Carlo simulations). However, although the sequence of
numbers generated from a given seed is randomly distributed, it is always the
same series of numbers for the same seed. Thus, a computer poker game that
simply used a given seed would always generate the same hands for each player.
One way to do this is to read the time (and perhaps date) from the computer‘s
system clock and generate a seed based on that value. Another common
technique is to use the interval between the user‘s keystrokes (in milliseconds).
The so-called true random number generators extract random numbers from
physical phenomena such as a radioactive source or even atmospheric noise as
detected by a radio receiver.
PSEUDORANDOM
NUMBER
GENERATION
Pseudorandom number generation
Pseudorandom numbers are generated by deterministic algorithms. They are
"random" in the sense that, on average, they pass statistical tests regarding
their distribution and correlation. They differ from true random numbers in that
they are generated by an algorithm, rather than a truly random process.
What we usually do is to take for instance ten pieces of papers and number
them 0,1,2,3,4,5,6,7,8, and 9 , fold and place them in a box. Shake the box and
thoroughly mix the slips of paper. Select a slip; then record the number that is
on it. Replace the slip and repeat this procedure over and over. The resultant
record of digits is a realized sequence of random numbers. Assuming you
thoroughly mix the slips before every draw, the nth digit of the sequence has an
equal or uniform chance of being any of the digits 0, 1, 2,3,4,5,6,7,8, 9
irrespective of all the preceding digits in the recorded sequence.
RANDOM
NUMBERS IN
COMPUTER
Random numbers in computer
The RAND Corporation using specially designed electronic equipment, to
perform the experiment, actually did generate a table of a million random
digits. The table can be obtained on tape, so that blocks of the numbers can
be read into the memory of a high- speed computer, as they are needed.
2. The results of experiments such as the one previously describe above are
published in books of statistical tables. In hand simulation, it may be
appropriate to use a published table of random numbers.
FOR K% = 1 TO 5
END
END
SIMULATING
RANDOMNESS
Simulating randomness
Suppose we want to simulate the throwing of a fair die. A random
number between 0 and 1 will not always satisfy our needs. If the die is
fair, throwing it several times will yield a series of uniformly distributed
integers 1,2,3,4,5 and 6. Consequently we need to be able to generate
a random integer with values in the range 1 and 6 inclusive.
Now the function RND generates a random number between 0 and 1.
Specifically, the random variable X is in the range: 0 < X < 1
The expression X = RND *6
Will generate a number in the range: 0 < X < 6
We must convert these numbers to integers as follows: X% = INT
(RND*6)
The expression produces an integer in the range: 0 < X < 5
Simulating randomness
But we need the range: 0 < X < 6
Therefore if we need to add 1 to the above expression in
simulating the tossing of a die. Thus,
X% = INT (RND*6) + 1
In general, to generate a random integer between P and N we
use the expression:
INT(RND*N+1-P) + P;
where N>P
While for integer number between 0 and N – 1 we use the
expression INT (RND *N).
PROPERTIES OF A
GOOD RANDOM
NUMBER
GENERATOR
Properties of a Good Random Number
Generator
The random numbers generated should;
a. have as nearly as possible a uniform distribution.
b. should be fast
c. not require large amounts of memory.
d. have a long period.
e. be able to generate a different set of random numbers or a
series of numbers.
f. not degenerate.