need to do only question no. 3 using R- software. deadline : 28th may

need to do only question no. 3 using R- software. deadline : 28th may

STATS 320 Assignment 4 Due: 2pm, Thu 4 Jun 2015 1. [12 marks] Visitors arrive at a security checkpoint according to a Poisson process of rate 2 per minute. There is only one security guard at service and the individual service times are only known to be random with a mean 25 seconds and a standard deviation 40 seconds. (a) [3 marks] Explain why this can not be an M/M/1 queue. (b) [3 marks] Find the proportion of the time the security guard is busy. (c) [3 marks] Suppose the checkpoint opens at 8am. How long on average should a visitor who arrives in the afternoon wait in the queue before being examined? (d) [3 marks] How long on average does the security guard need to work continuously before having a break? 2. [20 marks] Cars arrive at a police breath alcohol testing station in a Poisson stream with rate 5 per minute. Suppose there are two policemen available for testing the drivers and the time (in minutes) for a policeman to conduct the test has an Erlang distribution Γ(2, 3). To not inconvenience drivers too much, if there are 6 cars in the queue (including being tested), arriving cars are waved through without joining the queue. All inter-arrival times and service times are independent. Let N(t) be the number of cars in the queue at time t (minutes), starting with N(0) = 0. Further, let L(t) = E{N(t)}, i.e., the expected number of cars in the queue at time t. (a) [10 marks] Write an R programme that simulates this queue, and plot a random realization of N(t) for the first 20 minutes. (b) [5 marks] Based on simulation, estimate L(2) and L(5). (c) [5 marks] Based on simulation, estimate L in steady-state. 1 3. [25 marks] In this question, we investigate the effectiveness of ramp metering, using a very simplistic model. It is simplistic because only a road between points A and B is considered. At point A, there is a traffic signal that may be switched on so that one vehicle is allowed to enter the road when the light turns green, or switched off so that vehicles can enter without restriction. During rush hours, vehicles arrive at point A in a Poisson stream with rate λ per minute. Inter-departure times of vehicles at point B follow an exponential distribution with rate µ per minute that depends on N(t), the number of vehicles on the road at time t, as follows: µ(N) = µ0 × N N0 × α(N) where α(N) = 1, if N ≤ N0; exp{β(1 − N/N0)}, otherwise. The above formulae essentially mean that the traffic speed is not affected when N ≤ N0, but it is slowed down by a factor of α(N) when N > N0. Furthermore, the road has a capacity of U vehicles, meaning that no vehicle can enter the road if the capacity is reached. Answer the following questions, using λ = 12, µ0 = 10, N0 = 100, β = 0.8 and U = 300. (a) [5 marks] When the traffic signal is switched off, compute the expected time that a vehicle takes to travel the entire length of the road in steady-state during rush hours. You should use R, rather than a calculator, for the computing involved, but no simulation is needed. 2 (b) [10 marks] At 6:30am, there are 80 vehicles already on the road and the traffic signal remains off, use simulation to find when in expectation the 1000th of the vehicles that arrive at point A after 6:30am will depart the road at point B. (c) [10 marks] Re-do Part (b), but under the conditions that the traffic signal is switched on at 6:30am and that it turns green after every 7 seconds. To make programming a bit easier, you may assume that there is always a vehicle waiting to enter the road when the light turns green. 4. [12 marks] Consider the continuous-time Markov chain with state space S = {0, 1, 2} and transition intensity matrix Q =   −4 2 2 2 −3 1 0 3 −3   . (a) [3 marks] Starting with state 2, what is the probability that the next three transitions are 2 → 1 → 0 → 2? (b) [3 marks] Starting with state 2, what is the probability that the chain returns to state 2 after two transitions? (c) [3 marks] Find the stationary distribution of the Markov chain. (d) [3 marks] What is the expected number of transitions from state 0 to state 1 during a 60-time-unit run of the chain in steady-state? 3

STATS 320 Tutorial, Week 9 15 May 2015 1. Patients arrive at an accident and emergency medical clinic in a Poisson stream of rate 4 per hour. There are two doctors on duty and the time that takes a doctor to help a patient is exponentially distributed with mean 20 minutes. Let N(t) be the number of patients in the clinic at time t. (a) In aid of simulation, estimate the probability that there are at least 3 customers in the queueing system, at t = 3 hours. You can make use of the R code from the tutorial in Week 8. (b) Provide a 95% confidence interval for the above estimated probability. (c) Compute by hand the above probability, but in steady-state. (d) Explain why the second probability should be greater than the first. Answer: (a) # Simulate the M/M/2 queue, via time and type of next event mm2 = function(T=3, lambda=4, mu=3) { t = 0 N = 0 i = 1 while(t[i] < T) { mut = switch(as.character(N[i]), “0”=0, “1”=mu, 2*mu) t[i+1] = t[i] + rexp(1, lambda + mut) pt = lambda / (lambda + mut) N[i+1] = N[i] + sample(c(1,-1), 1, prob=c(pt,1-pt)) i = i + 1 } cbind(t=t, N=N) } count = 0 m = 10000 for(i in 1:m) { x = mm2(T=3) nr = nrow(x) if(x[nr-1,2] >= 3) count = count + 1 } > (p = count / m) [1] 0.3144 1 (b) > (se = sqrt(p*(1-p)/m)) [1] 0.004642765 > p + 1.96 * se * c(-1,1) [1] 0.3053002 0.3234998 (c) G = 1 + λ µ + λ µ λ 2µ + λ µ λ 2µ λ 2µ + · · · = 1 + λ µ X∞ j=0 λ 2µ j = 1 + 2ρ 1 − ρ , where ρ = λ 2µ = 2 3 . Hence π0 = 1 G = 1 5 and 1 − π0 − π1 − π2 = 1 − π0(1 + 2ρ + 2ρ 2 ) = 0.356 (d) The transient peirod starts with N(0) = 0, and the probability mass 1 is gradually redistributed from state 0 to states with higher n-values. 2 2. Consider the M/M/3/3 queue that has arrival rate λ = 6 per minute and service rate µ = 3 per minute per server. (a) If there is one customer in the system, what is the probability that another customer arrives before the current customer leaves? (b) Find the stationary distribution. (c) In steady-state, what is the rate of customers who enter the system? Answer: (a) Consider the merged Poisson process. The probability for the next event to be an arrival is P(Ai+1 < Di) = 6 3 + 6 = 2 3 . (b) G = P3 i=0 λ µ i i! = 6.33 and hence π = (0.158, 0.316, 0.316, 0.211). (c) A customer can enter the system, as long as it is not full. Hence, the entry rate is λ(1 − π3) = 4.734. 3 3. Consider the M/G/1 queue that has Poisson arrivals at rate λ = 1.6 customers per minute and the distribution for service time is only known to have mean 0.5 minute and variance 0.3. Assume the system is in steady-state. (a) What is the mean queue length of the system? (b) How long should an arriving customer expect to wait before being served? (c) What is the probability that an arriving customer finds the server busy? (d) What is the expected length of a busy period for this queue? Answer: (a) With ρ = λ µ = 0.8 and c 2 s = 0.3 0.5 2 = 1.2, L = ρ + ρ 2 (1 + c 2 s ) 2(1 − ρ) = 4.32 (b) Lq = ρ 2 (1+c 2 s ) 2(1−ρ) = 3.52 and Wq = Lq/λ = 2.2. (c) 1 − π0 = ρ = 0.8. (d) E(B) = 1−π0 λπ0 = 2.5. 4