Gaurav Gupta, MBA, CFA, FRM, CAIA, PMP
Gaurav Gupta, MBA, CFA, FRM, CAIA, PMP
  • About
  • Certifications/Accomplishments
  • Models
    • MS Excel - VBA
    • Power BI >
      • Euro Debt Crisis
      • PMO Metrics
      • Sales - Geography
      • UK Bank Customers
    • R (RStudio) >
      • Simulation for Teller Wait Times at a Bank
      • Portfolio Construction Using R
  • Articles
    • Financial Advice
  • Organizations
  • Media And Publications
  • Contact
  • About
  • Certifications/Accomplishments
  • Models
    • MS Excel - VBA
    • Power BI >
      • Euro Debt Crisis
      • PMO Metrics
      • Sales - Geography
      • UK Bank Customers
    • R (RStudio) >
      • Simulation for Teller Wait Times at a Bank
      • Portfolio Construction Using R
  • Articles
    • Financial Advice
  • Organizations
  • Media And Publications
  • Contact

Question_1.R

gaurav

Thu Feb 05 13:41:13 2015

library(triangle)
## Warning: package 'triangle' was built under R version 3.1.2
Data<-read.csv("C:/Users/gaurav/OneDrive/Important/IT 204/Final Exam/Customer Arrival.csv")

b1 <- Data [ Data [ , 1] < 60, ]
b2 <- Data [ Data [ , 1] >= 60  &  Data [ , 1] < 120 , ]
b3 <- Data [ Data [ , 1] >= 120 &  Data [ , 1] < 180 , ]
b4 <- Data [ Data [ , 1] >= 180 &  Data [ , 1] < 240 , ]
b5 <- Data [ Data [ , 1] >= 240 &  Data [ , 1] < 300 , ]
b6 <- Data [ Data [ , 1] >= 300 &  Data [ , 1] < 360 , ]
b7 <- Data [ Data [ , 1] >= 360 &  Data [ , 1] < 420 , ]
b8 <- Data [ Data [ , 1] >= 420 &  Data [ , 1] < 480 , ]

hist(b1$Customer.Service.Time)

hist(b2$Customer.Service.Time)

hist(b3$Customer.Service.Time)

hist(b4$Customer.Service.Time)

hist(b5$Customer.Service.Time)

hist(b6$Customer.Service.Time)

hist(b7$Customer.Service.Time)

hist(b8$Customer.Service.Time)

#To check normality

shapiro.test(b1$Customer.Service.Time)
## 
##  Shapiro-Wilk normality test
## 
## data:  b1$Customer.Service.Time
## W = 0.9414, p-value = 0.4756
shapiro.test(b2$Customer.Service.Time)
## 
##  Shapiro-Wilk normality test
## 
## data:  b2$Customer.Service.Time
## W = 0.9332, p-value = 0.1782
shapiro.test(b3$Customer.Service.Time)
## 
##  Shapiro-Wilk normality test
## 
## data:  b3$Customer.Service.Time
## W = 0.9699, p-value = 0.5362
shapiro.test(b4$Customer.Service.Time)
## 
##  Shapiro-Wilk normality test
## 
## data:  b4$Customer.Service.Time
## W = 0.9854, p-value = 0.9003
shapiro.test(b5$Customer.Service.Time)
## 
##  Shapiro-Wilk normality test
## 
## data:  b5$Customer.Service.Time
## W = 0.9715, p-value = 0.3709
shapiro.test(b6$Customer.Service.Time)
## 
##  Shapiro-Wilk normality test
## 
## data:  b6$Customer.Service.Time
## W = 0.9144, p-value = 0.01123
shapiro.test(b7$Customer.Service.Time)
## 
##  Shapiro-Wilk normality test
## 
## data:  b7$Customer.Service.Time
## W = 0.9792, p-value = 0.719
shapiro.test(b8$Customer.Service.Time)
## 
##  Shapiro-Wilk normality test
## 
## data:  b8$Customer.Service.Time
## W = 0.9437, p-value = 0.05522
#b1 is normal with p>.05
#b2 is normal with p>.05
#b3 is normal with p>.05 
#b4 is normal with p>.05
#b5 is normal with p>.05
#b6 is non-normal with p<.05 
#b7 is normal with p>.05
#b8 is normal with p>.05

