Page 1
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 1/31
IS102Computer as an Analysis ToolWeek 6: It’s About Time
Reading:Capter !: "ro#esses and Time
Instru#tor:Asso#iate "ro$essor %uo &ilingS#ool o$ In$ormation Systems'ilingguo(smu)edu)sg
Page 2
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 2/31
Agenda Today
• Simulating *ore +ata "oints
– Using Frequency Bins – Using Re-sampling
– Using Inverse Distribution
• ,esson -ut#ome – Date and Time Management in !cel
– Modeling "ueuing #ystem using #imulations
– Macro Recording
• ./er#ises – $%&' Timer(li)er*!ls
– $%+' $DBban)*!ls
Page 3
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 3/31
Simulating *ore +ata "oints
• *etod 1: sing reuen#y 3ins
– Build (RF table and use R,D./ 0unction to matc1 (RF by
,--4"5 and returns t1e simulated data $2'
.i/ 0requency count or .ii/ percentage o0 occurrence
.iii/ distribution 0unctions
• *etod 2: sing Re7sampling
– Discrete Data' S*A,,.array3 RA8+3.TW..85198/
– (ontinuous Data' ".RC.8TI,..array3 RA8+5/
• *etod : sing In;erse +istribution – Discrete distribution .Uni0orm3 4oisson3 Binomial/
– (ontinuous distribution .Uni0orm3 !ponential3 ormal/
Page 4
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 4/31
*etod 1: reuen#y 3ins
• 5e 0irst compute t1e cumulative relative 0requency .(RF/ o0
data $ and build t1e (RF data• 5e t1en use R,D./ to generate a random number
bet6een 7 and 8
• T1is number is compared 6it1 t1e (RF table using
9oo)up./ and return t1e simulated data $2
#ince a bigger range o0 values 0romR,D./ 6ill 0all 6it1in t1is interval3 7 1ast1e 1ig1est probability o0 turning up
Page 5
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 5/31
*etod 2: Resampling
• Resampling dis#rete data
– Use Randbet6een.83/ to generate a position number )* – T1is number is used to return t1e )t1 value in t1e ra6
data collection as i0 t1e ra6 data is already sorted inascending order*
– T1is ensures t1at 1ig1er 0requency results occur moreli)ely t1an t1e lo6er 0requency results*
$2:#M,99.array3)/$2:#M,99.ra6 data3 R,DBT5.83//
Page 6
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 6/31
An ./ample: Resampling +is#rete +ata
8umber reuen#y
8 ;
; <= =
< 8
8
8
;;
;
;
=
=
=
<
Sorted +ata Randbet<een51910
8
;
=<
%
>
&
+
?
87
Because t1e positionnumber is generatedrandomly3 1ig1er
0requency result .;/6ill occur more o0tent1an lo6er 0requencyresult .</*
Result ; 1as t1e1ig1est probability o0turning up*
Page 7
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 7/31
*etod 2: Resampling
• Resampling #ontinuous data
– Use Rand./ to generate a random number bet6een 7and 83 to represent t1e percentile value )*
– T1is percentile value ) is used to return t1ecorresponding percentile number in t1e ra6 data
collection*
– 4R(TI9./ sorts and interpolates among t1e ra6data using t1e number returned by R,D./*
– T1e ne6ly generated data $2 may be +I.R.8T 0romt1e ra6 data due to interpolation*
$2:4R(TI9.array3)/$2:4R(TI9.ra6 data3 R,D.//
Page 8
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 8/31
*etod : Simulating +ata $rom +istribution
• ni$orm
– $2 : R,DBT5.min3 ma!/ – $2 : min @ R,D./A.ma! – min/
• 8ormal
– $2 : RMIC.R,D./3 mean3 std/
returns t1e $2 0or a given cumulative probability R,D./
– 2 : RM#IC.R,D.//
returns t1e 2 0or a given cumulative probability R,D./
• ./ponential – $2 : .-Mean/A9.R,D.//
– or $2 : .-Mean/A9.8-R,D.//
Page 9
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 9/31
• 8-R*+IST5/9 mean9 standard=de;9 #umulati;e – !' value o0 interest
– cumulative : true returns (DF3 0alse returns 4DF
– $2 : RMIC.R,D./3 mean3 std/
• 8-R*S+IST5' > standard normal – mean : 73 standardEdev:8
– ' value o0 interestG only returns (DF
– 2 : RM#IC.R,D.//
8ormal +istribution
z
Page 10
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 10/31
+i$$erent +istribution un#tions"robability *ass un#tion 5"* Cumulati;e +istribution un#tion 5C+
Cumulati;e +istribution un#tion 5C+"robability +ensity un#tion 5"+
"oisson+istribution
./ponential+istribution
Page 11
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 11/31
+istribution un#tions
• "oisson
– 4I##.!3 mean3 cumulative/• !' number o0 eventsG mean' e!pected value
• cumulative : true returns (DF3 0alse returns 4MF
– !ample' number o0 customers 61o arrive in a store
every 1ourG number o0 emails you receive everyday• ./ponential +istribution
– $4DI#T.!3 lambda3 cumulative/• !' value o0 interestG lamda' 8Hmean
• cumulative : true returns (DF3 0alse returns 4DF• $2 : .-Mean/A9.R,D.// or $2 : .-Mean/A9.8-R,D.//
– !ample' customer inter-arrival timeG email inter-arrivaltimeG 0is1Hbus inter-arrival time
Page 12
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 12/31
+ate and Time *anagement
Page 13
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 13/31
+ate ? Time *anagement in ./#el
• 2 date systems in ./#el 5./#el -ptions @ Ad;an#ed
– 8?77 date system .de0ault/ – 8?7< date system
8?77 date system
8st an 8?77 : 8 ;?t1 Feb 8?77 : >7 8st Mar 8?77 : >8
8?7< date system
8st an 8?7< : 7 ;?t1 Feb 8?7< : %? 8st Mar 8?7< : >7
T1is date does not e!istJ >7
Page 14
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 14/31
+ate+ay un#tions• T-+AB5
– returns t1e current date• B.AR5serial=number
– returns t1e year corresponding to t1e serial number
– !amples'
• 5rong' K,R.8<-an-7%/• L' K,R.8<-an-7%N/
• L' K,R.B8%/ 61ere B8% 1as value 8<-an-7%
• L' K,R.=?78</ : ;77>
• *-8T5serial=number – returns t1e mont1 corresponding to t1e serial number
– Oo6 many serialEnumber 6ill return you t1e same yearP#ame mont1P #ame dayP
Page 15
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 15/31
+ate+ay un#tions• +AB5serial=number
– returns t1e day corresponding to t1e serial number – !amples'
• MTO.=?78</ : 873 D,K.=?78</ : ;<
• #o3 in 0act3 =?78< is ;<t1 ct ;77>
• +AT.5year9 mont9 day – returns a serial number
• W..4+AB5serial=number9 return=type
• Subtra#ting
• 5RQ' 8<-an-7% – ;=-#ep-7<• L' 8<-an-7%N – ;=-#ep-7<N : 88=
• L' D,T.;77%3838</ – D,T.;77<3?3;=/ : 88=
Page 16
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 16/31
Time un#tions
• Time is stored as te $ra#tional part o$ te serial
number9 tat is9 te digits to te rigt o$ te de#imalpoint
• 8-W5
– returns t1e current date and time
– *g* I0 no6 is +'77,M3 ;%t1 Dec ;77%3 t1en t1e value o05./ is =+&88*======= 61ere
• =+&88 is t1e day ;%t1 Dec ;77%
• ======= is t1e time o0 t1e day 61ic1 is 8H= o0 t1e day
– #o3 +'77,M3 ;>t1 Dec ;77% is =+&8;*======= – 51at is t1e 0ractional part o0 noon timeP
Page 17
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 17/31
Time un#tions• TI*.5our9 minute9 se#ond
– returns t1e serial number to t1e rig1t o0 t1e decimal point int1e 0ormat 7*$$$$$
• -R5serial=number
• *I8T.5serial=number• S.C-8+5serial=number
– returns t1e 1our3 minute and second o0 a serial numberrespectively
• OUR.=?<>8*+<&/ : ;7
• MIUT.=?<>8*+<&/ : 8?
• #(D.=?<>8*+<&/ : <8
7*+<& is in 0act +'8?'<8pm on any day
Page 18
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 18/31
*anagement o$ Waiting ,ines
• Dueues arise <en te sort term demand $or ser;i#e
e/#eeds te #apa#ity – Most o0ten caused by random variation in service times and t1etimes bet6een customer arrivals
• Dueuing models are used to: – Describe t1e be1avior o0 queuing systems
– Determine t1e level o0 service to provide – valuate alternate con0igurations 0or providing service
• Simulation is o$ten used to analy'e more #omple/ueuing system
Interarrivaltime
Interarrivaltime
Page 19
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 19/31
-bser;ing Dueues E Re#ording Arri;als
• 5e construct simple macros and assign to buttons to convenientlyrecord arrival time3 service start time and service end time*
• T1en 6e compute t1e inter-arrival time3 6ait time and service time*
TimerCli#ker)/ls
,rrival time
#ervice#tart time
#ervicend time
Inter-arrivaltime
server 5ait time
#ervicetime
Page 20
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 20/31
• Timer
– designed 0or "ueue observation and analysis'• records times
– customer arrival time
– service-start time
– service-end time• tabulates intermediate variables
– inter-arrival time
– #ervice time
– 6aiting time – system times :service @ 6aitingS
-bser;ing Dueues E Re#ording Arri;als
Page 21
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 21/31
Timer E *a#ro to re#ord arri;al time
#teps 8 ;
#tep 87
#tep +
#tep &
#tep 8= - FF
#tep 8<
8*D= : o6./3 c1ange to time 0ormat
;*Fill ,rray (+'+ 6it1 lin) to D=
=*Fill ,rray F+'I+ 6it1 0ormulas
<*Format cells
%*ToolsHMacroHRecord e6 Macro
>*Ley F? (to activate Calculate)
#tep ? -
8%* (reate buttons assign macros tot1em
&* #elect (& and copy
+* #elect (> and )ey (trl-Do6n,rro6
?* #elect Rel* Re0 in Macro Record (ontrol 4anel
87* Ley Do6n,rro6
88* 4aste#pecial CalueumberFormat
8;* Ley sc
8=* Unselect Rel* Re0 in Macro Record #top8<* #top Macro Record
Page 22
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 22/31
• Cli#ker
– Timer 1as limitations' First-(ome-First-#erve3 #ingle #erver – (lic)er is an adaptation o0 Timer
– (ounts arrivals
• records arrival times o0 up to = types o0 customers
•by clic)ing an appropriate button3 one 0or eac1 type o0 customer • tabulates t1eir cumulative 0requency counts 0or given timeintervals .bins/
• c1ange t1e time bins to t1e correct date to capture time stamps
– #ample ,pplications'
• (ount number o0 ve1icles using a stretc1 o0 road
– *g* Motorcars3 Motocycles3 Buses
-bser;ing Dueues E Re#ording Arri;als
Page 23
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 23/31
Simulating Dueues
• %i;en obser;edistori#alra< data9 o< #an <e
model and analyse <aiting linesF
• se o$ Re7sampling – #imulate data 0or inter-arrival and service times via re-
sampling o0 ra6 data t1roug1 observed distributions e*g*• Inverse o0 !ponential Distribution' 7A;erageG,n5Rand5
• Inverse o0 mpirical Distribution' "er#entile5+ataArray9Rand5
• Single Ser;er Dueues ;s *ulti Ser;er Dueues – c1ec)out lines3 0ast 0ood outlets
Page 24
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 24/31
Simulating Dueues
• Some de$initions 51 Ser;er
– Inter-,rrival #ervice ,rrival 5ait #ystem #ystemTime Time Time #tart nd Time Time 9engt1
#ervice
,rrival Time @Inter-,rrival Time
I0 no one in queue3 : ,rrival Timelse : nd Time o0 last customer
#ervice #tart Time @#ervice Time
btainedusing
Inverse
!ponentialDistribution
#tart Time – ,rrival Time
nd Time – ,rrival Time
o* in queue :o* o0 #ervice ndTime V ,rrival Time
Re-sampling 0rom1istorical data using4ercentile 0unction
Page 25
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 25/31
H+3 3ank
• Inter ,rrival Time : – meanA9.R,D.// – simulate using the
Exponential Function
• #ervice Time : 4R(TI9 .service time array3 R,D.//
• ,rrival Time : ,rrival Time o0 previous customer @ Inter ,rrival Time
• #ervice #tart Time : M,$ .previous customer service end time3 arrivaltime/
• #ervice nd Time : #ervice #tart Time @ #ervice Time
• 5ait Time : #ervice #tart Time – ,rrival Time
• #ystem Time : 5ait Time @ #ervice Time or nd Time – ,rrival Time• #ystem queue lengt1 .number o0 customer in t1e system at arrival time/
: (UTIF .all previous customer nd Time V ,rrival Time/
• Tra00ic intensity : service timeHinter arrival time
(ustomer Inter-,rrival #ervice ,rrival 5ait #ystem #ystem
Time Time Time #tart nd Time Time 9engt1
#ervice
Page 26
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 26/31
Con#atenate5 or ?
• 5e can concatenate te!t toget1er to 0orm longer te!t by
using t1e 0unction concatenate./ or t1e sign• (oncatenating te!t is necessary 61en you need to enter
criteria as te!t
• !ample 8'
(oncatenate.Microso0tN3 N3 !celN/ : Microso0t !celN Microso0tN N !celN : Microso0t !celN
• !ample ;'
Qiven t1at cell ,; stores t1e number ;7 and cell ,= stores
t1e te!t ,pplesN (oncatenate.,;3 N3 ,=/ : ;7 ,pplesN
,; N ,= : ;7 ,pplesN
• !cel automatically converts numbers to te!t 61enconcatenating
Page 27
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 27/31
Counti$5
• Counti$5range9 #riteria
– Returns t1e number o0 cells t1at satis0y t1e evaluationcriteria
– Range is t1e range o0 cells 0rom 61ic1 you 6ant to count
– (riteria is input as te!t .e*g*3 W:D;/
criteria
range
Return =
Page 28
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 28/31
H+3 3ank E #7Ser;er • 51en t1ere are more t1an 8 servers
• Model same as be0ore e!cept customer service start time can beearlier
• I0 t1ere are cN number o0 servers3 t1e customer start time 6ill bet1e ct1 largest customer service end time o0 all previous customerservice end times*
87*77am
87*7%am
87*8%am
#erver 8
#erver ;
#erver =
rd largest
I0 0 l i 0
Page 29
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 29/31
-bser;ing Dueues
• Some de$initions 5*ultiple Ser;ers
–
"ro#essing Dueues
:IF.20@>J.JK39,RQ.J%J1K:%1L3XX</3.20/
I0 no* o0 people in queue W no* o0 servers3#ervice #tart Time : ,rrival Time
lse i0 no o0 people in queue V: no* o0 servers3#ervice #tart Time : Time any #erver becomes available
: nt1 largest nd Time 61ere n : no* o0 servers
Page 30
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 30/31
Takea<ays
• Timer ? Cli#ker
– Time-based #imulations – 5ays to count arrivals
– ,pplication o0 Time 0unctions
– ,pplication o0 Macro Recording
• H+3 3ank
– Use o0 observed distribution .!ponential3 mpirical/0rom ra6H1istorical data to generate simulation o0 0uturetrials
Page 31
7/23/2019 CAT Lesson6
http://slidepdf.com/reader/full/cat-lesson6 31/31
Reminders
• "roMe#t S#ope Con$irmation <it "ro$) be$ore te
Re#ess <eek• Start <orking on your proMe#t
• 8e/t #lass
– Revie6 o0 5ee) 8 to 5ee) & lessons