Professional Documents
Culture Documents
Simulation 3.2
Simulation 3.2
IB3200 Lecture
Sampling from
distributions:
1. Empirical continuous
distributions.
Dr Katy Hoad
http://www.wbs.ac.uk/about/person/Kathryn-Hoad/
Join at vevox.app
Or
Search Vevox in the app store
ID: 152-860-971
[8,10) 7% 91 84-90
[10,12) 5% 96 91-95
[12,14) 2% 98 96-97
9
• What would be our first simulated activity time?
Use these two random numbers streams:
62 43 55 21 50 8 23 71 97
15 70 35 52 7 60 78 76 76
Random
Activity time
• Can further refine the sampled numbers
activity time by further dividing up 0 [4.00, 4.01)
the selected activity time range. 1 [4.01, 4.02)
• For example, divide [4,5) into 100 2 [4.02, 4.03)
smaller intervals = 100th of a minute
each.
54 [4.54, 4.55)
• Sample from this using another
random number: 55 [4.55, 4.56)
55 → 55th hundredth = 4.55 mins.
98 [4.98, 4.99)
99 [4.99, 5.00)
10
Sampling Exercise
• Use these random number streams to obtain the next 5 activity
times & hence complete the table: Random Activity time
numbers range (mins)
62 43 55 21 50 8 23 71 97
0-49 1st min
15 70 35 52 7 60 78 76 76
50-99 2nd min
Activity duration Random Activity time
numbers range (mins)
1 4.55 mins
0-9 [0,2)
2 10-46 [2,4)
47-69 [4,6)
3
70-83 [6,8)
4 84-90 [8,10)
91-95 [10,12)
5
96-97 [12,14)
6 98-99 [14,16)
11
Join: vevox.app ID: 152-860-971
Coming next…
12
Simulation
IB3200
Sampling from
distributions:
2. Empirical discrete
distributions.
Dr Katy Hoad
http://www.wbs.ac.uk/about/person/Kathryn-Hoad/
Gym exercise decisions:
Decision rules
Discrete empirical distribution
Number of
Exercise Route
decision customers
(frequency)
Run 1 50
Cycle 2 30
Row 3 20
Total 100
Cumulative Random
Route Probability
probability Numbers
1. Run 0.5 0.5
2. Cycle 0.3 0.8
3. Row 0.2 1
15
Join: vevox.app ID: 152-860-971
Gym exercise decisions:
Here are two random numbers streams:
0.35 0.56 0.68 0.14 0.05 0.03 0.12 0.71 0.97
0.15 0.70 0.35 0.52 0.07 0.60 0.78 0.76 0.86
• What would be our first simulated activity decision (route)?
Cumulative Random
Route Probability
probability Numbers
1. Run 0.5 0.5
2. Cycle 0.3 0.8
3. Row 0.2 1
Cumulative Random
Route Probability
probability Numbers
1. Run 0.5 0.5
2. Cycle 0.3 0.8
3. Row 0.2 1
Dr Katy Hoad
http://www.wbs.ac.uk/about/person/Kathryn-Hoad/
Inverse-transformation method
• If the inverse of the cumulative function (CDF) F(x) of a
distribution exists we can use this inverse to randomly
sample values (x) from the chosen probability
distribution.
PDF
0.00 0.46 0.92 1.38 1.84 2.30 2.76 3.22 3.68 4.14
• Using the given random number stream and the Inverse of the
Exponential distribution: , we can sample inter-arrival
times for the arrival process in our gym simulation model.
28
Join: vevox.app ID: 152-860-971
Time between
arrivals
Gym example
revisited…
29
Join: vevox.app ID: 152-860-971
Time between
arrivals
Gym example
revisited…
30
Join: vevox.app ID: 152-860-971
Representing Variability Summary
32
Next…
33
Simulation
IB3200
Exercises – manual
simulations with
sampling
Dr Katy Hoad
http://www.wbs.ac.uk/about/person/Kathryn-Hoad/
Exercise 1 – manual simulation
• Fast Track Ltd run a quick fitting service for car
exhausts, tyres and batteries. At present, they only
have one fitting bay, but would like to invest in a
second.
• They have collected some data (time unit used is
minutes) on the pattern of customer arrivals and
used this to estimate the following distribution of
time between arrivals: Exponential (λ = 0.08)
• It takes either 10 or 20 minutes (with equal
probability) to complete a service.
35
Exercise 1 – manual simulation
• Complete the table below, using the random numbers stated
in the table, to sample the arrival times and service times for
the first five customer arrivals (assume the simulation clock
starts at time 9.00 am)
Customer Random Time Between Arrival Random Service
Number Number Arrivals Time Number Time
(minutes) (HH:MM) (minutes)
9:00
1 0.256 0.802
2 0.612 0.150
3 0.801 0.642
4 0.091 0.324
5 0.510 0.947
36
Exercise 1 – manual simulation
• Transfer your calculated arrival times and service times to the
table below and simulate the system for the first five
customers arriving. Determine the total time that the five
customers have to queue.
Customer Arrival Time Service Start Finish Queuing
Number (HH:MM) Time (mins) Service Service Time (mins)
(HH:MM) (HH:MM)
1
5
37
Exercise 1 – manual simulation
• What is the average queuing time?
38
Exercise 2 – manual simulation
NOW REPEAT THIS EXERCISE BUT WITH INCREASED PRECISION
– SO WE NOW WORK WITH SECONDS RATHER THAN MINUTES
• Fast Track Ltd run a quick fitting service for car exhausts,
tyres and batteries. At present, they only have one fitting
bay, but would like to invest in a second.
39
Exercise 2 – manual simulation
• Complete the table below, using the random numbers stated
in the table, to sample the arrival times and service times for
the first five customer arrivals (assume the simulation clock
starts at time 9am). Round to the nearest whole second.
Customer Random Time Between Arrival Time Random Service Time
Number Number Arrivals (secs) (HH:MM:SS) Number (seconds)
9:00:00
1 0.256 0.802
2 0.612 0.150
3 0.801 0.642
4 0.091 0.324
5 0.510 0.947
40
Exercise 2 – manual simulation
• Transfer your calculated arrival times and service times to
the table below and simulate the system for the first five
customers arriving. Determine the total time that the five
customers have to queue.
Customer Arrival Time Service Start Service Finish Service Queuing
Number (HH:MM:SS) Time (secs) (HH:MM:SS) (HH:MM:SS) Time
1
2
3
4
5
41
Exercise 2 – manual simulation
• What is the average queuing time?