b1mean<-mean(b1$Customer.Service.Time)
b1sd<-sd(b1$Customer.Service.Time)

b2mean<-mean(b2$Customer.Service.Time)
b2sd<-sd(b2$Customer.Service.Time)

b3mean<-mean(b3$Customer.Service.Time)
b3sd<-sd(b3$Customer.Service.Time)

b4mean<-mean(b4$Customer.Service.Time)
b4sd<-sd(b4$Customer.Service.Time)

b5mean<-mean(b5$Customer.Service.Time)
b5sd<-sd(b5$Customer.Service.Time)

b6mean<-mean(b6$Customer.Service.Time)
b6min<-min(b6$Customer.Service.Time)
b6max<-max(b6$Customer.Service.Time)

b7mean<-mean(b7$Customer.Service.Time)
b7sd<-sd(b7$Customer.Service.Time)

b8mean<-mean(b8$Customer.Service.Time)
b8sd<-sd(b8$Customer.Service.Time)

#set.seed(888); # fix the random number generator to ensure the same results

timeunits = 480;  # number of hours the windows are open

unitarrivaltime <- numeric(500)
unitservicetime <- numeric (500)  
unitwaittime <- numeric(500)  

arrivaltimes1 <- rnorm(500, b1mean,b1sd)
arrivaltimes2 <- rnorm(500, b2mean,b2sd)
arrivaltimes3 <- rnorm(500, b3mean,b3sd)
arrivaltimes4 <- rnorm(500, b4mean,b4sd)
arrivaltimes5 <- rnorm(500, b5mean,b5sd)
arrivaltimes6 <- rtriangle(500, b6min,b6max, b6mean)
arrivaltimes7 <- rnorm(500, b7mean,b7sd)
arrivaltimes8 <- rnorm(500, b8mean,b8sd)

currentarrivaltime <- 0   
unit = 2;
newarrival = 0;
i = 2;
a = 2
unitarrivaltime[1] <- arrivaltimes1[1]
while ( currentarrivaltime < 480) {
 
  if (currentarrivaltime < 60) { #Block 1
    newarrival <- newarrival + arrivaltimes1[a];
    if (newarrival < 60) {
      unitarrivaltime[i] <- newarrival
      i = i + 1;
      a = a + 1; # increment the arrival unit block;
      next;
    } else {
      currentarrivaltime = 60   # This is just to move us to the next bloc
      newarrival <- unitarrivaltime[i-1]  # This just sets the newarrival time back before the addition 5 lines above      
      a = 1;
    }
  }
  
  if (currentarrivaltime < 120) { #Block 2
    newarrival <- newarrival + arrivaltimes2[a];
    if (newarrival < 120) {
      unitarrivaltime[i] <- newarrival
      i = i+1;
      a = a+1;
      next;
    } else {
      currentarrivaltime = 120   # This is just to move us to the next bloc
      newarrival <- unitarrivaltime[i-1]  # This just sets the newarrival time back before the addition 5 lines above      
      a = 1;
    }
  }
  if (currentarrivaltime < 180) { #Block 3
    newarrival <- newarrival + arrivaltimes3[a];
    if (newarrival < 180) {
      unitarrivaltime[i] <- newarrival
      i = i +1 ;
      a=a+1
      next;
    } else {
      currentarrivaltime = 180   # This is just to move us to the next bloc
      newarrival <- unitarrivaltime[i-1]  # This just sets the newarrival time back before the addition 5 lines above      
      a = 1;
    }
  }
  if (currentarrivaltime < 240) { #Block 4
    newarrival <- newarrival + arrivaltimes4[a];
    if (newarrival < 240) {
      unitarrivaltime[i] <- newarrival
      i = i +1 ;
      a=a+1;
      next;
    } else {
      currentarrivaltime = 240   # This is just to move us to the next bloc
      newarrival <- unitarrivaltime[i-1]  # This just sets the newarrival time back before the addition 5 lines above      
      a = 1;
    }
  }
  if (currentarrivaltime < 300) { #Block 5
    newarrival <- newarrival + arrivaltimes3[a];
    if (newarrival < 300) {
      unitarrivaltime[i] <- newarrival
      i = i +1 ;
      a=a+1
      next;
    } else {
      currentarrivaltime = 300   # This is just to move us to the next bloc
      newarrival <- unitarrivaltime[i-1]  # This just sets the newarrival time back before the addition 5 lines above      
      a = 1;
    }
  }
  if (currentarrivaltime < 360) { #Block 6
    newarrival <- newarrival + arrivaltimes3[a];
    if (newarrival < 360) {
      unitarrivaltime[i] <- newarrival
      i = i +1 ;
      a=a+1
      next;
    } else {
      currentarrivaltime = 360   # This is just to move us to the next bloc
      newarrival <- unitarrivaltime[i-1]  # This just sets the newarrival time back before the addition 5 lines above      
      a = 1;
    }
  }
  if (currentarrivaltime < 420) { #Block 7
    newarrival <- newarrival + arrivaltimes3[a];
    if (newarrival < 420) {
      unitarrivaltime[i] <- newarrival
      i = i +1 ;
      a=a+1
      next;
    } else {
      currentarrivaltime = 420   # This is just to move us to the next bloc
      newarrival <- unitarrivaltime[i-1]  # This just sets the newarrival time back before the addition 5 lines above      
      a = 1;
    }
  }
  if (currentarrivaltime < 480) { #Block 8
    newarrival <- newarrival + arrivaltimes3[a];
    if (newarrival < 480) {
      unitarrivaltime[i] <- newarrival
      i = i +1 ;
      a=a+1
      next;
    } else {
      currentarrivaltime = 480   # This is just to move us to the next bloc
      newarrival <- unitarrivaltime[i-1]  # This just sets the newarrival time back before the addition 5 lines above      
      a = 1;
    }
  }
}

