Académique Documents
Professionnel Documents
Culture Documents
Instructor:
Associate Professor Guo Zhiling
School of Information Systems
zhilingguo@smu.edu.sg
Agenda Today
Simulating More Data Points
Using Frequency Bins
Using Re-sampling
Using Inverse Distribution
Lesson Outcome
Date and Time Management in Excel
Modeling Queuing System using Simulations
Macro Recording
Exercises
EX57: TimerCliker.xls
EX58: XDBbank.xls
Method 2: Resampling
Resampling discrete data
Use Randbetween(1,N) to generate a position number k.
This number is used to return the kth value in the raw
data collection as if the raw data is already sorted in
ascending order.
X=SMALL(array,k)
X=SMALL(raw data, RNADBETWEEN(1,N))
This ensures that higher frequency results occur more
likely than the lower frequency results.
Randbetween
(1,10)
Number
Frequency
10
Method 2: Resampling
Resampling continuous data
Use Rand() to generate a random number between 0
and 1, to represent the percentile value k.
This percentile value k is used to return the
corresponding percentile number in the raw data
collection.
X=PERCENTILE(array,k)
X=PERCENTILE(raw data, RNAD())
PERCENTILE() sorts and interpolates among the raw
data using the number returned by RAND().
The newly generated data X may be DIFFERENT from
the raw data due to interpolation.
Normal
X = NORMINV(RAND(), mean, std)
returns the X for a given cumulative probability RAND()
Z = NORMSINV(RAND())
returns the Z for a given cumulative probability RAND()
Exponential
X = (-Mean)*LN(RAND())
or X = (-Mean)*LN(1-RAND())
Normal Distribution
NORMDIST(x, mean, standard_dev, cumulative)
x: value of interest
cumulative = true returns CDF, false returns PDF
X = NORMINV(RAND(), mean, std)
Poisson
Distribution
Exponential
Distribution
Distribution Functions
Poisson
POISSON(x, mean, cumulative)
x: number of events; mean: expected value
cumulative = true returns CDF, false returns PMF
Exponential Distribution
EXPONDIST(x, lambda, cumulative)
x: value of interest; lamda: 1/mean
cumulative = true returns CDF, false returns PDF
X = (-Mean)*LN(RAND()) or X = (-Mean)*LN(1-RAND())
60
Date/Day Functions
TODAY()
returns the current date
YEAR(serial_number)
returns the year corresponding to the serial number
Examples:
Wrong: YEAR(14-Jan-05)
OK: YEAR(14-Jan-05)
OK: YEAR(B15) where B15 has value 14-Jan-05
OK: YEAR(39014) = 2006
MONTH(serial_number)
returns the month corresponding to the serial number
How many serial_number will return you the same year?
Same month? Same day?
Date/Day Functions
DAY(serial_number)
returns the day corresponding to the serial number
Examples:
MONTH(39014) = 10, DAY(39014) = 24
So, in fact, 39014 is 24th Oct 2006
DATE(year, month, day)
returns a serial number
WEEKDAY(serial_number, return_type)
Subtracting
WRONG: 14-Jan-05 23-Sep-04
OK: 14-Jan-05 23-Sep-04 = 113
OK: DATE(2005,1,14) DATE(2004,9,23) = 113
Time Functions
Time is stored as the fractional part of the serial
number, that is, the digits to the right of the decimal
point
NOW()
returns the current date and time
E.g. If now is 8:00AM, 25th Dec 2005, then the value of
NOW() is 38711.3333333 where
38711 is the day 25th Dec 2005
3333333 is the time of the day which is 1/3 of the day
So, 8:00AM, 26th Dec 2005 is 38712.3333333
What is the fractional part of noon time?
Time Functions
TIME(hour, minute, second)
returns the serial number to the right of the decimal point in
the format 0.XXXXX
HOUR(serial_number)
MINUTE(serial_number)
SECOND(serial_number)
returns the hour, minute and second of a serial number
respectively
HOUR(39461.847) = 20
0.847 is in fact 8:19:41pm on any day
MINUTE(39461.847) = 19
SECOND(39461.847) = 41
Interarrival
time
Interarrival
time
Arrival time
Wait time
Inter-arrival
time
server
Service
time
Service
End time
Then we compute the inter-arrival time, wait time and service time.
TimerClicker.xls
Step 9 - ON
Step 13 - OFF
Step 8
Step 7
Step 10
15.
Sample Applications:
Count number of vehicles using a stretch of road
E.g. Motorcars, Motocycles, Buses
Simulating Queues
Given observed/historical/raw data, how can we
model and analyse waiting lines?
Use of Re-sampling
Simulate data for inter-arrival and service times via resampling of raw data through observed distributions e.g.
Inverse of Exponential Distribution: -Average*Ln(Rand())
Inverse of Empirical Distribution: Percentile(DataArray,Rand())
Simulating Queues
Some definitions (1 Server)
Inter-Arrival
Time
Service
Time
Obtained
using
Inverse
Exponential
Distribution
Re-sampling from
historical data using
Percentile function
Arrival
Time
Service
Start
End
Wait
Time
System
Time
System
Length
No. in queue =
No. of Service End
Time > Arrival Time
Arrival Time +
Inter-Arrival Time
End Time
Arrival Time
If no one in queue,
= Arrival Time
Else
= End Time of last customer
Start Time
Arrival Time
XDB Bank
Customer
Inter-Arrival
Time
Service
Time
Arrival
Time
Service
Start
End
Wait
Time
System
Time
System
Length
Concatenate() or &
We can concatenate text together to form longer text by
using the function concatenate() or the & sign
Concatenating text is necessary when you need to enter
criteria as text
Example 1:
Concatenate(Microsoft, , Excel) = Microsoft Excel
Microsoft & & Excel = Microsoft Excel
Example 2:
Given that cell A2 stores the number 20 and cell A3 stores
the text Apples
Concatenate(A2, , A3) = 20 Apples
A2 & & A3 = 20 Apples
Countif()
Countif(range, criteria)
Returns the number of cells that satisfy the evaluation
criteria
Range is the range of cells from which you want to count
Criteria is input as text (e.g., <=&D2)
criteria
Return 3
range
3rd largest
10.00am
Server 1
10.05am
Server 2
10.15am
Server 3
=IF(J20>=$E$4,LARGE($G$14:G19,$E$4),E20)
Takeaways
Timer & Clicker
Time-based Simulations
Ways to count arrivals
Application of Time functions
Application of Macro Recording
XDB Bank
Use of observed distribution (Exponential, Empirical)
from raw/historical data to generate simulation of future
trials
Reminders
Project Scope Confirmation with Prof. before the
Recess week
Start working on your project
Next class
Review of Week 1 to Week 7 lessons