Simulation and Modelling Complete Notes
Simulation and Modelling Complete Notes
System concept
• System is an assembly of components used within one business unit, working together
for some purpose.
• Also, a system is a group of interrelated components working together to achieve
common goal by accepting inputs and producing outputs in an organized transformation
process.
• A system exists and operates in time and space ; bounded inside system boundary.
System – Terms:
i. State
A variable characterizing an attribute in the system such as no. of jobs waiting
for processing.
ii. Activity/event
An occurrence at a point in time which may change the state of the system
- Endogenous – activities occurring within the system
- Exogenous – activities occurring in the environment that affect the system
iii. Entity
An object that passes through the system e.g. cars .Entity is associated with an
event.
iv. Queue
- physical queue of entity/task
- any place where entities are waiting for something to happen for any reason
v. Creating
Causing an arrival of a new entity to the system at some point in time
vi. Scheduling
The act of assigning a new future event to an existing entity.
vii. Random variable
A random variable is a quantity that is uncertain, such as inter-arrival time
between two incoming flights or number of defective parts in a shipment.
viii. Random variate
A random variate is an artificially generated random variable.
ix. Distribution
A distribution is the mathematical law which governs the probabilistic features
of a random variable.
Characteristics of System:
i. Organization
• structure and order
• Example: Hierarchical organization in a company.
• Computer system: organization of various components like input devices,
output devices, CPU and storage devices
ii. Interaction
• Between sub systems or the components
• Example: the main memory holds the data that has to be operated by the
ALU.
iii. Interdependence
• Component linkage
• Component dependence
iv. Integration
•How subsystems are tied together to achieve the system objective
v. Central Objective
• Should be known in early phases of analysis
System – Simple Example:
Building a simulation of a gas station with a single pump served by a single service
man. Assume that arrival of cars as well their service times are random.
At first identify:
states: number of cars waiting for service and number of cars served at any moment
events: arrival of cars, start of service, end of service
entities: these are the cars
queue: the queue of cars in front of the pump, waiting for service
random realizations: inter-arrival times, service times
distributions: we shall assume exponential distributions for both the inter-arrival time
and service time
• Two types:
- Formal Information System: Based on the organization
representation by organization chart. Information is distributed in the
form of memos or reports , instruction from top level to intended user.
-Informal Information System: Employee based system where
problem can be solved with in the circle. e.g: casual conversation,
message on social media or blogs, etc.
v. Continuous and Discrete system
• A continuous system is one in which the state variable(s) change
continuously over time. E.g. the amount of water flow over a dam.
• A discrete system is one in which the state variable(s) change only
at a discrete set of points in time. E.g. customers arrive at 3:15, 3:23,
4:01, etc.
MODELS
PHYSICAL MATHEMATICAL
SYSTEM SIMULATION
activities are represented by mathematical functions that interrelate the variables. Similarly,
statically and dynamically both physical and mathematical models are further divided.
Static models can only show the values that system attributes take when the system is in
balance. However, dynamic follow the changes over time that result from the system activities.
In mathematical models, a third distinction is the technique by which the model is “solved”
that means analytical and numerical methods. The technique that uses deductive reasoning of
mathematical theory to solve a model is known as analytical method. In practice, only certain
forms of equations can be solved. In some cases, an exact solution can be derived and a result
can be obtained in various conditions. The beauty of the analytical model is that it provides a
generic way to get performance results in various conditions through a mathematical
formulation. For example, linear differential equations can be solved.
The technique that applying computational procedures to solve equations is known as
numerical methods. Numerical methods are used when analytical or symbolic approaches to
solving math problems are computationally difficult. For example, the solution may be derived
in the form of a complicate integral which then needs to be expanded as a power series of
evaluation. Also system simulation is considered to be a numerical computation technique used
𝑏
in conjunction with dynamic mathematical models. Example: A definite integral ∫𝑎 𝑓(𝑥) dx
can be solved either analytically (i.e. symbolically) or numerically.
Static physical models vs Dynamic models
• The best known examples of physical • Dynamic physical models rely upon an analogy between the system
being studied and some other system of a different nature, the
models are scale models. analogy usually depending upon an underlying similarity in the
• In shipbuilding, making a scale model forces governing the behavior of the systems.
• To illustrate this type of physical model, consider the two systems
provides a simple way of determining the shown in following figures i.e. Figure a and Figure b.
exact measurements of the plates covering
the hull, rather than having to produce
drawings of complicated, three-
dimensional shapes.
• Scale models are also used in wind tunnels
and water tanks in the course of designing
aircraft and ships. Figure: (a) Mechanical System (b) Electrical System
• Although air is blown over the model, or • The Figure a. represents a mass that is subject to an applied force
F(t) varying with time, a spring whose force is proportional to its
the model is pulled through the water, extension or contraction, and a shock absorber that exerts a damping
these are static physical models because force proportional to the velocity of the mass.
• The system might for example represent the suspension of an
the measurements that are taken represent automobile wheel when the automobile body is assumed to be
attributes of the system being studied immobile in a vertical direction.
• It can be shown that the motion of the system is described by the
under one set, equilibrium conditions. following differential equation.
• In this case, the measurements do not 𝑀𝑥" + 𝐷𝑥′ + 𝐾𝑥 = 𝐾𝑓(𝑡)
Where, x is the distance moved, M is the mass, K is the stiffness of
translate directly into system attribute the spring, D is the damping factor of the shock absorber
values. • Figure b. represents an electrical circuit with an inductance L, a
resistance R, and a capacitance C, connected in series with a voltage
• Well known laws of similitude are used to source that varies in time according to the function E(t). If q is the
convert measurements on the scale model charge on the capacitance, it can be shown that the behavior of the
circuit is governed by the following differential equation:
to the values that would occur in the real 𝑞 𝐸(𝑡)
system. 𝐿𝑞" + 𝑅𝑞′ + =
𝐶 𝐶
• Sometimes, a static physical model is used • Inspection of these two equations shows that they have exactly the
same form.
as a means of solving equations with • The mechanical system and the electrical system are analogs of each
particular boundary conditions. other, and the performance of either can be studied with the other.
• There are many examples in the field of • In practice, it is simpler to modify the electrical system than to
change the mechanical system, so it is more likely that the electrical
mathematical physics where the same system will have been built to study the mechanical system.
equations apply to different physical • If, for example, a car wheel is considered to bounce too much with a
particular suspension system, the electrical model will demonstrate
phenomena. this fact by showing that the charge (and, therefore, the voltage) on
• For example, the flow of heat and the the condenser oscillates excessively.
• To predict what effect a change in the shock absorber or spring will
distribution of electric charge through have on the performance of the car, it is only necessary to change the
space can be related by common values of the resistance or condenser in the electrical circuit and
observe the effect on the way the voltage varies.
equations.
Static Mathematical Model vs Dynamic Mathematical Model
• A static model gives the relationships between the system • A dynamic mathematical model allows the changes of system
the system attributes when the system is in equilibrium. attributes to be derived as a function of time.
• If we alter the attribute values , the point of equilibrium • The derivation may be made with an analytical solution or with a
also changed , the model enables the new values for all the numerical computation, depending upon the complexity of the
attributes to be derived but does not show the way in which model.
they changed to their new values. • The equation that was derived to describe the behavior of a car
• For example, in marketing a commodity there is a balance wheel is an example of a dynamic mathematical model; in this
between the supply and demand for the commodity. case, an equation that can be solved analytically.
• It is customary to write the equation in the form:
𝑥" + 2𝜏𝜔𝑥′ + 𝜔2 𝑥 = 𝜔2 𝐹(𝑡)
𝐷 𝐾
𝑤ℎ𝑒𝑟𝑒 2𝜏 𝜔 = 𝑎𝑛𝑑 𝜔2 =
𝑀 𝑀
• Expressed in this form, solutions can be given in terms of the
variable wt. Figure.6 shows how x varies in response to a steady
force applied at time t = 0 as would occur, for instance, if a load
were suddenly placed on the automobile.
• Solutions are shown for several values of 𝜏 , and it can be seen that
• Both factors depend upon price: a simple market mode! when 𝜏 is less than 1, the motion is oscillatory.
will show what is the price at which the balance occurs.
• Demand for the commodity will be low when the price is
high, and it will increase as the price drops.
• The relationship between demand, denoted by Q, and
price, denoted by P, might be represented by the straight
line marked "Demand“ in Figure c.
• On the other hand, the supply can be expected to increase
as the price increases, because the suppliers see an
opportunity for more revenue.
Figure d: Solutions of second-order equations.
• Suppose supply, denoted by S, is plotted against price, and
• The factor 𝜏 is called the damping ratio and, when the motion is
the relationship is the straight line marked "Supply" in
Figure c. If conditions remain stable, the price will settle oscillatory, the frequency of oscillation is determined from the
to the point at which the two lines cross, because that is formula.
where the supply equals the demand. 𝜔 = 2𝜋𝑓 Where f is the number of cycles per second.
• Since the relationships have been assumed linear, the • Suppose a case is selected is representing a satisfactory frequency
complete market model can be written mathematically as and damping. The relationship given above between 𝜏, ω ,M, k and
follows: D show how to select the spring and shock absorber to get that type
Q=a-bP of motion. For example the condition for the motion to occur
S=c+dP without oscillation requires that 𝜏 ≥1. It can be deduced from the
S=Q definition of that the condition requires that D2≥4MK.
• The last equation states the condition for the market to be
cleared; it says supply equals demand and, so, determines
the price to which the market will settle.
• For the model to correspond to normal market conditions
in which demand goes down and supply increases as price
goes up the coefficients b and d need to be positive
numbers.
• For realistic, positive results, the coefficient a must also be
positive. Figure 4 has been plotted for the following values
of the coefficients:
a=600
b=3000
c=-100
d=2000
• The fact that linear relationships have been assumed
allows the model to be solved analytically. The
equilibrium market price, in fact, is given by the following
expression:
𝑎−𝑐
𝑃=
𝑏+𝑑
• With the chosen values, the equilibrium price is 0.14,
which corresponds to a supply of 180.
Finished Products
Raw Materials
Purchasing dept Fabrication dept Assembly dept Shipping dept
ii. Relevance : The model should only include those aspects of the system that are
relevant to the study objectives. As an example, if the factory system study aims to
compare the effects of different operating rules on efficiency, it is not relevant to
consider the hiring of employees as an activity.
iii. Accuracy: The accuracy of the information gathered for the model should be
considered. In the aircraft system , for example , the accuracy with which the
movement of the aircraft is described depends upon the representation of the airframe.
iv. Aggregation: A further factor to be considered is the extent to which the number of
individual entities can be grouped together into larger entities. The production control
manager, however, will want to consider the shops of the departments as individual
entities.
Similar considerations of aggregation should be given to the representation of the
activities. For example, in studying a missile defense system , it may not be necessary
to include the details of computing a missile trajectory for each firing.
Assignment:
1. Explain about calibration, verification and validation of model.
2. Steps of Simulation Study
1|Page
• The function f(x) is contained with the rectangle with sides c and (b-a)
• Now , pick some points(N) at random within the rectangle and determine whether they
lie beneath the curve or not.
• The fraction of points falling on or out of the curve should be approximately the ratio
of the area under the curve to the area of rectangle.
𝑛 𝑏 𝑓(𝑥)𝑑𝑥
Then, approximately: = ∫𝑎
𝑁 𝑐(𝑏−𝑎)
where, N is total random points
n is points fall under curve
𝑛 𝑏
Now ,
𝑁
𝑐(𝑏 − 𝑎) = ∫𝑎 𝑓(𝑥)𝑑𝑥
• For each point, value of x is selected at random between a and b say x0 and at random
between 0 and c say f(x0)=y.
• If y≤ f(x0) the point is accepted in the count n , otherwise it is rejected and the next
point is picked.
• Monte Carlo is another name for statistical sampling methods of great importance to
physics and computer science.
Advantages:
• It is used to analyze complex and large practical problems when it is not possible to
solve them through a mathematical method.
• In simulation, the experiments are carried out with the model without disturbing the
system.
• Policy decisions can be made much faster by knowing the options well in advance and
by reducing the risk of experimenting in the real system.
Disadvantages:
• Simulation doesn't generate optional solutions.
• It may take a long time to develop a good simulation model.
• In certain cases simulation models can be very expensive.
• Simulation doesn't give the answers by itself so, decision-maker must provide all
information about the constraints and conditions for examination.
2|Page
Examples:
3|Page
4|Page
Case 1:
When system exhibits chaotic behavior and hard to precisely get accurate answer , then called
problem is deterministic but can't model it deterministically. Example 1: A double pendulum.
We have mathematical model of this but our measurements of the initial state of the pendulum
may have slight errors. We could use Monte Carlo simulation, modelling the measurement
error as a random variable, to predict what state the pendulum is most likely to be in a future
point in time. Example 2: let’s take the example of an aircraft engine. Failures happen for
essentially deterministic reasons (e.g. heat, mechanical strain, leading to degradation, cracking
and then failure), but we generally don’t know enough to create an accurate model of these
deterministic behaviors. We can, however, make a model of likely failure modes, and use
historical data to assign probabilities to these, in order to predict failure using Monte Carlo
simulation.
Case 2:
Example: Aircraft engines can catastrophically fail due to “foreign objects” (often birds!)
entering the intake while it is running - referred to as FOD. Failures due to FOD are essentially
random, but we have pretty good data on the probability of it happening. If we want to
understand how many spare engines to hold in case of breakdown (including these random
FOD) events we might use Monte Carlo simulation where FOD and other breakdown events
happen randomly, at different times, and we observe how many spares are needed in order to
always have a high likelihood of having enough in store in case of breakdown
Comparison Of Simulation and Analytical Method:
Both simulation and analytical methods are modeling approaches which aim is providing an
idea of system performance, in different condition.
Analytic method is a mathematical abstraction method that can be extended to address various
working conditions. An exact solution can be derived and a result can be obtained in various
conditions. Also it provides a generic way to get performance results in various conditions
through a mathematical formulation.
5|Page
A simulation method such as a Monte-Carlo also make assumption of a model and some
assumption about the behavior of the process. It is used when an analytical formulation cannot
be derived ( For example when the size of the model is too large or when no exact solution can
be derived). Simulation models provide results for a specific use case and should be run many
times to counter balance the effect of numerical calculations.
Compared with analytical solution of problems, the main drawback of simulation is apparent:
it gives specific solutions rather than general solutions. Example: In the study of automobile
wheel motor, an analytical solutions gives all the conditions that cause oscillation . But each
execution of simulation tells only whether a particular set of conditions did or didn't cause
oscillation . To try to find out all such conditions requires that the simulation be repeated under
many different condition.
6|Page
Suppose the price of cigarettes has been constant for a long time at a level p, so that p =
pt =pt-1 = pt-2, = …. Then the quantity of cigarettes demanded per unit time will also be a
constant:
Now let the price of cigarettes change from p to p +Δp in period t + 1 and remain at this new
level indefinitely. The effect of the change in period t + 1 will be to change the quantity
demanded from q to q + b0Δp. But the effects of the price change do not stop here; in the next
period, t + 2, the quantity demanded is further altered to q + b0Δp b1Δp . In general, after θ
periods, the change in q will be Thus, the effect of the change in price on demand is distributed
over time: b0Δp the first period, b0Δp + b1Δp the second, and so on.
Econometric models of this nature have been built for the national economies of most of the
major industrial countries. Many large corporations also use models reflecting the effects of
the national economy on their industry.
Example: Find the growth in national consumption for five years using the model given
.Assume the initial income Y-1 is 80 and take expenditure in the 5 years to be as follows:
Years G(Government Expenditure)
1 20
2 25
3 30
4 35
5 40
7|Page
Cobweb Model:
• Cobweb Model or Cobweb Theory was first analyzed by Nicholas Kaldor in 1934
named as "Cobweb Theorem".
• Cobweb Model or Cobweb Theory is an economic model based on the idea that price
fluctuations can lead to fluctuation in supply which cause falling and rising in price .
Also explains why prices might be subject to periodic fluctuations in certain types of
markets
• It describes cyclical supply and demand in a market.
8|Page
9|Page
10 | P a g e
11 | P a g e
• The simulation clock is then advanced and statistics of performance measures are
collected.
Two Categories:
1. Discrete Time Simulation(DTS) model (fixed time advances Or time-step)
2. Discrete Event Simulation(DES) model (next event time)
DTS (fixed time advances Or time-step)
• In this model time unit is defined .
• Simulation clock advances a specified unit of time ∆ t for representing exact
increment.
• While upgradation in the further process in simulation clock, it examines the event
list to identify the possible occurrence of any event in past period of time ∆t.
• If one or more events were occurred during the previous interval then those events
are considered to occur at the end of the interval at system state.
• If the system is time driven, DTS is better. Also called synchronous model.
DES (next event time)
• Mapping of system that represents the variation of variables instantaneously in the
dynamic system over a period of time.
• Simulation Clock is varies according to the occurrence of events and facilitates the
initial worth of stimulated time on the basis of current events.
• It is better for event driven system.
• DES estimates the time for futuristic events on the basis of a list of events.
• Clock advances to next (most initialize simulated clock to 0) imminent event ,which
is executed.
• Also update the event list after event execution.
• Continue until stopping rule is satisfied.
• Clock jumps from one period of time to the next and period of inactivity are ignored.
Components of DES
• System state: Collection of state variables to describe the system state.
• Simulation clock: A variable giving the current value of stimulation time.
• Event list: A list containing the next time when each type of event will occur.
• Statistical counter : To accumulate quantities for output
• Initialization routine : Initialize the clock at 0
• Timing routine: Determine next event time, advancing the clock
• Event routine : Carry out logic for each event type.
• Library routines: Utility to generate random variants.
• Report generator and Main Program
12 | P a g e
Departure routine:
13 | P a g e
Lets simulate "Airport System" having single runway(i.e. Single Server Queue)
Conceptualize Model:
• Customer (aircraft)
Entities utilizing the resource
• Server(runway)
Resource that is serially reused
• Queue
Buffer holding aircraft waiting to land
14 | P a g e
Events(Types):
• Events: aircraft arrival, landing, departure
• An event must be associated with any change in the state of the system.
Event 1: Aircraft Arrival
(InTheAir, RunwayFree)
Event 2: Aircraft Landing
(InTheAir, OnTheGround, RunwayFree)
Event 3: Aircraft Departure
(OnTheGround)
Output Statistics:
Compute:
• Maximum number of aircraft on the ground
➢ OnTheGround: indicate the number of aircraft currently on ground
➢ Maximum “on the ground” =Max(OnTheGround)
• Average Waiting Time:
➢ Waiting time for each aircraft: wti = ArrivalTime –LandingTime
➢ Total sum of all waiting times: wttotal = sum(wti)
➢ Total number of aircraft: Ntotal
➢ Average time: wtavg = wttotal/Ntotal
Effect of Time-Advance-Mechanism
• Now a days modeling and simulation becomes more complex, modelers are faced with
mounting challenges to design and analyze simulations that effectively address difficult
problems.
• We have to perform series of empirical studies to characterize and compare the influence
of TAM(DES and DTS).
• The effects of changes in time “step” across a number of vital simulation areas.
15 | P a g e
Application:
• Supermarkets, Banks, Restaurant, Gas station ,ETC ………
Performance Measures
• E[S]: average system (response) time (average time spent in the system)
• E[W]: average waiting time (average time spent waiting in queue(s))
• E[X]: average queue length
• E[U]: average utilization (fraction of time that the resources are being used)
• E[R]: average throughput (rate that customers leave the system)
• E[L]: average customer loss (rate that customers are lost or probability that a customer
is lost)
Characteristics of Queuing Systems
16 | P a g e
Customer population:
• Finite customer population
➢ The number of potential new customers (arrival rate) is affected by the number of
customers already in the system (waiting and been served). i.e. finite number of
customers(e.g. 40, 50 , 100,….).
➢ Example: Total students of section A / B. As the number of students waiting to meet
with the Lecture increases for viva, the population of possible new students
decreases.
• Infinite customer population
➢ The number of potential new customers is not affected by the number of customers
already in the system.
➢ Example: supermarkets, banks , grocery store,……
Arrival Process:
• Arrival process is the distribution that determine how costumers arrive in the system.
• Arrival process is a random aspect and generally based on inter-arrival time of
successive customers.
• Also arrival may occurs differentially (Random, Scheduled, fixed ….)
• Random Arrival – arrival can be at any interval of time i.e. inter-arrival usually
characterized by probability distribution. Where Poisson arrival process (with rate λ),
where An represents the interarrival time between customer n-1 and customer n, and is
exponentially distributed (with mean 1/λ).
• Scheduled Arrival – interarrival times can be constant or constant plus or minus a small
random amount to represent early or late arrivals. E.g: patients to a physician or
scheduled airline flight arrivals to an airport.
• At least one customer is assumed to always be present, so the server is never idle, e.g.,
sufficient raw material for a machine.
Note: Service Process – is the distribution that determines customers processing
time(exponential/deterministic/general,…). The service rate describes the number of
customers serviced during a particular time period . The service time indicates the amount of
time needed to service a customer . Service rates and times are reciprocal of each other and
either of them is sufficient to indicate the capacity of the facility.
Waiting (Queue) Behavior:
• Waiting means a line(queue) and the attitude of the customers entering the queuing
system is known as waiting behavior.
• Classified as : (a) Patient Or (b)Impatient
• Patient: Wait for service until been served, no matter how much customer has to wait
once arrived to the system. E.g: Machines arrived at maintenance shop.
• Impatient: Customers that wait for a certain time in the queue and leave the system
without getting service and shows some impatient Behavior.
➢ Balking: leave when they see that the line is too long.
➢ Reneging: leave after being in the line when it is moving too slowly.
➢ Jockeying: move from one line to a shorter line.
17 | P a g e
System Capacity:
• A limit on the number of customers that may be in the waiting line and being on service.
• Limited capacity, e.g., an automatic car wash only has room for 10 cars to wait in line
to enter the mechanism.
• Unlimited capacity, e.g., concert ticket sales with no limit on the number of people
allowed to wait to purchase tickets.
Queue Discipline:
• Defined as the logical ordering process of customers in a queue that determines which
customer is chosen for service when a server becomes free.
• Queue Discipline types:
➢ FIFO(First In First Out)
➢ LIFO(Last In First Out)
➢ SIRO(Service In Random Order)
➢ SPF(Shortest Processing First)
➢ PR(Service according to Priority)
Types of Queue:
Two types:
• Single Server Queue
• Multiple Server Queue
Single Server Queue:
• Serve one at a time or can make request one at a time ,depends on queue discipline.
• Simply ,queue is a line of customers, where customer at the head of the line get service
from the server.
• Departure after service and arriving customers join the tail of line.
Example: For the following data find the queue Statistics(Time in minutes) : IAT denotes
the inter-arrival time and ST denotes the Service Time. Assume the first customer arrives at
Time t=0. Inter-Arrival Time(IAT): Time between two successive arrival.
18 | P a g e
Solution:
Explanation:
Inter-arrival time(IAT) is time between two successive arrival of customers. Arrival
Time(cumulative sum of IAT) is time of customer arrival. Service Time – time needs to
facilitated, waiting time – time to get service, service time begins – time when customers/jobs
started, Service Time End – time when customer/jobs finished and departure, Time Customer
Spends in System – total time spends in system(Waiting time + Service time) and Time the
system Idle – time that server stay relaxed.
Multiple Server Queue:
• Include more than one server and respond for multiple request at a time. Provide service
to customers/ jobs arriving into queue.
• The model of multiple server system is on parallel fashion , with several similar servers or
with different types of servers.
• In Multiple Server Models include either single queue or multiple queues (i.e. with a
separate queue for every server).
19 | P a g e
Example: A Restaurant System with two service Provider. The Time between service ranges
from 1 to 4 minutes, as shown :
Server1: More experience and can provide service faster. Distribution of service time shown.
Server2:
When servers are idle server1takes the service. If both are busy, the customer goes on queue.
Estimate waiting time for server1 and server2 .
Solution:
First, calculate inter-arrival time distribution.
20 | P a g e
Simulation Table:
Server1=2/24=1/12=0.0833
Server2=14/27 = 0.51
Average Time between arrivals = Sum of all times between arrivals/ number of arrivals -1=24/9=2.66
Average Waiting Time those who waits = Total time customer wait in queue/total number of customer
who waits = 2/2=1
21 | P a g e
Average Waiting Time customer spends in the system = Total time customer spends in the system / total
number of customer = 40/10=4
Queues models:
Kendall Notation:
• D.G Kendall introduced in 1953 a three-factor shorthand notation to characterize a
range of queuing models.
• The three-factor notation is A/B/C, where
➢ A: specifies the interarrival time distribution
➢ B: specifies the service time distribution
➢ C: specifies the number of parallel servers
• The notation has since been extended to include up to six different factors. A notation
system for parallel server queues: A/B/c(/N/K/X).
• The First three parameters are typically used, unless specified
➢ A represents the interarrival-time distribution,
➢ B represents the service-time distribution,
➢ c represents the number of parallel servers,
➢ N represents the system capacity,
➢ K represents the size of the calling population,
➢ X specifies the service discipline.
Distribution Notation
• M: stands for “Markovian”, implying exponential distribution.
• D: deterministic (e.g. fixed constant)
• Ek: Erlang distribution with parameter K
• G: General (anything)
Kendall Notation Examples(Queue Models):
M/M/1 Queue:
• Poisson arrivals(exponential inter-arrival), and exponential service, 1 server,
infinite capacity and population , FIFO.
• The simplest 'realistic' queue.
M/M/m Queue:
• Poisson arrivals(exponential inter-arrival), and exponential service, but m server,
infinite capacity and population , FIFO.
M/D/1 Queue:
• Poisson arrivals and constant service times, 1 server, infinite capacity and
population, FIFO.
G/G/3/20/1500/SPF:
• General arrival and service distributions, 3servers, 17 waiting jobs(20-3), 1500 total
jobs, Shortest Packet First.
M/M/1 Queue Model
Assumptions
• The easiest waiting line model
• The following assumptions are made:
1. The customers are patient (no balking, reneging, or jockeying) and come from an
infinite population.
22 | P a g e
2. Customer arrivals are described by a Poisson distribution with a mean arrival rate
of (λ). This means that the time between successive customer arrivals follows an
exponential distribution with an average of 1/ λ.
3. The customer service rate is described by a Poisson distribution with a mean service
rate of (µ). This means that the service time for one customer follows an exponential
distribution with an average of 1/ µ.
4. The waiting line priority rule used is first-come, first-served.
5. Note: The service rate must be greater than the arrival rate (µ > λ). If µ ≤ λ the
waiting line would eventually grow infinitely large.
Operating characteristics formulas (Notation):
• λ: mean rate of arrival (number of arrival’s per unit of time)
• µ: mean service rate (average number of customers that can be server per unit of time)
• c: number of servers in parallel
• n: number customers in system
• ρ = λ/(cµ): utilization of the server; also the probability that the server is busy or the
proportion of time the server is busy(number of customers server per unit of time)
• Pn: probability that there are n customers in the system (1- ρ) ρn
• L: mean number of customers in the system (waiting + being served) (ℷ⁄𝜇 − ℷ)
2
• Lq: mean number of customers in the queue ρL=(ℷ ⁄𝜇(𝜇 − ℷ))
• W: mean waiting time or average time spend in the system(waiting + being served)
(1⁄𝜇 − ℷ)
• Wq: mean waiting time in the queue ρW=(ℷ⁄𝜇(𝜇 − ℷ))
𝜇
• Ln : Average length of non-empty queue( ⁄𝜇 − ℷ)
Example 1:
• The computer lab at State University has a help desk to assist students working on
computer spreadsheet assignments.
• The students patiently form a single line in front of the desk to wait for help.
• Students are served based on a first-come, first-served priority rule.
• On average, 15 students per hour arrive at the help desk. Student arrivals are best
described using a Poisson distribution.
• The help desk server can help an average of 20 students per hour, with the service rate
being described by an exponential distribution.
Calculate the following operating characteristics of the service system.
(a) The average utilization of the help desk server
(b) The average number of students in the system
(c) The average number of students waiting in line
(d) The average time a student spends in the system
(e) The average time a student spends waiting in line
(f) The probability of having more than four students in the system
23 | P a g e
solution:
Example 2:
A self-service store employs one cashier at its counter. Nine customers arrive on an average
every 5 minutes while the cashier can serve 10 customers in 5 minutes. Assuming Poisson
distribution for arrival rate and exponential distribution for service time , find:
i. Traffic Intensity
ii. Average number of customers in the system.
iii. Average number of customers in the queue or average queue length.
iv. Average time a customer spends in the system.
v. Average time a customer waits before being served.
Solution: (Example 2)
Given,
arrival rate (λ)= 9/5 customers/minutes = 1.8 customers/minutes = 108 customers/hour
service rate (µ)= 10/5 customers/minutes = 2 customers/minutes = 120 customers/hour
Traffic Intensity/utilization server
ρ = λ/ µ
= 1.8/2=0.9 0r 90%
Average number of customers in the system.
L = λ/( µ- λ)
=1.8/(2-1.8)=9
Average number of customers in the queue or average queue length.
Lq =ρL
= λ2 / µ ( µ - λ)
= 0.9*9 =8.1
Average time a customer spends in the system.
Ws = 1/( µ- λ)
=1/(2-1.8)=5min
Average time a customer waits before being served.
Wq = ρWs
= λ/( µ - λ)
=0.9*5=4.5min
24 | P a g e
Example 3:
A radio repairing person spent time to repair radio sets has exponential distribution with
mean 20 minutes. Radios are repaired on ordered fashion and their arrival is
approximately poison with an average rate of 15 for 8-hour day , find:
i. Traffic Intensity.
ii. How many jobs are ahead of the average set just brought in?
iii. Average number of jobs in the queue or average queue length.
iv. Average time a jobs spends in the system.
v. Average time a jobs waits before being served.
vi. What is the repairman’s expected idle time each day?
Solution: (Example 3)
Given,
mean(m) =20, mean = 1/ µ or 1/ λ
arrival rate (λ)= 15/8*60 radios/minutes = 0.03125
service rate (µ)= 1/20 radio/minutes = 0.05
Traffic Intensity
ρ = 0.03125/ 0.05
=0.625 0r 62.5%
Average number of radios in the system.
L = λ/( µ- λ)
=0.03125/0.01875=1.6666
Average number of radios in the queue or average queue length.
Lq =ρL
= λ2 / µ ( µ - λ)
= 1.04166
Average time a radio needs to spend in the system.
Ws = 1/( µ- λ) =1/(0.05-0.03125)=1/0.01875
=53.333
Average time a customer waits before being served.
Wq = ρWs
= λ/( µ - λ)
=33.333
What is the repairman’s expected idle time each day?
for 8-hour ρ= 8*0.625=5hours
idle time = 8-5= 3hours
Probability distribution:
Poisson Distribution:
• It is statistical tool that helps to predict the probability of certain events from happening
when you know how often the event has occurred within a specified period of time.
• It gives us the probability of a given number of events happening in a fixed interval of
time.
• Can be used to estimate how likely it is that something will happen “X” number of
times.
• Average arrival rate is known.
• Mean arrival rate is constant for some number of time periods.
25 | P a g e
Assignment:
Types of System Simulation
1. Numerical Computation Technique For Continuous Models:
2. Numerical Computation Technique For Discrete Models:
26 | P a g e
CHAPTER 3
Continuous system simulation
Introduction
A continuous system simulation is one, in which predominant activities of the system cause
smooth changes in the attributes of the system entities. When such system is modeled
mathematically , the variable of the model representing the attributes are controlled by
continuous functions. In general, in continuous, the relationship describes the rate at which
attributes changes, so that the model consists of differential equations.
If a system can be represented using simple differential equation model then it is often possible
to solve the model without the use of simulation, otherwise we use simulation to solve those
models which are complex to solve analytically.
System Dynamics
• System Dynamics is a methodology for studying and managing complex feedback
systems, in managerial, organizational and socioeconomic context.
• Dynamic System are imbedded into the development of System Dynamics and the
System Dynamics theory is often used to explain the principles upon which dynamic
systems are being built.
• The developers of system dynamics models are not always highly trained
mathematicians and in certain cases they do not see the need for dynamics applications
within their models.
• Example: Fluctuations in the general level of economic activity, price and supplies
fluctuate , social policies , biological oscillations, or explosions in populations, etc.
• The principal concern of a System Dynamics study is to understand the forces operating
in a system in order to determine their influence on the stability or growth of the system.
• Dynamic System is a system described by differential and /or difference equations. The
present output depends on past input and the output changes with time if it's not in a
state of equilibrium.
• Example( Dynamic System):
➢ A bathtub is a simple example of a dynamic system(material is flowing through this
system).
➢ A pot of water set on a burner.
Differential Equation:
We can use differential equation to represent the behavior of continuous system.
Example: Mx" + Dx' + Kx = Kf(t) (with constant coefficient describes the wheel
suspension of an automobile and is linear differential equation)
Although derivatives of any order may form other form , such as being raised to a power,
or are combined in any form , the differential equation is said to be non-linear differential
equation. Linear equations are simple to be solvable where non-linear equations can
usually not be solved exactly and are the subject of much on-going research.
When more than one independent variable occurs in a differential equation, the equation is
said to be partial differential equation. Differential equation occurs repeatedly in scientific
and engineering studies. It can involve the derivatives of same dependent variable with
respect to each of the dimensional body. An example is an equation describing the flow of
1
Compiled By: Santosh Bist
heat in a three dimensional body. There are four independent variable representing the three
dimensions and time , and one dependent variable , representing temperature.
Differential equation occurs repeatedly in scientific and engineering studies. The reason for
this prominence is that most physical and chemical process involves rates of change, which
require differential equations for their mathematical description. Since a differential
coefficient can also represent growth rate, continuous models can also be applied to a
problem of a social or economic nature where there is a need to understand the general
effect of growth trends.
Example: Lets illustrate how differential equation represent problems. Here we will show
how the equation describing the automobile wheel suspension system is derived from
mechanical principles.
2
Compiled By: Santosh Bist
Integrator: Integrator is a circuit arrangement , the output is the integral with respect
to time of single input voltage or the sum of several input voltages(can be positive or
negative).
Sign Inverter: It is an amplifier designed to cause the output to reverse the sign of the
input.
Scale Factor: Different scale factors can be used on the input to represent the
coefficient of the model equations.
3
Compiled By: Santosh Bist
4
Compiled By: Santosh Bist
Design an analog computer for human liver. The equations for human liver are
dx1/dt = -k12x1 + k21x2
dx2/dt = k12x1 – (k21 + k23)x2
dx3/dt = k23x2
Solution:
Here, above model has more than one independent variable. i.e. when a model has more than
one independent variable, a separate block diagram is drawn for each independent variable and,
where necessary ,interconnections are made between the diagrams. As shown below;
Lets read from left to right there are three integrators and they solve the equations for x1,x2
and x3. Interconnections between the three integrators, with sign changers where necessary,
provide inputs that aware the differential coefficients of the three variables. The first integrator
is solving the equation
x'1 = -k12x1 + k21x2
The second integrator is solving the equation,
x"2 = k12x1 – (k21 + k23)x2
The last integrator solves the equation,
x'"3 = k23x2
Note: Mathematical model of liver
Hybrid Computers
• The scope of analog computers has been considerably extended by developments of solid-
logic electronic device.
• Solid-logic devices, in addition improves the design and performance of operational
amplifiers and make devices cheaper and easier to obtain.
5
Compiled By: Santosh Bist
• But , before that analog computer uses few nonlinear elements, such as multipliers or
function generators and were expensive to make.
• Also we know that digital devices can store values, switching , and performing logical
operation.
• So, the term Hybrid computer has come to describe combinations of traditional analog-
computer and digital devices.
• Hybrid computer may be used to simulate system that are mainly continuous and also have
some digital elements i.e. Hybrid computers are used mainly in specialized applications
where both discrete and continuous data need to be processed.
• For example:
➢ An artificial satellite for which both the continuous equation of motion and the digital
controls signal must be simulated.
➢ A petrol pump contains a processor that converts fuel flow measurements into quantity
and price values.
➢ In hospital Intensive Care Unit(ICU) , an analog device is used which measures patient's
blood pressure and temperature etc , which are then converted and displayed in the form
of digits.
• Hybrid computer are useful when a system that can be adequately represented by an analog
computer model is subject of a repetitive study.
Digital-analog Simulators
Analog computers have some disadvantages and to avoid , Digital-Analog simulators are on
effect. Digital-Analog Simulation is a programming technique which makes a digital computer
operate much like an analog computer. They allow a continuous model to be programmed on
a digital computer in essentially the same way as it is solved on an analog computer. These
languages contain macro instructions that carry out the action of address, integrators and sign
changers.
A program uses these macro-instructions to link them together in essentially the same way as
operational amplifiers are connected in analog computers. Later more powerful techniques of
applying digital computers to the simulation of continuous system have been developed. Due
to these digital-analog simulators are not now in common uses.
6
Compiled By: Santosh Bist
2) Data Statement
These statement designs the numerical values to parameters , constant and initial
conditions, ICON can be used to set the initial value of the integration block function.
CONST can be used to set values for constant. PARAM is used to set parameters for
individual . It also can be used to set series of numeric values for one parameter.
Example:
CONST A = o.6, XDOT = 1.25, YDOT = 5.55
PARAM D = (0.25,0.50, 0.75, 1.0)
3) Control Statement
This statement specifies the option in the execution of the program and the choice of
the output. TIMER is used to specify the timer interval.
7
Compiled By: Santosh Bist
Example:
TIMER DELT = 0.005, FINTIM = 1.5, PRDEL = 0.1, OUTDEL = 0.1
where,
DELT – is Integration interval
FINTIM – is Finish Time
PRDEL – is Interval at which print results
OUTDEL – is Interval at which to print plot
If printed or print-plotted output are required then control statement with the words
PRINT and PRTPLT are used, followed by the name of variables to form the output.
TITLE and LABEL can be used to put headings on the output.
Example:
1) Solve the equation: 3x"' +15x" +50x' +200x = 10
Program:
TITLE DIFFERENTIAL EQUATION SOLUTION
*
X3DOT = (1.0/3.0)*(10.0 – 15.0*X2DOT – 50.0*XDOT – 200.0*X)
X2DOT = INTGRL(0.0,X3DOT)
XDOT = INTGRL(0.0,X2DOT)
X = INTGRL(0.0,XDOT)
*
TIMER DELT = 0.005, FINTIM = 1.5, PRDEL = 0.05, OUTDEL = 0.05
PRINT X, XDOT, X2DOT,X3DOT
PRTPLT X
LABEL DISPLACEMENT VS TIME
END
STOP
2) Explain about the simulation of an automobile wheel with CSMP III program for it.
Program:
TITLE AUTOMOBILE SUSPENSION SYSTEM
*
PARAM D = (5.656, 16.968, 39.592, 56.56, 113.12)
*
X2DOT = (1.0/M)(K*F – K*X – D*XDOT)
XDOT = INTGRL(0.0,X2DOT)
X = INTGRL(0.0,XDOT)
*
CONST M = 2.0, F = 1.0, K = 400.0
TIMER DELT = 0.005, FINTIM = 1.5, PRDEL = 0.05, OUTDEL = 0.05
PRINT X, XDOT, X2DOT
PRTPLT X
LABEL DISPLACEMENT VS TIME
END
STOP
Explanation:
Above program is for the case where Mass(M = 2.0), applied force(F) = 1.0 and
stiffness of the spring(K = 400) ,specified as CONST statement. A PARAM statement
has been used to produce runs with different values of D(5.656, 16.968, 39.592, 56.56,
113.12), to give different values to the damping ratio(0.1,0.3,0.7,1.0, and 2.0). The
program integrates with an interval of 0.0005, and runs for a time of 1.5.
8
Compiled By: Santosh Bist
The output is for values of X", X' and X, and print-plot for X. All output is at intervals
of 0.05.
Hybrid Simulation
Sometimes a model of a simulation does not show only continuous behavior completely, but
also has a discrete nature at this time, the system being simulated is an interconnected of
continuous and discrete system which can be best model by an analog and digital computers
being linked together to provide a hybrid simulation. High-speed devices are needed to
transform signal from one form of representation to the other. The term hybrid simulation is
generally reserved for the case in which functionally distinct analog and digital computers are
linked together for the purpose of simulation.
Feedback System:
A significance factor in the performance of many systems is that a coupling occurs between
the input and output of the system. Feedback describes the situation when output from (or
information about the result of) an event or phenomenon in the past will influence an
occurrence or occurrences of the same (i.e. same defined) event/phenomenon in the present or
future. When an event is part of a chain of cause-and-effect that forms a circuit or loop, then
the event is said to "feed back" into itself.
9
Compiled By: Santosh Bist
For Predator:
The interaction between predator and prey, the death rate of prey is proportional
to the product of two population size x(t).y(t) or death rate of prey is b.x(t).y(t).
Therefore, rate of growth of Predator population, dy/dt, is given by:
𝑑𝑦
= -s.y(t) + b.x(t).y(t)
𝑑𝑡
where, a and b are measure of effect of the interspecific between two species. As
the predator population increases, the prey population decreases. This causes the
decrease in the rate of increased predator, which eventually results in decrease in a
number of predators. These in turns cause the number of prey to increase.
10
Compiled By: Santosh Bist
direction to keep pointing towards the bomber. Now a question is whether the fighter
will be able to destroy the bomber or not, if so, in how much time.
If the target flies along a straight line, the problem can be solved directly with analytical
technique: however, if the path is curve, the problem is much more difficult and
normally can't solved analytically. Then we will use simulation to solve these problems
under the following simplifying condition:
i) The target and the pursuer are flying in the same horizontal plane when the
fighter first sights the bomber, and both stay in that plane. This makes the
pursuit model two dimensional.
ii) The fighter's speed VF is constant(20kms/minutes)
iii) The target's path is specified.
iv) After a fixed time span ∆t the fighter changes its direction in order to point itself
toward the bomber.
Let us consider the situation, where the target and pursuit fly in the same
horizontal plane, stay in that plane. During the period of pursuit , the fighter
speed VF is constant at 20 kms/minutes while the target path is specified as a
function of time as follows:
Time(t) 0 1 2 3 4 5 6 7 8 9 10
X(t) 100 100 120 130 122 119 300 240 168 165 219
Y(t) 0 3 6 10 15 20 26 32 37 34 30
The fighter aircraft is at position(XF,YF) , i.e. (0,50) when it first sight the
bomber at time t=0, the time at which pursuit begins. At the time t=0, the
bomber is at (XB,YB) = (100,0). The fighter corrects its direction towards the
bomber and shoots the bomber by firing a missile as soon as it is within a
distance of 10km , and the pursuit ends. In case the bomber is not shoot within
12 minutes of pursuit, the pursuit is abandoned.
The fighter aligns its velocity factor with the point of sight towards the bomber.
It continues to fly in that direction for one minute and at time t+1, it looks the
target again and re-aligns itself. At time t, the distance between the fighter &
the bomber is:
If 𝜃 is the angle with the line connecting the bomber and fighter mesh with x-
axis then
𝑌𝐵 −𝑌𝐹
sin 𝜃 = 𝑑
𝑋𝐵 −𝑋𝐹
cos 𝜃 = 𝑑
The co-ordinates of the position of the fighter at time t+1 can be determined as:
𝑋𝐹 (𝑡 + 1) = 𝑋𝐹 (𝑡) + 𝑉𝐹 𝑐𝑜𝑠 𝜃
𝑌𝐹 (𝑡 + 1) = 𝑌𝐹 (𝑡) + 𝑉𝐹 𝑠𝑖𝑛 𝜃
with these new co-ordinates of the fighter , its distance from the target is again
computed. If the distance is 10km or less, the pursuit ends. Otherwise the values
of the sin 𝜃,cos 𝜃 and new co-ordinates of the fighter are re-computed. If the
11
Compiled By: Santosh Bist
pursuit does not end within specified time, the bomber is considered as escaped
and pursuit is abandoned.
Here, A is to hit B, B is to hit C & C is to hit D. The velocities of A, B, C and D are Va,
Vb, Vc &Vd respectively. Let 𝜃𝑎 be the angle with the velocity vector A makes with the
direction AB. Similarly, let 𝜃𝑏 be the angle which velocity vector B makes with
direction BC. Though C & D moves in straight line, in present case to generate the
problem, let 𝜃𝑐 & 𝜃𝑑 be the angle with velocity vector of C and D makes with direction
CD.
As A runs towards B , it continuously changes its direction so that its velocity vector is
in direction B. Similarly, B continuously changes its direction so that its velocity vector
is a way in a direction of its target C. Since D is not chasing any object it will move in
a straight line. So as to keep maximum distance from its hitter C. Object C has to run
towards D. These again move in a straight line as its target is running straight
We want to determine which of the object will be hit first?
These can be determining by simulating the chase as:
➢ The location of all 4 objects in determined after every small increment in time.
➢ The direction of motion at new point is determined.
➢ The distance between object are computed.
➢ As soon as the distance between any set of object i.e. distance AB, BC or CD
becomes zero, hit occurs and chase ends.
Assignment:
1) Interactive System
2) Real time System
3) Simulation of autopilot system
12
Compiled By: Santosh Bist
Chapter 4
Discrete System Simulation
Discrete System is defined as the changes in state are discontinuous and each change in the
state of the system is called an event. The model used in discrete system simulation has a set
of numbers to represent the state of system. A number used to represent some aspect of the
system state is called a state descriptor. The state descriptors change value and define a
discrete event as a set of circumstances, that causes an instantaneous change in one or more
system state descriptors.
It is possible that two different events occur simultaneously , or are modeled as being
simultaneous and not necessary to change all of state descriptors occurring simultaneously
belong to a single event. But the changes must be made sequentially. Also system simulation
must contain a number representing time. The simulation proceeds by executing all the changes
to the system descriptors associated with each event, as the events occur, in chronological
order. The way in which events are selected for execution , particularly when there are
simultaneous events, is an important aspect of programming simulations.
Representation of Time:
Clock time is the passage of time recorded by a number . It is initialized to zero and
subsequently indicates how many units of simulated time have passed since the beginning of
the simulation. The term simulation time means the indicated clock time and not the time that
a computer has taken to carry out the simulation. Also , there is no direct connection between
simulated time and the time taken to carry out the computations where the computation time is
the number of events that occur. Simulation is carried out on digital computers , where real
events occurs in time intervals measured in fractions of microseconds. We know , for
simulation of an economic system , events occurs once a year and even a hundred years of
operation could easily be performed in a few minutes of calculations.
Two methods exist for updating clock time. One method is to advance clock of time as event
occur also called event-oriented and second one is to advance the clock by small intervals of
time and determine at each interval whether an event is due to occur at that time also called
interval-oriented . Discrete system simulation is usually carried out by using the event-oriented
method, while continuous system simulation normally uses the interval-oriented method.
Another approach to representing the passage of time has been called significant event
simulation , is applicable to continuous systems in which there are quiescent(idle) periods. The
interval between events in the event-oriented approach is a quiescent period, but it involves
having the models representation of the system activities create a notice of the event that
terminates the interval. The significant event approach assumes that simple analytic functions,
such as polynomials of low order, can be used to project the span(duration) of a quiescent
period.
or it may be lost because no link is available, in which case it is said to be blocked call. We
will simulate , what proportion are successfully completed, blocked, or found to be busy calls.
From above figure (a) line 2 is connected to line 5 and line 4 is connected to 7. Below figure
(b) representing the state of the system.
5) Gather some statistics for the simulation output – Counters are set aside to record the
number of calls that have been processed, completed, or lost through being blocked or
busy. Disconnection of a call , the counts of processed call and of completed calls are
increased by one, appears in figure(b) .
Again, the next potential event is an arrival , but this time the arriving call can be connected,
so the state of the system moves, figure(d).
figure(e)
On figure(e) , there are 3 links and only one is in use. Given clock time is 1053, call in progress
4 to 7 at 1075. Also, next call arrive at 1057 from 1 to 7 but line 7 is busy. In this case call lost
and update call counters i.e. number of total proceeds call increased by 1.
For delayed calls , as shown in figure (f) :
activities of the system must be represented as routines that create the discrete events making
the changes to the system image.
Simulation Algorithm – The procedure that executes the cycle of actions involved in carrying
out the simulation, referred to as the simulation algorithm.
Report (Report Generator) – is the generation of an output report. The statistics gathered
during the simulation will usually be organized by a report generator.
The general flow of control during the execution of a simulation program is illustrated in figure
below:
1. Counts – no. of entities of particular type or no. of times some event occurred
2. Summary measures – extreme values, mean values, standard deviations
3. Utilization – fraction of time some entity is engaged
4. Occupancy – fraction of a group of entities in use on the average.
5. Distributions – of important variables, such as queue lengths, waiting times .
6. Transit times – time taken for an entity to move from one part of the system to some
other part.
When there are stochastic effects operating in the system, all these system measures will
fluctuate as a simulation proceeds. The particular values reached at the end of the simulation
are taken as estimates of the true values they are designed to measure.
From above figure, tb time keep record at which the item last became busy , tf time keep record
at which item became free and the interval (tf – tb) is derived and added to counter. At the end
of simulation run, the utilization U is derived by dividing the accumulated total by the total
time T, so that , if the entity is used N times:
1
Utilization(U) = ∑𝑁 𝑟=1(𝑡𝑓 − 𝑡𝑏 )𝑟
𝑁
• A discrete simulation program, update time as events occur, will measure the intervals tf -
tb directly . A continuous simulation program update time in small intervals need to build
up the count by counting the number of intervals in which the item is busy.
In dealing with groups of entities , rather than individual items, the calculation is similar,
requiring that information about the number of entities involved also be kept. The figure below
represents function of time, the number of links in a telephone system that are busy. To find
average number of links in use, a record must be kept of the number of links currently in use
and the time at which the last change occurred. If the number changes at time tr , to the value
nr, then, at the time of the next change tr+1, the quantity nr(tr+1-tr) must be calculated and added
to an accumulated total. The average number in use during the simulation run, A, is then
calculated at the end of the run by dividing the total by the total simulation time T, so that:
1
A = ∑𝑁
𝑟=1 𝑛𝑟 (𝑡𝑟+1 − 𝑡𝑟 )
𝑇
Also , the below figure represent the number of entities waiting on a queue, in which case , the
calculation gives the mean number of entities waiting.
If there is an upper limit on the number of entities , as there was a limit on several links in the
telephone system then the occupancy is defined as the ratio of the average number in use to the
maximum number.
Average number in use
occupancy =
𝑀𝑎𝑥𝑖𝑚𝑢𝑚 𝑛𝑢𝑚𝑏𝑒𝑟
If M = links in a telephone
nr = number of busy in the interval ti and ti+1 then the average occupancy , assuming the number
nr changes N times is given by:
1
Occupancy (B) = ∑𝑁
𝑟=1 𝑛𝑟 (𝑡𝑟+1 − 𝑡𝑟 )
𝑁𝑀
An important difference between utilization and occupancy statistics is that for utilization,
timing information must be kept for each individual entity. Occupancy statistics only require
keeping a count of a class of entities , and recording the last time the count changed, just two
numbers.
Assignment:
Recording Distributions and Transit Times
Discrete Simulation Languages
is defined as a function that gives the probability of a random variable's being less than of equal
to a given value. In the case of discrete data, the cumulative distribution function is denoted by
P(xi).
Probability functions are often displayed graphically as shown in figure below: figure a, is the
probability mass function and figure b, is the cumulative distribution function.
The integral of the probability density function taken over all possible values is 1. That is,
∞
∫−∞ 𝑓(𝑥)𝑑𝑥 = 1
In practice, most variables in a simulation study have a finite lower limit, generally zero instead
of −∞ . The probability density function at and below this limit is then identically zero, and
the lower limit of the integral can be replaced by the finite value. The same effect may occur
at the upper limit.
The cumulative distribution function, which defines the probability that the random variable is
less than or equal to x, is denoted by F(x), in the case of a continuous variable . It is related to
the probability density function, as follows:
∞
F(x) = ∫−∞ 𝑓(𝑥)𝑑𝑥
If the observations fall into I groups , where the ith group takes the value xi and has ni members,
the formula can be written as
1
m = ∑𝐼𝑖=1 𝑛𝑖 𝑥𝑖
𝑁
For a continuous variable , the mean value is defined by the following integral:
∞
m = ∫−∞ 𝑥𝑓(𝑥)𝑑𝑥
There are two other measures of a distribution , mode and median. When the probability
density function has a peak, the value of x at which the peak occurs is called a mode. If there
is only one peak occurs in the function, the probability density function is said to be unimodal.
The median is the value separating the higher half from the lower half of a data sample,
a population, or a probability distribution. Also it is not even necessarily true that the values of
a random variable will fall below the mean value. The value of x which defines the point is
called the median. The probability density function is sometimes described in terms of fractiles,
which are a generalization of the median. When considering percentages, the fractiles are called
percentiles.
In general, however, the mode and the median are not particularly significant when
representing probability functions in a system simulation, but it is important them with the
mean when interpreting input data. In addition, when certain well-known functions are to be
fitted to experimental data, the calculations determining the best fit sometimes involve the use
of modes, medians , or fractiles.
Another measure of a stochastic variable that is important is the variance of the variable ,
denoted by s2. The practical form in which the variance is used is as a standard deviation,
which is the (positive) square root of the variance , denoted by s. If there are N observations
taking the values xr (r = 1,2,3,….,N) and having the mean value m, the standard deviation is
estimated with the formula,
1 𝑁
s={
(𝑁−1)
∫𝑟=1(𝑚 − 𝑥𝑟 )2 }1/2
The significance of the standard deviation is that it is a measure of the degree to which the data
are dispersed.
Random Number
Random numbers are numbers that occur in a sequence ,are uniformly distributed over a
defined interval or set, and impossible to predict future values based on past or present ones.
Random numbers are important in statistical analysis and probability theory.
We know simulations are experimental in nature and most simulation be done on the basis of
random selection. In such simulations, random numbers are used for interarrival times, service
times, allocation amounts, and routing probabilities. For each application of random numbers
in a simulation, a distribution must be chosen. The distribution determines the likelihood of
different values occurring.
Continuous random variable – Random variable X is continuous if its sample space is a range
or collection of ranges of real values. Example: The height of people in Nepal lies between 0.5
and 6 feet.
Discrete random variable – is said to be discrete variable if it takes at most countable values.
In other word , a real valued function defined on a discrete sample space is called a discrete
random variable. Examples: 1) The number of people in queue in bank. 2) The number of
patients arrived in hospital.
• expectation
• variance
Computer programs have been developed for generating sequences of numbers uniformly
distributed over given range(usually 0 to 1). Starting with initial number, second number is
generated. Using second number as input, the procedure is repeated to produce a third number
and so on. In general , the (i+1)th number of the sequence is generated from the ith number.
There are different technique to generate random number. Here we study about congruential
method( Linear Congruential Generator or sometimes, residue method). This procedure is
described mathematically by the expression,
Xi+1 = (λXi + µ)(modulo m) i= 0,1,2,3,4,……
Given three constants λ, µ, and m, the procedure derives the (i+1)th number from the ith
number by multiplying by λ , adding µ , and then taking the remainder or residue, upon dividing
by m.
To begin the process , an initial number X0 is needed, and this is called a seed. For complete
process therefore needs four numbers, λ , µ ,X0 and m. Then random number,
Ri = Xi/m i=1,2,3,4,……
Three types of congruence pseudo-random number generators have been used:
1) mixed congruential generator(defined by above formula)
2) additive congruential generator(if λ =1)
3) multiplicative congruential generator(if µ =0)
Example 1: Use linear congruential method to generate a sequence of random number with
seed=179.multiplier=43 and modulus 1000.
Solution:
Given,
λ = 17
µ = 43
X0 = 27
m = 100
According to LCG(Mixed LCG):
Xi+1 = (λ Xi + u) %m (i=0,1,2,3,…..)
Ri=Xi/m (i=1,2,3,4,…..)
Example: The sequence of random numbers 0.54, 0.73, 0.97, 0.10, and 0.67 has been
generated. Use the Kolmogorov-Smirnov test at 𝛼 5% to determine if the hypothesis that the
numbers are uniformly distributed on the interval[0,1] can be rejected. [Note: critical value of
D for 5% significance level and N/𝜇=5 is 0.565].
Solution:
Given,
Random numbers = 0.54, 0.73, 0.97, 0.10, 0.67
Total observation N or μ = 5
Level of significance (𝛼 ) = 5%
critical value(D 𝛼 , N/𝜇) = 0.565
we know,
D = Max{D+, D-}
where,
𝑖
D+ = Max{ -Ri }
𝑁
(𝑖−1)
D- = Max{ Ri - }
𝑁
Then,
i Ri(order) i/N (i-1) / N D+ D-
1 0.10 0.2 0 0.1 0.10
2 0.54 0.4 0.2 -0.14 0.34
3 0.67 0.6 0.4 -0.07 0.27
4 0.73 0.8 0.6 0.07 0.13
5 0.97 1.0 0.8 0.03 0.17
Here,
D+ = 0.1
D- = 0.34
D = Max{D+, D-} = 0.34
Here, D(calculated value) < D(critical value), null hypothesis not rejected i.e. numbers are independence.
So , given sample is random numbers sample(generated using random process).
Chi-square test:
• A Chi-square (X2) statistic is a test that measures how a model compares to actual observed data.
• It was developed by Karl Pearson in 1900.
• Chi-square test is a non-parametric test (based on frequency and not on the parameters like mean
and standard deviation).
• This statistical test follows a specific distribution known as chi-square distribution.
• In general , the measure of difference between what is observed and what is expected according to
an assumed hypothesis is called the chi-square test. Given as :
(𝑜𝑖 −𝑒𝑖 )2
X2 = ∑𝑛𝑖=1 𝑒𝑖
where,
oi – observed frequency or observed value in the class.
ei – expected frequency or expected value in the ith class.
Sampling distribution of X2 is approximately the chi-square distribution with (n-1) degree of freedom.
If X2(sampled/calculated) < X2(Critical value/tabulated value) , Hypothesis(h0) accepted , i.e. the given
sample is uniformly distributed and is a sample of random number.
Example: Perform chi-square test for the test of randomness of occurrence at 1% significance
level. For n=10 classes, critical value = 2.09.
Solution:
Given:
no. of class(n) = 10
degree of freedom = (n-1) =9
level of significance (𝛼) = 1%
X2(critical value) = 2.09
we know ,
(𝑜𝑖 −𝑒𝑖 )2
X2(calculated) = ∑𝑛𝑖=1 𝑒𝑖
Then,
Description:
A GENERATE block is used to represent the output of machine by creating one
transaction every five minutes of time. The ADVANCE blocks with a mean of 4 and
modifier of 3 is used to represent inspection will therefore be anyone of values
1,2,3,4,5,6,7. After completion of the inspection transaction go to a TRANSFER block
with a selection factor of 0.1, so that 90% of the parts go to next location i.e. exit1 called
ACC and 10% go to another location i.e. exit2 called REJ . Since there is no further
interest both location reached from the TRANSFER blocks to TERMINATE blocks.
The program runs until a certain count is reached as a result of transaction terminating
. Field A of terminate block carries a number indicating by how much the termination
count should be incremented when transaction terminates at that block . The control
statement START has a field A that indicates a value the terminating counter should
reach to end the simulation. When the simulation is completed , the program
automatically generate a report , in a prearranged format.
Note:
i. In this case exit1(i.e. ACC) is the next sequential block so it is allowed to omit
the name ACC in both the TRANSFER Field B and the location field of first
terminate block. The GPSS code becomes like this TRANSFER 0.1, ,REJ. Both
comma must be given to indicate B is missing.
ii. If Transfer block is used as unconditional mode, then we need not have to
specify field A. However comma must be given to indicate A is missing. The
GPSS code become like this TRANSFER ,REJ.
Characteristic of the Block
1. Transactions(Xact)
In each system represented by a block diagram , some entities pass through the system.
In petrol pump system , they may be vehicles, in a production system they may be parts
and in supermarket system they may be customer . Those entities are referred to as
Transactions. In simulation the transaction are created, which move through the block
diagram in the same way , as the entities pass through the actual system being simulated.
There can be many transactions simultaneously moving through the block diagram.
2. Block / Action Time
The block time also called action time is an integer giving the number of units required
to execute the action represented by the block . The program computes an action time
for each transaction entering a block to represent the time taken by the system action
simulated by the block. The program compute an interval of time called action time for
each transaction as it enters and ADVANCE block, and the transaction remains at the
block for this interval of simulated time before attempting to proceed. The action time
may be a fixed interval or a random variable. An action time is defined by giving a
mean and modifier . Example: T = A ± B where A is the mean and B is the modifier.
3. Succession of Events
The program maintains records of when each transaction in the system is due to move.
It proceeds by completing all movements that are scheduled for execution at a particular
instant of time and that can be logically performed. When there are more than one
transaction due to move, the program processes transactions in the order of priority or
FCFS basis. Once the program begun moving a transaction, it continuous to move the
transaction through the block diagram until the transaction enters ADVANCE (wake
up other transaction and return to itself when action time is expended) or
TERMINATE(transaction is removed from simulation) block or the transaction is
blocked(action the transaction is attempting to perform can't be perform currently)
4. Selection Factor / Choice of path
The TRANSFER block allow some location other than the next sequential location to
be selected. The choice is normally between two blocks referred to as blocks A and
B(also called as exit1 and exit2). The choice of which exits to be followed is given by
a number called the selection factors. S(0<S<1) which is entered in the block. S is the
probability of selecting exit 2 and 1. S is the probability of selecting exit 1. Also if the
selection factor is BOTH, it first chooses empty block A i.e. exit1.
5. Items of Equipment
In each system, there are physical equipment, which perform some operation on the
transactions. Machine tools in a production shop perform machining operations on
work pieces. Example: In transportation system, a toll booth on a road is equipment,
while vehicles are transactions. In Factory Manufacturing system , an inspector is
equipment, while parts are transaction, etc. The item of equipment may operate upon
transactions individually or may handle groups.
6. Storage and Facilities
Item of equipment can be classified into storage and facilities, depending upon the
capacity for handling the transactions. An item of equipment , which can handle only
one transaction at a time, is called a facility while the items of equipment, which can
handle a large number of transactions at the same time is called storage.
Example: In communication system , message is transaction, switch(pass only one
message) is facility while trunk(collection of wirer carrying several messages) is
storage.
Facilities and Storage
A facility is defined as an entity or resources that can be engaged by a single transaction at a
time. Storage is defined as an entity or resource that can be occupied by much transaction at a
time up to some pre-determined limit.
Once a transaction seizes(holds) a facility any other transaction trying to seize the same facility
is delayed until the first transaction releases the facility (resources) but not in case of storage
until storage limit reaches. Some example of the system entities might be interpreted in
different system are:
Types of System Transaction Facility Storage
Communication Message Switch Trunk
Transportation Car Roll Both Road
Data processing Record Key stroke Computer memory
Computer Process CPU Memory
There are additional four block types concerned with using facilities and storages:
1. SEIZE: The SEIZE block allow a transaction to engage a facility if it is available.
2. RELEASE: The RELEASE block allows the transaction to disengage the facility.
3. ENTER: The ENTER block allows the transaction to occupy space in storage, if it is
available.
4. LEAVE: The LEAVE allows a transaction to give up the occupied space.
Field A in each case indicates which facility or storage is intended, and the choice is usually
marked in flag attached to the symbols of the block. If the field B in ENTER and LEAVE
blocks are blank, the storage contents are changed by 1. If there is a numeric(≥ 1). Then the
content changes by that value.
Example:
Let us consider a situation as below:
SEIZE CPU
ADVANCE 7
RELEASE CPU
Here CPU is a facility and it seems that a transaction needs to use the resource for 7 times units.
Any other transaction arriving at the block 'SEIZE' is refused to enter until the former
transaction has entered 'RELEASE' block.
Resources which can be shared by several transactions are modeled using storage. Suppose we
want to model a computer system which has 64kb of memory then we might declare
'MEMORY STORAGE 64' and then a request for 16kb memory might be represented by the
sequences of blocks.
ENTER MEMORY 16
LEAVE MEMORY 16
As the facilities, a transaction arriving at ENTER block at a time when it is used by other
transactions, is delayed until the previous transaction LEAVE the necessary memory with. A
transaction controlling and facility can be interrupted or preempted by other transactions.
Example 1:
In a manufacturing shop, a machine tools turns out parts at the rate of one every five minutes.
As they are finished the parts go to inspector, who takes 4±3 minutes to examine each part and
rejects 10% of parts. Each part will be represented by one transaction and time unit selected
for problem will be one minute. Simulate for 100 parts to leave the system assuming that there
is only one inspector.
Note: Since there is only one inspector, it is necessary to represent the inspector by a facility ,
to simulate the fact that only one part at a time can be inspected.
GPSS code:
GENERATE 5 Create parts
ENTER insp Get an Inspector
ADVANCE 4,3 Inspect
LEAVE insp Free Inspector
TRANSFER 0.1,ACC,REJ Select Reject
ACC TERMINATE 1 Accepted parts
REJ TERMINATE 1 Rejected parts
STORAGE 3 Numbers of inspector
START 100 Run 100 parts
Note: STORAGE is a control statement which assigns the capacity of storage.
Example 2: Consider a factory that manufactures football taking 20 to 40 minutes. The ball is
moved from the generation to the inspection machine taking a 2 minutes. There are 3
inspection machine at one place and need 30 to 60 minutes for inspection and reject 30% of
football. Simulate for 1000 transaction . Draw GPSS block diagram to simulate this system.
solution:
Here, Manufacture of football takes 20 to 40 minutes so,
mean = (20+40)/2 =30
Generate = 30±10
product take 2 minutes to reach for inspection i.e. ADVANCE = 2, and for
inspection it take 30 to 60 minutes,
mean = (30+60)/2 = 45
ADVANCE = 45±15
GPSS Block Diagram:
GPSS Code:
GENERATE 30,10 Create parts
ADVANCE 2,0 To Inspect
ENTER insp Get an Inspector
ADVANCE 45,15 Inspect
LEAVE insp Free Inspector
TRANSFER 0.3,ACC,REJ Select Reject
ACC TERMINATE 1 Accepted parts
REJ TERMINATE 1 Rejected parts
STORAGE 3 Numbers of inspector
START 1000 Run 1000 parts
Gathering Statistics
Block types such as QUEUE, DEPART , MARK and TABULATE are used to gather statistic
about the system performance but not to represent the system action.
When the condition for advancing a transaction is not satisfied several transactions may be kept
waiting at a block and due to this the QUEUE block increase and DEPART block decreases
the number in field A i.e. queue block increases the queue number while depart block decreases
the queue number. A is queue number, B is the quantity by which the queue number is being
increased.
The MARK and TABULATE blocks are used to measure the length of time taken by
transaction to move the system or parts of the system. The MARK block simply notes the
arrival time on the transaction and the TABULATE blocks subtracts the time noted by
MARKED block from the time of arrival at the TABULATE block.
Example: Consider the example of manufacturing shop with 3 inspectors. Parts will now
accumulate on the inspectors works bench if inspection doesn't finish quickly enough. simulate
the situation for 1000 parts to measure how long the parts take to be inspected, excluding their
waiting time in queue.
Note:
i. Up to the above example, the properties of generate block is such that if a
transaction is unable to leave a block at the time it is cleared , no further
transactions are generated until the block is cleared so if all the inspectors are busy
, the machining of further parts stops until the machine is cleared.
ii. So if all inspectors are busy then queue is used to accumulate incoming parts/
transactions.
GPSS code
• In the above solution, a QUEUE block using queue number 1 is placed
immediately before ENTER block and a DEPART block is placed immediately
after the ENTER block to remove the part from the queue when inspection
begins.
• If some inspectors are free for inspection, then transaction doesn't have to wait
in queue otherwise they have to wait. The program will automatically measure
the length of stay in queue.
• The MARK and TABULATE block will measure how long the parts take to be
inspected , excluding their waiting time in the queue.
• If MARK block is omitted, the tabulated time is the time since the transaction
first entered the system.
GENERATE 5 Create parts
QUEUE 1 Queue for an inspector
ENTER 1 Get an Inspector
DEPART 1 Leave QUEUE
MARK
ADVANCE 12,9 Inspect
LEAVE 1 Free Inspector
TRANSFER 0.1,ACC,REJ Select Reject
TABULATE 1 Measure transit time
ACC TERMINATE 1 Accepted parts
REJ TERMINATE 1 Rejected parts
v. When parts finish inspection , the transaction goes to single TABULATE block where
the transit time is recorded.
vi. Because of the rule by which transactions normally pass from one block to next higher
numbered block, only one of the three release block that complete the inspection is able
to pass transactions directly to the TABULATE block.
vii. The other pass the transaction to TABULATE block using unconditional TRANSFER
block.
conv3 TERMINATE
1 TABLE M1,5,5,10 Tabulation Intervals
START 10,NP Initialize with ten parts
RESET
START 1000 Main run
SIMSCRIPT Program
• The SIMSCRIPT programming system is especially designed to facilitate the writing
simulation program.
• SIMSCRIPT is a very widely used language for simulating discrete system and similar
to FORTRAN in appearance.
• SIMSCRIPT 11.5 can be view as a general programming language with extra features for
discrete event simulation.
• Because of this general power and FORTRAN based, SIMSCRIPT has been widely
implemented and used discrete simulation language.
• The language can be considered more than just a simulation language since it can be
applied to general programming problems.
When all events (that can be executed at a particular time) have been processed, the clock is
update to the time next event notice and the control is passed to the event routine as identified
by the notice. These actions are automatic and doesn't need to be programmed .
I the event executed by a routine results another events, the routine must create a new event
notice and filed it with the other notice.
In case of exogeneous events a series of exogenous event statements are created. For each event
this statements are similar to event notices are also filed into chronological order and are read
by the program.
SIMSCRIPT Statements:
• SIMSCRIPT statements are written in a form closely resembling the English language.
• There are many alternative terms or mode of statement which will be interpreted as
equivalent statement.
• The statement PRINT n LINES AS FOLLOWS is equivalent PRINT n LINES THUS
Example:
PRINT 1 LINE AS FOLLOWS
Hello world
The above statement Prints a single line output with Hello world message.
PRINT 1 LINE with x, y, x/y AS FOLLOWS
Value of x = ***, Value of y = ***, x divide by y = ***.*
1. The standard IF statement
Simple either or logic is supported by the IF statement.
The general form is
IF logical expression
Group of statement 1
ELSE
Group of statement 2
Example 1: A simple SIMSCRIPT II program to read three number and display their
sum
READ X, Y AND Z
ADD X + Y TO Z
PRINT 1LINE WITH Z AS FOLLOWS
X + Y + Z = ***.*
STOP
The above program displays the sum of three number with label X+Y+Z = , and 4 digit
integer value as sum.
Example 2: A SIMSCRIPT II program to read a set of 100 numbers and add together
those number which are greater than 5.
'READ' ADD 1 TO COUNT
IF COUNT > 100 GO TO FINISH
ELSE READ N
IF N IS GREATER THAN 5 ADD N TO SUM
REGARDLESS GO TO READ
• If the mode is other than the normal mode(INTEGER), DEFINE statement list the
variable and declares their mode as follows:
DEFINE name1, name2,…. AS INTEGER VARIABLES
If the DEFINE statement does not mention the mode, the variables are taken to be in
the normal mode.
• Events are represented by individual routine which consists of local variable so they
need not be defined in preamble i.e. beginning . Note only global variable are defined
in the preamble.
• The permanent entities temporary entities and the event notices are defined in the list,
following the statement PERMANENT ENTITIES, TEMPORARY ENTITIES and
EVENT NOTICES respectively . Then it is followed by the statement of the form :
EVERY entity HAS A attr.1 AND A attr.2…
• If any SIMSCRIPT statement needs to go beyond 80 characters it can be extended to
another line.
• The event notices can also carry data, if needed ,the attributes are defined with a list of
EVERY statements following EVENT NOTICES statement.
• If an array or multidimensional table is needed, A DEFINE statement, giving the name
of the entity , defines the dimensions, in addition to declaring the format, if that is
necessary . For example:
DEFINE table AS AN INTEGER ,n-DIMENSIONAL VARIABLE
Example: Defining the Telephone System Model
• In telephone system simulation for lost call , telephone lines are permanent entities and
has attributes to indicate whether the line is busy or not . So the name TLINE is used
to represent the telephone line and the attribute will be called STATE. STATE is simply
an integer variable which take value 0 to indicate free and 1 to indicate busy state.
• Calls are represented by temporary entities , with two attributes for carrying the origin
and destination.
• The temporary entities has two attributes for recording the origin and destination of the
call.
The preamble for model 1 of the telephone system actually shows part of the printed
output of compilation, which lists the input.
Referencing Variable:
• Single variables are simply referenced by using their name.
• Permanent entities such as telephone line, are respected by arrays, with an array of
attribute, identified by the attribute name. It's because they are fixed/ static in nature.
• Temporary entities and event notices are created and destroyed as simulation proceeds
so they can't be kept in fixed table.
• For example, CREATE A CALL and DESTROY A CALL , for each creation , the
program refers to data structure given in preamble and creates a block of words. Since
the number of block will fluctuate, they can't be kept in fixed table.
• So every type of temporary entity , or event notice, the system automatically reserves a
location by holding a pointer that has the same name as the entity or notice. When a
CREATE statement is used , the pointer to the entity or notice being created is placed
at that location. For example , the command CREATE CALL , puts the pointer to the
created record in a location called CALL.
• If during the current execution of a routine, it is necessary to create a second copy of
an entity or notice, the second creation will write over the pointer to the first unless
another form of CREATE statement is used. This take the form CREATE A CALL
CALLED name, the pointer to the created record then goes to the location called name.
• Also, SIMSCRIPT allow the formation of set linking groups of temporary entities
having a common property . The set are organized as list structure. Every individual
temporary entity that might belong to the set has two word push aside as pointer for
identifying its predecessor and successor in the set.
• The simulation will proceed by executing events until the time for the CLOSING event
is reached, to end the simulation. At that point control returns to the MAIN routine at
the statement following the one that started the simulation.
• Lines 14 through 19 define the report. The output lists the conditions under which the
simulation is stopped by the statement at line 20.
• As with all SIMSCRIPT routines, an END statement is needed to indicate the physical
end of the routine definition.
Estimation Methods
Statistical methods are commonly used on the random variable. Usually , a random variable is
drawn from an infinite population with a finite mean '𝜇' and finite variance '𝜎'. This means ,
the population distribution is not affected by the number of samples already made, nor does it
change with time. Also, if the value of one sample is not affected by the value of any other
sample, the random variables are mutually independent. Random variables that meet all these
conditions are said to be independently and identically distributed(i.i.d) . The central limit
theorem can be applied to i.i.d data that hold simulation data.
The theorem states that the sum of n i.i.d. variables, drawn from a population that has a mean
of '𝜇' and a variance of ' 𝜎2 ' , is approximately distributed as a normal variable with a mean of
n 𝜇 and a variance of n 𝜎2.
Let xi( i = 1,2,3,……) be the n i.i.d random variables. Using Central limit theorem:
∑𝑛
𝑖=1 𝑥𝑖 −𝑛𝜇
z=
√𝑛𝜎
𝑥̅ −𝜇
z= 𝜎
√𝑛
The variable 𝑥̅ is sample mean. It can be a consistent estimator for the mean of the population
from which the sample is drawn. since the sample mean is the sum of random variables, it is
itself a random variable. So, a confidence interval about its computed value needs to be
established.
The probability density function on the standard normal variable (z) is shown in the figure
below.
The integral form –∞ to a value 𝜇 is the probability that z is less than or equal to 𝜇 and is
denoted by 𝜑(𝜇).
Let us consider the value of 𝜇 is chosen so that 𝜑(𝜇) = 1-𝛼/2 , where 𝛼 is some constant less
than 1 , and denote this value of 𝜇 by 𝜇𝛼/2 . Then probability that z > 𝜇𝛼/2 = 𝛼/2 .
The normal distribution is symmetric about its mean, so the probability that z < - 𝜇𝛼/2 = 𝛼/2.
Therefore the probability that z lies between - 𝜇𝛼/2 and 𝜇𝛼/2 is:
The constant 1- 𝛼 (usually expressed as a percentage) is the confidence level and the interval
𝜎
𝑥̅ ± 𝜇𝛼/2 is the confidence interval. The size of confidence interval depends upon the
√𝑛
confidence level chosen. Typically , the confidence level might be 90% in which case is 1.65.
𝜎
Then confidence interval 𝑥̅ ± 1.65 with probability 0.9; meaning that , if the experiment is
√𝑛
repeated many times, the confidence interval can be expected to cover the value 𝜇 on 90% of
the repetitions.
In practice , the population variance is not usually known: in which case, it is replaced by an
estimate calculated from the formula:
1
s2 = ∑𝑛𝑖=1(𝑥𝑖 − 𝑥̅ )2
𝑛−1
But waiting times measured this way are not independent because whenever a waiting line
forms, the waiting time of each entity on the line depends upon the waiting time of its
predecessor (i.e. the entities are autocorrelated).
The usual formula for estimating the mean value of the distribution remains on satisfactory
estimate for the mean of autocorrelated data. However, the variance of autocorrelated data is
𝜎2
not related to the population variance by simple expression as occurs for independent data.
𝑛
Another problem is that the distribution may not be stationary; it is because a simulation run is
started with the system in some initial state, frequently the idle state, in which no service is
being given and no entities are waiting, thus the early arrivals have a more probability of
obtaining service quickly. So a sample mean that includes the early arrivals will be biased. As
the length of the simulation run extended and the sample size increases, the effect of bias will
die out.
figure: Mean wait time in M/M/1 system for different sample sizes
Above figure shows how the expected value of the sample mean depends upon the sample
length, for the M/M/1 system, starting from an initial empty state, with a server utilization of
0.9. Also steady state mean in this case is 8.1. Where mean value is biased below the steady
state value. The bias diminishes as the sample size increases but , even with a sample size of
2,000 , the mean has still only reached about 95% of the steady state value.
Replication of Runs
This approach is used to obtain independent results by repeating simulation. Repeating the
experiment with different random numbers for the same sample size n gives a set of
independent determinations of the sample mean 𝑥̅ (n) .
Even though the distribution of the sample means depends upon the degree of autocorrelation,
this independent determination of sample mean can be used to estimate the variance of the
distribution.
Suppose the experiment is repeated p times with independent random number series. Let xij be
the ith observation in the jth run. Then,
1
Estimates for sample mean , 𝑥̅ j(n) = ∑𝑛𝑖=1 𝑥𝑖𝑗
𝑛
1
Estimates for variance, s2j = ∑𝑛𝑖=1[𝑥𝑖𝑗 − 𝑥𝑗 (𝑛)]2
𝑛−1
Combining the results of p independent measurements gives the following estimates for the
mean waiting time, 𝑥̅ , and the variance, s2 , of the population.
1
𝑥̅ = ∑𝑝𝑗=1 𝑥̅𝑗 (𝑛)
𝑝
1
s2 = ∑𝑝𝑗=1 𝑠𝑗2 (𝑛)
𝑝
The value of is an estimate for the mean waiting time, and s2 can be used to establish a
confidence interval.