# This has the arrival time
unitarrivaltime
##   [1]   5.111557   3.651681   8.360488  14.720223  18.834430  23.888650
##   [7]  28.324277  33.021344  38.797706  46.370278  52.140391  57.906660
##  [13]  60.225018  64.157432  65.025446  67.211981  67.027117  72.036788
##  [19]  75.954366  78.199453  80.817149  84.028093  88.888333  92.995325
##  [25]  95.506049  95.841992  99.687904 101.720759 103.151910 104.532769
##  [31] 107.275914 109.805002 113.063747 116.195453 118.686455 120.314112
##  [37] 124.131445 126.398445 127.969865 129.165008 130.946681 131.777156
##  [43] 133.844124 134.022009 135.292202 138.247346 139.864065 143.671187
##  [49] 147.250388 150.294348 152.661206 154.277556 157.597987 160.205946
##  [55] 163.266068 165.533542 168.271391 168.251972 171.410451 172.280100
##  [61] 174.282247 178.630970 178.786045 181.652098 182.928269 184.708825
##  [67] 185.948797 187.849500 189.512526 190.636547 192.693796 194.365998
##  [73] 195.136283 196.389843 197.798286 199.604853 200.974930 202.607184
##  [79] 204.103591 205.765023 207.975040 211.235898 212.456817 214.264066
##  [85] 216.455012 218.008916 219.802983 222.438195 224.704170 224.998970
##  [91] 227.016172 227.634116 228.738021 229.761045 231.458977 232.963753
##  [97] 233.981672 235.106144 236.653855 238.455442 240.946445 242.574102
## [103] 246.391435 248.658435 250.229855 251.424998 253.206671 254.037145
## [109] 256.104114 256.281998 257.552192 260.507335 262.124054 265.931176
## [115] 269.510377 272.554338 274.921195 276.537546 279.857977 282.465936
## [121] 285.526058 287.793532 290.531381 290.511961 293.670440 294.540090
## [127] 296.542237 299.033240 300.660896 304.478229 306.745229 308.316649
## [133] 309.511792 311.293466 312.123940 314.190909 314.368793 315.638986
## [139] 318.594130 320.210849 324.017971 327.597172 330.641132 333.007990
## [145] 334.624341 337.944772 340.552730 343.612852 345.880326 348.618176
## [151] 348.598756 351.757235 352.626885 354.629032 358.977754 359.132829
## [157] 361.623832 363.251489 367.068822 369.335822 370.907242 372.102385
## [163] 373.884058 374.714532 376.781501 376.959385 378.229579 381.184722
## [169] 382.801441 386.608563 390.187764 393.231725 395.598582 397.214933
## [175] 400.535364 403.143323 406.203445 408.470919 411.208768 411.189348
## [181] 414.347827 415.217477 417.219624 419.710627 421.338283 425.155616
## [187] 427.422616 428.994036 430.189179 431.970853 432.801327 434.868296
## [193] 435.046180 436.316373 439.271517 440.888236 444.695358 448.274559
## [199] 451.318519 453.685377 455.301728 458.622159 461.230117 464.290239
## [205] 466.557713 469.295563 469.276143 472.434622 473.304272 475.306419
## [211] 479.655141 479.810216   0.000000   0.000000   0.000000   0.000000
## [217]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [223]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [229]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [235]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [241]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [247]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [253]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [259]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [265]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [271]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [277]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [283]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [289]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [295]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [301]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [307]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [313]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [319]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [325]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [331]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [337]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [343]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [349]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [355]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [361]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [367]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [373]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [379]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [385]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [391]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [397]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [403]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [409]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [415]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [421]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [427]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [433]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [439]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [445]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [451]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [457]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [463]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [469]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [475]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [481]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [487]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [493]   0.000000   0.000000   0.000000   0.000000   0.000000   0.000000
## [499]   0.000000   0.000000
# only take units that have arrived 
# only take units that waited in queue
unitsarrived <- unitarrivaltime[unitarrivaltime > 0]

