ACM 6 Problem Set 4 Solutions Lei Zhang Problem Answer (a) is correct. Suppose I arrive at time t, and the first arrival after t is bus N i + and occurs at time T Ni+. Let W t = T Ni+ t, which is the waiting time or forward recurrence time at t. By the memoryless property, it s clear that W t is exponentially distributed with rate λ, E[W t ] = λ. Also, for fixed t, let { t TNi, if N V t = i > 0 t if N i = 0 be the backward recurrence time at t, the time that has elapsed at t since the last arrival bus prior to t (or t if there have been no arrivals). It s clear that 0 V t t, thus V t cannot be exponentially distributed. Actually, V t has the cumulative distribution function (figure ) 0 s < 0 F (s) = e λs 0 s < t s t As t, F converges to the cumulative distribution function of an exponential distribution. V t has a distribution function P. Notice that since F has discontinuity at t, P is point mass at t. 0 s < 0 λe P (s) = λs 0 s < t e λt δ(s t) s = t 0 s > t 0.8 0.6 0.4 0.2 0 0 0.5.5 2 2.5 3 Figure : Cumulative Distribution Function F for V t
We can compute E[V t ] = t 0 sλe λs ds + te λt = te λt + e λt λ = e λt λ + te λt W t and V t are indepent for each t by the memoryless property. Therefore we see that W t and V t are not symmetric for fixed t, although as t, E(W t ) = E(V t ) = λ. This solution is based on pp60, Probability by A F Karr, Springer-Verlag. Problem 2 The Poisson process in the problem is a process of randomly occurring events in space such that: i) For any region of volume V the number of events in that region has a Poisson distribution with mean λv. ii) The number of events in nonoverlapping regions are indepent. Fix the star alpha at origin y = 0, consider the region V = {y R 3 0 < y < x} and V 2 = {y R 3 x < R < x + dx}, the probability P that the nearest neighbor to alpha belongs to V 2 is, the probability distribution function is given by Problem 3 P = P (N(V ) = 0)P (N(V 2 ) ) = e λv (λv 2 + o(v 2 )) = 4λπx 2 e 4λπx3 3 dx f R (x) = 4λπx 2 e 4λπx3 3, x > 0. (a) State i can be defined as: i customers in the station, m i customers are outside the station and each will enter the system will exponential rate θ, 0 0 m. The balance equation is state entering rate = leaving rate 0 µp = mθp 0 0 < i < m (m i + )P i + µp i+ = ((m i)θ + µ)p i m θp m = µp m which can be solved by and P i = m! (m i)! P i =. ( ) i θ P 0 µ 2
(b) Average rate that customer enter the system is λ a = P i θ(m i) = mθ θ ip i = θ(m L). The average number of customers in the system L is L = ip i. (c) The average time that a customer sps in the station per visit is m L W = L/λ a = θ(m L) = ip i θm θ m ip i Problem 4 (a) State i can be defined as the state that i customer in the system. The balance equation is, state entering rate = leaving rate 0 µp = λp 0 λp 0 + 2µP 2 = (λ + µ)p 2 λp + 2µP 3 = (λ + 2µ)P 2 3 λp 2 = 2µP 3 (b) Let ρ = λ µ. The solution of the balance equation is given by the long run probabilities, P 0 = P = P 2 = P 3 = + ρ + 2 ρ2 + 4 ρ3 ρ + ρ + 2 ρ2 + 4 ρ3 2 ρ2 + ρ + 2 ρ2 + 4 ρ3 4 ρ3 + ρ + 2 ρ2 + 4 ρ3 (c) If a customer arrives and finds two others in the system, his waiting time is exponential with rate 2µ and service time is exponential with rate µ. Therefore the expected time he sps in the system is E(T ) = 2µ + µ = 3 2µ. (d) Customers can enter if less than 3 customers in the system. The proportion of customers entering the system is (e) The rate of customers entering the system is The average number of customers in the system is P 3 = ρ + 2 ρ2 + 4 ρ3 + ρ + 2 ρ2 + 4 ρ3. λ a = λ( P 3 ). L = P + 2P 2 + 3P 3 = ρ + ρ 2 + 3 4 ρ3 + ρ + 2 ρ2 + 4 ρ3 3
5.5 convergence of mean value 5 E(X)=5 4.5 4 3.5 3 2.5 2 E(X3)=2.5 E(X2)= 0.5 0 0 20 30 40 50 60 Figure 2: convergence plot The average time a customer in the system is Problem 5 W = L = ρ + ρ2 + 3 4 ρ3 λ a λ( + ρ + 2 ρ2 ) (a) By the fact that λ < min{µ, µ 2, µ 3 } and Burke s Theorem, there exist long run probabilities (steady state) and the departure process of each station is also Poisson with rate λ. Let ρ = λ µ 3 = 0/5 = 2/3, the probability of k customers in the station is Suppose c is integer, we have lim P (X 3(t) > c) = t ρ k ( ρ). ρ k ( ρ) = ρ c+. The smallest number c for which lim t P (X 3 (t) > c) < 0.0 is given by c = x means the minimum integer larger than x. c+ log(0.0) log ρ =, where (b) See the accompanying Matlab file in the Appix. In the long run, the averaged time in server i is L i = λ µ, thus L i λ = E(X ) = 5, L 2 = E(X 2 ) = and L 3 = E(X 3 ) = 2. We study the convergence by sampling X i and drawing the averaged X i at different time points, and compare it with E(X i ). In figure 2, we can see that after about 30 hours the mean value converges visually. Appix Matlab-code for Problem 2 % This code is modified from Mulin Cheng s homework % % The function prob5 is for running the numerical % experiments 4
function prob5 close all clear all lambda=0; mu=2; mu2=20; mu3=5; % simulate the process up to time T T=60; N=60; % sample time points tlist=linspace(t/n,t,n); samplesdrawn=00000; X=zeros(samplesdrawn,N); X2=X; X3=X; X0=zeros(,N); X20=X0; X30=X0; for i=:samplesdrawn [X0,X20,X30]=sample(lambda,mu,mu2,mu3,T,tlist); X(i,:)=X0; X2(i,:)=X20; X3(i,:)=X30; figure hold on plot(tlist,mean(x),tlist,mean(x2),tlist,mean(x3)); line([0 T],[5 5]);text(0,5, E(X)=5 ) line([0 T],[2 2]);text(0,2, E(X3)=2 ) line([0 T],[ ]);text(0,, E(X2)= ) % This function is for the sampling with the method described % in 5(b) % X_i number of customers in station i at time list tlist % lambda arrival rate % mu_i service rate at station i % T simulation time % tlist sample time list function [X,X2,X3]=sample(lambda,mu,mu2,mu3,T,tlist) %the total number of customers entering the system by time t N=poissrnd(lambda*T); n=length(tlist); X=zeros(,n); X2=zeros(,n); X3=zeros(,n); % arrival times AT0=T*rand(N,); % ordered arrival times AT=sort(AT0, asc ); DT=DepartTime(AT,mu); 5
DT2=DepartTime(DT,mu2); DT3=DepartTime(DT2,mu3); for i=:n t=tlist(i); % M is the arrivals at server before time t M=find(AT<=t,, last ); if length(m)==0 % if no arrivals before time t M=0; X(i)=0; X2(i)=0; X3(i)=0; % departures from server before time t temp=find(dt(:m)<=t,, last ); if length(temp)==0 % if no departure before time t temp=0; X(i)=M; X2(i)=0; X3(i)=0; % arrivals at server - departures from server X(i)=M-temp; % M is departures from server, i.e. arrivals at server 2 M=temp; % departures from server 2 temp=find(dt2(:m)<=t,, last ); if length(temp)==0 % if no departure before time t temp=0; X2(i)=M; X3(i)=0; % arrivals at server 2 - departures from server 2 X2(i)=M-temp; % M is departures from server 2, i.e. arrivals at server 3 M=temp; % departures from server 3 temp=find(dt3(:m)<=t,, last ); if length(temp)==0 % if no departure before time t temp=0; X3(i)=M; % arrivals at server 3 - departures from server 3 X3(i)=M-temp; return % This function is for the departure time of customers 6
% passing by a single station with service rate mu % DT departure times % AT arrival times % mu service rate function DT=DepartTime(AT,mu) n=length(at); DT=zeros(n,); % sample the service time ST=exprnd(/mu,n,); DT()=AT()+ST(); for i=2:n DT(i)=AT(i)+max([DT(i-)-AT(i),0])+ST(i); return 7