OPMG 403
Midterm Review
Contents so far!
2. Basics for Modelling:
1. Introduction:
Probability and
Simulation-What, Why
Probability
and How?!
Distributions!
3. Montecarlo 3. Montecarlo
Simulation Simulation-Case Study
5. Discrete Event
4. Discrete Event
Simulation-By Hand or
Simulation
Manual Simulation
Permutations and Combinations (8 candidates applied for different jobs)
a) How many different sequences of 8 candidates are there?.
a) The answer is 8! = 40,320 different ways.
b) What is the number of ways in which 6 candidates can be selected from 8. As the
jobs are different, we are interested in the order of selection, and hence the
permutations. The number of permutations of 6 different jobs from 8 applicants is:
•n Pr = n!/(n-r)! = 8!/(8-6)! = 20,160
c) What is the number of ways in which 6 candidates can be selected from 8, but now
the jobs are identical, so the order of selection is not important. The number of
combinations of 6 identical jobs from 8 applicants is:
• n Cr = n!/r!(n-r)! = 8!/6!(8-6)! = 28
Let's Make a Deal Example (again?)
• Famous Let's Make a Deal problem
• Player is given choice of 3 curtains
• One has a grand prize
• Other two are duds
• After player chooses a curtain, The host shows one of the
other two, which has a dud
• Now player has option to keep the same curtain or to switch to the
remaining curtain
• What should player do?
• At first thought, it seems like it should not matter
4
Let's Make a Deal
• We can look at this axiomatically {Marilyn Vos Savant}
• Initially there is a 1/3 probability that the player's choice is correct and 2/3 that it is
incorrect
• Revealing an incorrect curtain does not change that probability, so if the user does not
switch his/her chance of winning is still 1/3
• However, now what do we know?
• There is a 2/3 chance that the winning curtain is NOT the one originally picked
• Of that 2/3, there is a 0 chance that it is the curtain already revealed
• Therefore, there is a 2/3 chance that the remaining curtain is the winner, so we should switch
to it
• If you are still in doubt, simulate:
Let us make a deal.xlsx
5
Poisson Distribution
• Used to model a random number of events that will occur in an interval of time
• If, ƛ=m=Mean = Variance and x =value of the random variable
x
e
P( X )
X!
• Example
• Number of people logging onto a computer per minute is Poisson Distributed with mean 0.7
• What is the probability that 5 or more people will log onto the computer in the next 10 minutes?
• Solution:
1. Must first convert the mean to the 10-minute period – if mean is 0.7 in 1 minute, it will be (0.7)
(10) = 7 in a ten-minute period
0.30
2. P(X=>5)=1-p(0)-p(1)-p(2)-p(3)-p(4); or using a simple simulation: 0.25
0.20
3. =1- Sum(POISSON.DIST(Xi,7,FALSE), i=1,2,3,4) =0.827008 0.15
0.10
Poisson and Sim 4.xlsx 0.05
6
0.00
1 2 3 4 5 6 7 8 9
Normal Distribution
• It has some nice property:
• First property is that the pdf approaches 0 in both directions
• Second property is that it is symmetric about the mean
• Third property is that the maximum value is also the mean
• Example:
• Student GPA's are approximately normally distributed with =2.4 and =0.8. What
fraction of students will possess a GPA in excess of 3.0?
7
Normal Distribution
Probability density function - f(X)
5 5.05 5.1 5.15 5.2 5.25 5.3 5.35 5.4
1 / 2 ( X ) 2
1
f (X ) e 2
2
11/02/2023
Normal Distribution
• Let Z = (X – 2.4)/0.8
• We want the area under the normal curve with mean 2.4 and standard deviation 0.8 where x
> 3.0
This will be 1 – F(3.0)
F(3.0) = [(3.0 – 2.4)/0.8] = (0.75)
• Looking up (0.75) in distribution Table, we find 0.77337
• Recall that we want 1 – F(3.0), which gives us our final answer of 1 – 0.77337 = 0.2266
Using Excel is much easier
=NORM.DIST(3,2.4,0.8,TRUE) = 0.77337 (fraction of the students with grade less than 3.0)
And then, fraction of student with grade higher than 3.0 = 1 - 0.77337 = 0.226. Note that TRUE
indicate Cumulative (measuring area under the curve)
Note:
1. NORMDIST (x, mu, sigma) returns p (probability)
2. NORMINV (p, mu, sigma) returns x (value)
9
Example
• For weight above 1,100 kg: Z = (1,100 − 950) /
150 = 1, probability = 0.1587
• For weight above 1,250 kg: Z = (1,250 − 950) /
150 = 2, probability = 0.0228
• So the probability that the weight is between
these two is 0.1587 − 0.0228 = 0.1359.
• (d) To find the probability that the weight is
between 800 kg and 1,300 kg we can say:
P(between 800 kg and 1,300 kg) = 1 − P(< 800 kg) −
P(> 1,300 kg)
• For weight below 800 kg: Z = (800 − 950) / 150
= −1, probability = 0.1587
• For weight above 1,300 kg: Z = (1,300 − 950) /
150 = 2.33, probability = 0.0099
• So the probability that the weight is between
these two is 1 − 0.1587 − 0.0099 = 0.8314
Simulation Review
1. A simulation is a model that duplicates the behavior of some real-life
phenomenon.
2. Among the main reasons for the popularity of simulation are the following:
a) Many situations are too complex to permit mathematical modeling.
b) Simulation models are easy to use and to understand.
c) Experimentation is feasible as a means of understanding system behavior without the risks that
would be inherent in real life.
d) Extensive software packages are available.
e) It can be used for a wide range of applications.
f) It has been successfully applied in many instances.
3. Examples include simulating space flight, airplane landings and takeoffs, life
testing of automotive tires and business decision environments.
4. Random numbers provide the element of randomness, or chance, to a
simulation.
5. Simulation is based on the use of random numbers. Consequently, results will typically vary
from trial to trial. In other words, variation is expected. In fact, the variation observed can
provide the decision-maker with a feel for the degree to which results might vary in real life.
A second point is that simulation is not intended to generate solutions per se, but to enable
the decision-maker to better understand a situation and to test alternatives.
6. The main advantages of simulation are:
a. It lends itself to problems where a mathematical solution is not possible or feasible.
b. It permits experimentation with inherent risks.
c. Time is greatly compressed.
d. It can serve as a means of developing understanding and “experience.”
7. Among the limitations of simulation as a decision-making tool are the following:
a. Simulation does not provide an optimal solution, or even a solution. It simply
indicates approximate behavior for a given set of inputs.
b. A large-scale simulation can involve considerable effort and considerable computer
time and cost.
c. Monte Carlo simulation is only applicable in situations which involve chance variables.
Review – Simulation Questions
1. Simulation models are designed to generate optimal solutions, which
can then be applied to real-world situations.
a. True
b. False
2. Simulation can use any probability distribution that the user defines;
it does not require standard distributions.
a. True
b. False
3. Simulation models are limited to using standard probability
distributions such as Poisson, exponential, normal, etc.
a. True
b. False
4. The process of comparing a model to the real system that it represents to make sure it is accurate is
called
a. validation.
b. verification.
c. simulation.
d. experimentation.
5. The process of determining that a computer model is internally consistent and following the logic of the
conceptual model is called
a. validation.
b. verification.
c. simulation.
d. experimentation.
6. Which of the following is not an advantage of simulation?
a. It allows for the study of what-if questions.
b. Each simulation model is unique.
c. It allows the study of interaction of components or variables to determine which ones are important.
d. It allows time compression.
7. Simulation is a trial-and-error approach to problem solving
a. True
b. False
8. A random number mapping always maps a set of occurrences to numbers
between 00 and 99
a. True
b. False
Sim# 1: Use of RN to simulate a Frequency distribution
The number of jobs received by a small shop is to be simulated for a
seven-day period. The shop manager has collected the following data:
• Determine the average number of jobs per day for the seven-day simulation
period.
Sim# 1: Use of RN to simulate a Frequency
distribution
Cumulative Relative Corresponding Rand # of
# Sales Frequency Probability Day #
Frequency RNs # Sales
0 to 2 0 0/200=0.00 0 - 1 84 6
3 10 10/200=0.05 0.05 01 to 05 2 05 3
4 50 50/200=0.25 0.30 06 to 30 3 80 6
5 80 80/200=0.40 0.70 31 to 70 4 37 5
6 40 40/200=0.20 0.90 71 to 90 5 27 4
7 16 16/200=0.08 0.98 91 to 98 6 65 5
8 4 04/200=0.02 1.00 99 to 00 7 93 7
200 1.00 36
Average Number of Sales = 36/7 =5.14
Sim # 2
An analyst concluded that demand for a =Poisson.Dist(0,2,true)=0.135
specific tool can be adequately described
by a Poisson distribution with a mean of
two requests per day. Simulate demand
for a 12-working-day period for this tool. Cumulative Poisson Day
Rand. Requests per
# day
Rand. # 1 917 4
X Prob. Range
Use : 2 264 1
0 .135 001–135
3 045 0
=POISSON.DIST(X,2,TRUE) to get the 1 .406 136–406
4 176 1
probability. The rest is trivial. 2 .677 407–677
5 583 2
3 .857 678–857
6 164 1
4 .947 858–947
7 021 0
5 .983 948–983
8 609 2
6 .995 984–995
9 137 1
7 .999 996–999
10 245 1
8 1.000 000
11 901 4
12 696 3
Sim # 3: Use of RN to simulate
Normal Distribution Patient Rand # Time
1 0.803 21.706
The time a physician spends 2 0.023 16.005
with patients can be 3 0.068 17.012
modeled using a normal
distribution that has a mean 4 0.778 21.530
of 20 minutes and a standard 5 0.403 19.508
deviation of 2 minutes.
Simulate the times the 6 0.523 20.116
doctor might spend with the 7 0.625 20.638
next seven patients.
Sim #4
Jobs are delivered to a workstation at random intervals. The time between job
arrivals tends to be normally distributed with a mean of 15 minutes and a
standard deviation of 1 minute.
Job processing time is also normally distributed with a mean of 14 minutes
per job and a standard deviation of 2 minutes.
a. Simulate the arrival and processing of five jobs. Find the total times jobs wait for
processing.
b. The company is considering the use of new equipment that would result in
processing time that is normal with a mean of 13 minutes and a standard deviation
of 1 minute. Job waiting represents a cost of $3 per minute, and the new
equipment would represent an additional cost of $.50 per minute. Would the
equipment be cost justified? (Note: Use the same arrival times and the same
random numbers for processing times.)
Sim a.#4 Arrivals Service
Job Random # Time Between Arrival Time Waiting Time Service Begins Random # Service Time Service Ends
1 0.33 15+0.33(1) = 15.33 0 15.33 0.51 15.02 30.35
2 –1.76 13.24 28.57 1.78 30.35 1.53 17.06 47.41
3 –0.52 14.48 43.05 4.36 47.41 –0.37 13.26 60.67
4 –0.31 14.69 57.74 2.93 60.67 .26 14.52 75.19
5 –1.04 13.96 71.70 3.49 75.19 –.15 13.70 88.89
Total Time 12.56
Scenario A: Cost of original plan (a)
Cost of waiting = $3 x 12.56 =
$37.68* Service
b. Job Arrival Time Waiting Time Service Begins Service Time Ends
1 15.33 0.0 15.33 13.51 28.84
2 28.57 0.27 28.84 14.53 43.37
3 43.05 0.32 43.37 12.63 56.0
4 57.74 0.0 57.74 13.26 71
5 71.70 0.0 71.7 12.85 84.55
0.59 minutes
Scenario B: Cost of waiting time = 3 x 0.59 = $1.77
Cost of equipment = 0.5 x 84.55 = $42.28
Total Cost = $44.05
Problem Sim #4
Processing
time between arrivals time
mean 15 mean 14
Stdev 1 Stdev 2
max(f(i),i(i-
Start Time = 0 c(i)+f(i-1) 1)) i-f
a b c d e f g i k
Service service time in the
Rand # Interrrival time Rand # Service Time Arrival Time Time Start end system waiting time
1 0.652 15.39 0.041 10.53 15.39 15.39 25.92 10.53 0.00
2 0.763 15.72 0.995 19.20 31.11 31.11 50.30 19.20 0.00
3 0.002 12.16 0.209 12.38 43.27 50.30 62.69 19.42 7.03
4 0.847 16.02 0.696 15.03 59.30 62.69 77.71 18.42 3.39
5 0.798 15.84 0.157 11.99 75.13 77.71 89.70 14.57 2.58
6 0.295 14.46 0.112 11.57 89.59 89.70 101.27 11.68 0.11
7 0.770 15.74 0.682 14.94 105.33 105.33 120.28 14.94 0.00
Totals 105.33 95.64 108.75 13.12
Average 15.05 13.66 15.54 1.87
Amazon’s Return Simulation
• AMZN.xlsx
Contents so far!
2. Basics for Modelling:
1. Introduction:
Probability and
Simulation-What, Why
Probability
and How?!
Distributions!
3. Montecarlo 3. Montecarlo
Simulation Simulation-Case Study
5. Discrete Event
4. Discrete Event
Simulation-By Hand or
Simulation
Manual Simulation