currenttime = 0; 
unitserviced = 1;
entityleavetime = 0;

# These two are defined above
# unitwaittime <- numeric(1000)
# unitservicetime <- numeric(1000)

for (i in 1:480) {
  repeat {
    if (unitserviced == length(unitsarrived)) { break; }
    if (unitsarrived[unitserviced]< i) {
      entityarrivaltime = unitsarrived[unitserviced];
      if (entityarrivaltime < entityleavetime) {
        waittime = entityleavetime - entityarrivaltime;
      } else {
        waittime = 0;
      }
      entityservicetime = runif(1,3,12); #how long is entity serviced
      unitservicetime[unitserviced] <- entityservicetime
      entityleavetime = entityarrivaltime + entityservicetime;
      # currenttime  = entityleavetime;
      unitserviced = unitserviced + 1;
      unitwaittime [unitserviced] = waittime;
    } else {
      break;
    } 
  } # end repeat
} # end for

# At this point The following have all the information needed

unitwaittime
##   [1]  0.0000000  0.0000000  8.5547218  3.9013592  2.0006966  7.1585931
##   [7]  1.8619414  6.6608819  0.0000000  3.1763665  0.6212440  0.0000000
##  [13]  0.0000000  5.3826285  0.0000000  2.8550555  4.2945197  7.4615212
##  [19]  2.1614240  0.0000000  4.3839543  2.2268543  4.2810184  3.9234434
##  [25]  0.0000000  6.3330895  3.5375666  2.7433233  5.5239319  3.4789736
##  [31]  4.0832213  4.5811641  5.7531656  4.4891003  0.7516862  8.3006723
##  [37]  3.2334071  8.0701006  4.2709729  6.6846315  2.6953132  2.4190379
##  [43]  3.6364682  8.7086592 10.6546627  8.9903358  5.2504889  6.7378526
##  [49]  7.2015413  5.6483711  5.3946580  3.6656380  5.1891614  6.4712820
##  [55]  5.2714154  8.3085261  1.6857684  2.0497939  4.4158936  2.8854393
##  [61] 10.1905268  7.1615591  6.0890234 11.0280819  6.1948591  8.2848646
##  [67]  9.3764497  6.4775842  5.8434924 10.2684920  3.8744430  5.9394382
##  [73]  2.7124820  4.0942001 10.2223480  9.8350594  7.4023559  6.7899853
##  [79]  9.6449955  1.9862846  8.6876623  3.3014513  7.0122246  4.1887376
##  [85]  8.2426076  5.7616058  5.2139869  7.7138957  3.0077554  0.9553304
##  [91]  3.1817976  2.2269752  6.3780745 10.5582620  9.8112181  1.3569526
##  [97]  2.3588786 10.9150619  5.8248414  5.0167477  6.9352582  6.5634758
## [103]  9.6621871  3.7622730  6.2205631  7.8785138  3.7246276 10.1901510
## [109] 10.0595117  2.1392534  3.5437821  7.9692818  1.1733574  3.1928055
## [115]  7.1897206  6.8509973  7.1611127  4.2165121  7.3392641  1.5525160
## [121]  3.1142655  5.4029914  7.2309473  2.4793566  5.7732348  7.9843667
## [127]  4.5653933  9.4119627  1.7105992  4.8786062  5.9217562  9.4918921
## [133]  5.2283402  8.9713187  7.4164107  5.1691159  8.7807408  8.5254385
## [139]  2.5143505  7.2514485  9.3976007  7.6505509  4.5540394  8.1160067
## [145]  9.4506168  2.0526236  3.8173133  6.5491598  3.3544455  1.7592863
## [151]  3.9373835  8.1211666  7.7062232  4.0542288  1.3597943  0.6832806
## [157]  4.1897211  3.6287115  9.2306431  4.9465530  7.1098159  4.9594063
## [163]  4.3653340  3.9012447  6.8564646  7.3936201  2.8353803  9.1606118
## [169]  8.0468658  5.5438606  7.3948494  0.1123098  6.1639862  4.0429834
## [175]  3.6729325  0.4522712  0.8010142  0.8732942  8.3951524  4.8279447
## [181]  4.1124446  0.1017356  4.8489940  6.4437993  0.6553862  5.6389520
## [187]  6.1633333  3.5324569  7.7673207  2.0307530  3.9717252  5.7767792
## [193]  2.4588025  2.9818843  9.5492499  4.6252473  5.4737270  0.7130251
## [199]  1.1956631  6.5066428  6.2152747  4.5211725  3.5192205  4.6754710
## [205]  8.2534898  3.9550625  0.7932997  6.0972655  1.9971258 10.8231174
## [211]  6.9409962  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [217]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [223]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [229]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [235]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [241]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [247]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [253]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [259]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [265]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [271]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [277]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [283]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [289]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [295]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [301]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [307]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [313]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [319]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [325]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [331]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [337]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [343]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [349]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [355]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [361]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [367]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [373]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [379]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [385]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [391]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [397]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [403]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [409]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [415]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [421]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [427]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [433]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [439]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [445]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [451]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [457]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [463]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [469]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [475]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [481]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [487]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [493]  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000  0.0000000
## [499]  0.0000000  0.0000000
unitservicetime
##   [1]  7.094846  8.610166  8.360431 11.272801  6.916161 11.096509  3.626124
##   [8]  8.952729  8.193816  3.079926  5.092680  7.700987  3.413667  3.723069
##  [15]  6.481055  7.276657  7.171095  3.051364  6.629041  4.844550  7.491962
##  [22]  8.783684  3.833397  8.843814  3.873510  6.589235  7.556787  4.910124
##  [29]  5.464080  7.324310  8.282253  7.747845  3.883392 10.791675  4.861064
##  [36] 11.887434  6.537973  8.256052  3.890456  4.200711  4.466942 10.775628
##  [43] 10.832547 10.260529  8.205632  8.354572 11.008663  9.227572  8.438618
##  [50]  6.032496  6.805512  9.791713  7.879374 11.368648  3.953242  4.787643
##  [57]  4.396474  6.043918 11.060177  9.163706 10.437746 11.183157  9.060912
##  [64]  9.561036 11.157005  7.717556  7.744196 11.931518  4.998464  7.996688
##  [71]  4.384684  4.864485 11.475908 11.243502  9.208923  8.160062 11.277250
##  [78]  3.482692 10.349094  5.511468 10.273082  5.409657 10.049857  7.952552
##  [85]  6.767891  9.507963  5.642968  3.221305  3.476598  4.244177  6.996018
##  [92] 11.662167 10.834242  3.054885  3.863654 11.932981  6.949313  6.564459
##  [99]  8.736846  9.054479 11.289844  7.579606  8.487563  9.449934  4.919771
## [106] 11.971824 10.889986  4.206222  3.721667  9.239475  4.128501  4.809524
## [113] 10.996843 10.430198 10.205073  6.583370  8.955615  4.872947  5.722224
## [120]  8.463114  9.498421  5.217206  5.753815 11.142846  5.435043 11.414110
## [127]  4.201602  6.506263  9.739089 11.758892  6.799760 10.166462  9.198084
## [134]  5.999590 10.847709  8.703323  3.784544 10.206592 11.014320 11.457673
## [141]  8.133240 11.159967 11.817475  3.668974  7.137744  9.157119  6.414568
## [148]  4.026760  6.675233  8.101747 10.864702  4.923879  3.361941  5.032003
## [155]  4.344796  6.119714 10.858300  8.763886  9.376816  6.530826  5.560477
## [162]  5.682918  7.686939  9.460589  3.013265 10.430805 11.002009  7.160579
## [169] 11.201971  3.691511  9.207947  6.409841  5.289283  3.772702  3.408973
## [176]  3.933416 10.662626  7.565794  4.093025  3.260214  5.718644  8.445946
## [183]  3.146389  7.266609  9.980666  5.799457  9.338741  3.225896  5.753399
## [190]  6.607253  4.525771  3.159769 10.819443  7.580391  7.090446  4.520147
## [197]  4.774864  9.550603  8.582132  6.137523  6.839651  7.283430 11.313612
## [204]  6.222536  3.531149  6.077846  5.155605 11.692767  8.943143  3.431344
## [211]  3.189541  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [218]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [225]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [232]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [239]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [246]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [253]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [260]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [267]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [274]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [281]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [288]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [295]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [302]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [309]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [316]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [323]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [330]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [337]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [344]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [351]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [358]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [365]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [372]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [379]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [386]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [393]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [400]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [407]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [414]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [421]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [428]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [435]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [442]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [449]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [456]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [463]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [470]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [477]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [484]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [491]  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000  0.000000
## [498]  0.000000  0.000000  0.000000
unitsarrived
##   [1]   5.111557   3.651681   8.360488  14.720223  18.834430  23.888650
##   [7]  28.324277  33.021344  38.797706  46.370278  52.140391  57.906660
##  [13]  60.225018  64.157432  65.025446  67.211981  67.027117  72.036788
##  [19]  75.954366  78.199453  80.817149  84.028093  88.888333  92.995325
##  [25]  95.506049  95.841992  99.687904 101.720759 103.151910 104.532769
##  [31] 107.275914 109.805002 113.063747 116.195453 118.686455 120.314112
##  [37] 124.131445 126.398445 127.969865 129.165008 130.946681 131.777156
##  [43] 133.844124 134.022009 135.292202 138.247346 139.864065 143.671187
##  [49] 147.250388 150.294348 152.661206 154.277556 157.597987 160.205946
##  [55] 163.266068 165.533542 168.271391 168.251972 171.410451 172.280100
##  [61] 174.282247 178.630970 178.786045 181.652098 182.928269 184.708825
##  [67] 185.948797 187.849500 189.512526 190.636547 192.693796 194.365998
##  [73] 195.136283 196.389843 197.798286 199.604853 200.974930 202.607184
##  [79] 204.103591 205.765023 207.975040 211.235898 212.456817 214.264066
##  [85] 216.455012 218.008916 219.802983 222.438195 224.704170 224.998970
##  [91] 227.016172 227.634116 228.738021 229.761045 231.458977 232.963753
##  [97] 233.981672 235.106144 236.653855 238.455442 240.946445 242.574102
## [103] 246.391435 248.658435 250.229855 251.424998 253.206671 254.037145
## [109] 256.104114 256.281998 257.552192 260.507335 262.124054 265.931176
## [115] 269.510377 272.554338 274.921195 276.537546 279.857977 282.465936
## [121] 285.526058 287.793532 290.531381 290.511961 293.670440 294.540090
## [127] 296.542237 299.033240 300.660896 304.478229 306.745229 308.316649
## [133] 309.511792 311.293466 312.123940 314.190909 314.368793 315.638986
## [139] 318.594130 320.210849 324.017971 327.597172 330.641132 333.007990
## [145] 334.624341 337.944772 340.552730 343.612852 345.880326 348.618176
## [151] 348.598756 351.757235 352.626885 354.629032 358.977754 359.132829
## [157] 361.623832 363.251489 367.068822 369.335822 370.907242 372.102385
## [163] 373.884058 374.714532 376.781501 376.959385 378.229579 381.184722
## [169] 382.801441 386.608563 390.187764 393.231725 395.598582 397.214933
## [175] 400.535364 403.143323 406.203445 408.470919 411.208768 411.189348
## [181] 414.347827 415.217477 417.219624 419.710627 421.338283 425.155616
## [187] 427.422616 428.994036 430.189179 431.970853 432.801327 434.868296
## [193] 435.046180 436.316373 439.271517 440.888236 444.695358 448.274559
## [199] 451.318519 453.685377 455.301728 458.622159 461.230117 464.290239
## [205] 466.557713 469.295563 469.276143 472.434622 473.304272 475.306419
## [211] 479.655141 479.810216
mean(unitwaittime)
## [1] 2.176216
mean(unitservicetime)
## [1] 3.117661
# To determine which block use the arrival times 
length_b1 <- length( unitsarrived [unitsarrived < 60]) 
length_b2 <- length( unitsarrived [unitsarrived >= 60 & unitsarrived <120])  
length_b3 <- length( unitsarrived [unitsarrived >= 120 & unitsarrived <180])  
length_b4 <- length( unitsarrived [unitsarrived >= 180 & unitsarrived <240])   
length_b5 <- length( unitsarrived [unitsarrived >= 240 & unitsarrived <300])  
length_b6 <- length( unitsarrived [unitsarrived >= 300 & unitsarrived <360])   
length_b7 <- length( unitsarrived [unitsarrived >= 360 & unitsarrived <420])
length_b8 <- length( unitsarrived [unitsarrived >= 420 & unitsarrived <480])   

