0% found this document useful (0 votes)
2 views5 pages

Simulation Lecture Notes1a

Simulation is the process of creating a model of a complex environment to analyze its performance and draw conclusions for system redesign. It involves various types of models, such as dynamic vs. static and stochastic vs. deterministic, and utilizes random numbers for simulating events. Pseudo-random number generators are used to produce random integers based on a defined formula and seed value.

Uploaded by

ali chitumu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views5 pages

Simulation Lecture Notes1a

Simulation is the process of creating a model of a complex environment to analyze its performance and draw conclusions for system redesign. It involves various types of models, such as dynamic vs. static and stochastic vs. deterministic, and utilizes random numbers for simulating events. Pseudo-random number generators are used to produce random integers based on a defined formula and seed value.

Uploaded by

ali chitumu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

SIMULATION

Defn:
Simulation involves building a model of a complex environment, letting the model operate as if it were
real, examining its performance, possibly changing parameters so as to compare performance in
different circumstances and then drawing conclusions. The conclusion may be used to redesign the
actual system been modeled.

Example of a Complex Queuing System to be Simulated

Queuing in a Hospital

Q Doctor Q X-Ray

Doctor Q Lab
Exit Point

Q Consultant Optal Accts

Q Registry
Q

Q
Q Pharmacy
Entry Point

The above system is a very complex system, and we may have to study it to make it efficient. This is
done by;
a) Minimizing Idle Time: Those offering service are kept busy so long as there are people needing
attention.
b) Maximizing Through-put: There should be no unnecessary waste of time resulting from badly
organized queues or poor layout.

Types of Models
1. Dynamic or Static:
Dynamic means that the system may alter its structure in some ways e.g. another staff at a new service
point managing a queue.
Static means that a system change cannot take place or is not allowed, while the system is active; e.g. a
man driving a car cannot change the driver when the car is in motion.

2. Stochastic or Deterministic:
In a stochastic model, events occur at random. It is not known in advance exactly when an event will
occur, eg. the outcome of the throw of a die, or in a bank queue, no one knows in advance how long it
will take to service a particular customer.

1
In a deterministic model, we know in advance what should be done, e.g. a machinist at a drilling
machine may receive parts, drill a hole in each and pass it on. The processing time may be known or
estimated, eg. 1min.

3. Continuous or Discrete:
In a continuous case, we deal with events that are measured events that are measured with real
numbers. The data are obtained mostly by measuring and approximating. eg. height, weight, length or
rocks been delivered by a conveyor belt to a crushing machine.
In discrete cases, we deal with events that occur one at a time. The data are obtained mostly by
counting, eg. customers arriving to join a queue in a bank.

In queuing theory and Inventory management, our systems have been static, stochastic and discrete.
When we have a dynamic, deterministic and continuous system, we are faced with a problem. These
events are random in nature. In order to simulate random events, we need what is called Random
Numbers.

Random Numbers in Simulation


Defn: Random numbers are numbers that occur in a sequence such that two conditions are met: (1) the
values are uniformly distributed over a defined interval or set, and (2) it is impossible to predict future
values based on past or present ones. Random numbers are important in statistical analysis and
probability theory.
The most common set from which random numbers are derived is the set of single-digit decimal
numbers {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}

Sources of Random Numbers


(a) Statistical Tables: Many statistical tables have a table of random digits. These are digits from 0 –
9 laid out in random order in large numbers.

(b) Calculators: Some calculators will produce random numbers at the push of a button; i.e.
Shift+Rand# or Shift+Rnd or Rnd or Rand produces a three decimal place number between zero and 1;
e.g. 0.617, 0.124 etc.

(c) Programming Language: There are programming language codes with random number functions
that are used to generate random numbers. Example is the Basic language, which has the Rnd function
that returns a random number between 0 and 1. e.g.
Dim i as Integer
For i = 1 to 10
Print Rnd
Next i

This displays 10 random numbers, each between 0 and 1. e.g.


0.37126, 0.14299, 0.87432, 0.56911 etc.

Example:
Suppose we want to simulate the throw of a die, we use the formula;

2
Int(Rnd*6) + 1

Rnd is a method from basic that returns a random number in the range [0,1].

0 ≤ Rnd < 1
6 * 0 ≤ 6* Rnd < 1 * 6
0 ≤ 6*Rnd < 6
Int(0) ≤ Int(6*Rnd) < Int(6)
0 ≤ Int (6*Rnd) < Int(6)
0 ≤ Int (6*Rnd) ≤ 5
1 ≤ Int (6*Rnd) + 1 ≤ 6

Therefore, Int (6 * Rnd) + 1 will return a whole number from the set [1,2,3,4,5,6]. This expression can
be used to simulate the throw of a die.

E.g.:
i. For i = 1 to 10
Print Int (6 *Rnd) + 1; “, “;
Next i
Output: 2, 5, 4, 2, 6, 2, 1, 2, 6, 3
The above simulates 10 throws of a die.

ii. Dim as Integer die1, die2, dice


For i = 1 to 10
die1 = Int (6 * Rnd) + 1
die2 = Int (6 * Rnd) + 1
dice = die1 + die2
Print dice
Next i

The above program simulates the throw of two dice and sums the results.
“Rnd” is an example of a Pseudo-random number generator. e.g. In Java
[Link] Int()
[Link] Float()
[Link] Double()

These are static methods from the class Random

Pseudo-random Number Generator


A Pseudo-random number generator is a method which works recursively to produce random integers
in the range 0 to (m-1), where ‘m’ is a division and the random number is the remainder.
An example of a formula for a particular type of pseudorandom number generator is given by;
x n+1=a x n ( mod m )
where ‘a’ and ‘m’ are integers. This means that x n+1is the remainder when ax n is divided by m.

3
In Basic notation, it is; x(n+1) = (x(n)*a)mod m
In Java, it is; x[n+1] = (x[n]*a)%m

We then use a starting value x 0, which is called the SEED of a pseudo-random to begin the generation,
where 0< x 0 < m−1.
The Seed of a pseudorandom number generator is an arbitrary initial or starting value x 0 , used to begin
the generation of pseudorandom numbers.

E.g.:
Given that a = 151, m = 1023, calculate 5 random numbers starting with a seed value of 900.

Soln:
x n+1=a x n ( mod m ) n = 0,1, 2, 3, 4, 5; x 0=900

x 1=a x 0 ( mod m )
x 1=151 ×900(mod 1023)
= 135900 (mod 1023)
= 132 Rem 864
x 1=864

x 2=a x 1 ( mod m )
x 2=151 ×864 (mod 1023)
= 130464 (mod 1023)
= 127 Rem 543
x 2=543

x 3=a x 2 ( mod m )
x 3=151 ×543(mod 1023)
= 81,993 (mod 1023)
= 80 Rem 153
x 3=153

x 4 =a x 3 ( mod m )
x 4 =151×153 (mod 1023)
= 23,103 (mod 1023)
= 22 Rem 597
x 4 =597

x 5=a x 4 ( mod m )
x 5=151 ×597(mod 1023)
= 90,147 (mod 1023)
= 88 Rem 123
x 5=123

4
SIMULATION TECHNIQUES

You might also like