Solutions Simulation 1 20.1-2) The weather can be considered a stochastic system, because it evolves in a probabilistic manner from one day to the next. Suppose for a certain location that this probabilistic evolution satisfies the following: The probability of rain tomorrow is 0.6 if it is raining today. The probability of its being clear tomorrow is 0.8 if it is clear today. a. Use the following uniform random numbers to simulate the evolution of the weather for 10 days, beginning the day after a clear day. b. Repeat using excel and the rand() function to perform the simulation. Day 1 2 3 4 5 6 7 8 9 10 Uniform 0.6996 0.9617 0.6117 0.3948 0.7769 0.5750 0.6271 0.2017 0.7660 0.9918 P{rain tom orrow| rain today} 0.6 P{cleartom orrow| rain today} 0.4 P{clear tom orrow| clear today} 0.8 P{rain tom orrow| clear today} 0.2 Use CDF above CDF Wx Today Rain Clear Wx Tomorrow Rain Clear 0.0 - 0.6 0.6 - 1.0 0.0 - 0.2 0.2 - 1.0 Day 0 1 2 3 4 5 6 7 8 9 10 Uniform 0.6996 0.9617 0.6117 0.3948 0.7769 0.5750 0.6271 0.2017 0.7660 0.9918 Logical If Clear Rain Clear Clear Clear Clear Clear Clear Clear Clear Rain Solutions Simulation 1 20.1-2) Alternate Solution Assume CDF for Rain, Clear is shown as below. Day 1 2 3 4 5 6 7 8 9 10 Probability Tomorrow Weather CDF 1.0 0.8 0.6 Rain 0.4 Clear 0.2 0.0 Rain Clear Weather Today Uniform 0.6996 0.9617 0.6117 0.3948 0.7769 0.5750 0.6271 0.2017 0.7660 0.9918 CDF built on condition CDF Wx Today Rain Clear Wx Tomorrow Rain Clear 0.0 - 0.6 0.6 - 1.0 0.8 - 1.0 0.0 - .08 Day 0 1 2 3 4 5 6 7 8 9 10 Uniform 0.6996 0.9617 0.6117 0.3948 0.7769 0.5750 0.6271 0.2017 0.7660 0.9918 Logical If Clear Clear Clear Clear Clear Clear Clear Clear Clear Clear Rain Solutions Simulation 2 20.1-4) The William Graham Entertainment Co. will be opening a new box office where customers can come to make ticket purchases in advance for the many entertainment events being held in the area. Simulation is being used to analyze whether to have one or two clerks on duty at the box office. While simulating the beginning of a day at the box office, the first customer arrives 5 minutes after it opens and the interarrival times for the next four customers are 3 minutes, 1 minute, and 4 minutes. The service times are 8 minutes, 6 minutes, 2 minutes, 4 minutes, and 7 minutes. a. Plot the no. of customers at the box office over time. b. Estimate L, Lq, W, and Wq for this queueing system. c. Repeat for two clerks. Solutions Simulation 3 20.1-4) solution M/M/1 Queue i 1 2 3 4 5 Ui ------ Ai 5.0 3.0 9.0 1.0 4.0 Ti 5.0 8.0 17.0 18.0 22.0 Ui ------ Si 8.0 6.0 2.0 4.0 7.0 Part No. 0 1 2 3 4 5 Time of Arrival -5.0 8.0 17.0 18.0 22.0 Start Service -5.0 13.0 19.0 21.0 25.0 Depart Time 0 13.0 19.0 21.0 25.0 32.0 Avg = Time in Queue -0.0 5.0 2.0 3.0 3.0 2.600 Time in System -8.0 11.0 4.0 7.0 10.0 8.000 Event Time 0 5.0 8.0 13.0 17.0 18.0 19.0 21.0 22.0 25.0 32.0 Part No. -1 2 1 3 4 2 3 5 4 5 Event Type start arrive arrive depart arrive arrive depart depart arrive depart depart Q(t) 0 0 1 0 1 2 1 0 1 0 0 S(t) 0 1 2 1 2 3 2 1 2 1 0 0.41 1.25 B(t) 0 1 1 1 1 1 1 1 1 1 0 Sum = TimeAvg a.) L = 1.25, Lq = 0.41, Busy Time 0 0 3.0 5.0 4.0 1.0 1.0 2.0 1.0 3.0 7.0 27.0 0.844 20.1-4) solution Number in Queue Q(t) 3 0 0.0 5.0 10.0 15.0 20.0 25.0 30.0 35.0 25.0 30.0 35.0 25.0 30.0 35.0 Time Number in System S(t) 3 0 0.0 5.0 10.0 15.0 20.0 Time Busy/Idle B(t) 2 0 0.0 5.0 10.0 15.0 20.0 Time Solutions Simulation 5 20.3-1) Use the mixed congruential method to generate the following sequence of random numbers. a. 10 one-digit integer numbers such that Xn+1 = (Xn + 3) modulo 10 and Xo = 2. m= a= c= xo = n 0 1 2 3 4 5 6 7 8 9 10 10 1 3 2 xn 2 5 8 1 4 7 0 3 6 9 2 axn + c 5 8 11 4 7 10 3 6 9 12 5 (axn + c)/m 0 0 1 0 0 1 0 0 0 1 0 xn+1 5 8 1 4 7 0 3 6 9 2 5 b. 8 integers (0-7) such that Xn+1 = (5Xn + 1) modulo 8 and Xo = 1. m= a= c= xo = n 0 1 2 3 4 5 6 7 8 9 10 8 5 1 1 xn 1 6 7 4 5 2 3 0 1 6 7 axn + c 6 31 36 21 26 11 16 1 6 31 36 (axn + c)/m 0 3 4 2 3 1 2 0 0 3 4 xn+1 6 7 4 5 2 3 0 1 6 7 4 Solutions Simulation 6 20.3-1) Use the mixed congruential method to generate the following sequence of random numbers. c. 5 two-digit integer numbers such that Xn+1 = (61Xn + 27) modulo 100 and Xo=10. m= a= c= xo = n 0 1 2 3 4 5 6 7 8 9 10 100 61 27 10 xn 10 37 84 51 38 45 72 19 86 73 80 axn + c 637 2284 5151 3138 2345 2772 4419 1186 5273 4480 4907 (axn + c)/m 6.37 22.84 51.51 31.38 23.45 27.72 44.19 11.86 52.73 44.8 49.07 xn+1 37 84 51 38 45 72 19 86 73 80 7 Solutions Simulation 7 20.4-11) Consider the following CDF. 1.0 0.8 .06 0.4 0.2 7 U1 = .2655 X1 = 9.2 U2 = .3472 X2 = 9.5 U3 = .0248 X3 = 7.0 U4 = .9205 X4 = 12.2 U5 = .6130 X5 = 10.5 9 11 13