mean(unitwaittime[1:length_b1])#Average wait time for the entities in block 1
## [1] 2.827984
mean(unitwaittime[length_b1+1:length_b2])#Average wait time for the entities in block 2
## [1] 3.401984
mean(unitwaittime[length_b2+1:length_b3])#Average wait time for the entities in block 3
## [1] 5.110566
mean(unitwaittime[length_b3+1:length_b4])#Average wait time for the entities in block 4
## [1] 5.599064
mean(unitwaittime[length_b4+1:length_b5])#Average wait time for the entities in block 5
## [1] 5.963217
mean(unitwaittime[length_b5+1:length_b6])#Average wait time for the entities in block 6
## [1] 5.552301
mean(unitwaittime[length_b6+1:length_b7])#Average wait time for the entities in block 7
## [1] 5.552301
mean(unitwaittime[length_b7+1:length_b8])#Average wait time for the entities in block 8
## [1] 5.552301
mean(unitservicetime[1:length_b1])#Average service time for the entities in block 1
## [1] 7.499765
mean(unitservicetime[length_b1+1:length_b2]) #Average service time for the entities in block 2
## [1] 6.209897
mean(unitservicetime[length_b2+1:length_b3]) #Average Service time for the entities in block 3
## [1] 7.475337
mean(unitservicetime[length_b3+1:length_b4]) #Average service time for the entities in block 4
## [1] 8.037316
mean(unitservicetime[length_b4+1:length_b5]) #Average service time for the entities in block 5
## [1] 8.235739
mean(unitservicetime[length_b5+1:length_b6]) #Average service time for the entities in block 6
## [1] 7.689878
mean(unitservicetime[length_b6+1:length_b7]) #Average service time for the entities in block 7
## [1] 7.689878
mean(unitservicetime[length_b7+1:length_b8]) #Average service time for the entities in block 8
## [1] 7.689878
length_b1 #entities serviced in 1st hour
## [1] 12
length_b2 #entities serviced in 2nd hour
## [1] 23
length_b3 #entities serviced in 3rd hour
## [1] 28
length_b4 #entities serviced in 4th hour
## [1] 37
length_b5 #entities serviced in 5th hour
## [1] 28
length_b6 #entities serviced in 6th hour
## [1] 28
length_b7 #entities serviced in 7th hour
## [1] 28
length_b8 #entities serviced in 8th hour
## [1] 28
Proudly powered by Weebly