# Mean length of time spent queueing in $M/E_2/1$ system?

Context: Consider a $M/E_2/1$ queueing system, where the customer arrival rate is $\lambda$ and the service time distribution has a gamma distribution with parameters $2$ and $\mu$, i.e. with p.d.f. $\mu^2te^{-\mu t}$ , $t ≥ 0$

Question: Assuming that the system is in equilibrium, deduce an expression for the mean length of time spent queueing in the system by an arriving customer before she starts being served (the mean "waiting time")

What I have done so far:

• traffic intensity is: $\rho=\frac{2\lambda}{\mu}$
• Unconditionally at equilibrium, number of customers who arrive during a service time is given by the probability generating function: $K(z) = (\frac{\mu}{\mu+\lambda-2\lambda})^2$
• At equilibrium, the PGF for the number of customers left behind in the system by the $n^{th}$ customer when she leaves is: $\Pi(z)=\frac{\mu(\mu-2\lambda)}{\lambda^2z^2-\lambda(\lambda+2\mu)z+\mu^2}$

But I don't know how to use the above to get what is being asked for.

Note 1: this question is related to Mean service time of a $M/E_2/1$ queueing system?

Notes 2: I am looking at a more interesting modification to question 5(d) for one of the 2012 RSS exams for which they do no provide a solution: http://www.rss.org.uk/uploadedfiles/userfiles/files/GD3_2012_final%20(web%20version).pdf

• Try applying Little's law: $L = \lambda W$. You know $\lambda$, and all you need is $L$. Can you get that? – jbowman Jan 30 '14 at 15:09
• Been trying but I can't figure it out. – Clair Crossupton Jan 30 '14 at 15:54

Consider the embedded Markov chain $\{X_n:n=0,1,2\ldots\}$ where $X_n$ is the number of customers in the system immediately after the $n^{\mathrm{th}}$ departure. The transition probabilities are $$p_{ij}=\begin{cases} a_j,& i=0\\ a_{j-i+1},& i>0, \end{cases}$$ where $a_n$ is the probability of $n$ customers arriving during a service time. We compute \begin{align} a_n &= \int_0^\infty e^{-\lambda t}\frac{(\lambda t)^n}{n!}\mu^2 t e^{-\mu t}\,\mathsf dt\\ &= \frac{\lambda^n\mu^2}{n!(\lambda+\mu)}\int_0^\infty t^{n+1}(\lambda+\mu)e^{-(\lambda+\mu)t}\,\mathsf dt\\ &= \frac{\lambda^n\mu^2(n+1)}{(\lambda+\mu)^{n+2}}. \end{align} The generating function of $\{a_n\}$ is thus \begin{align} P(z) &= \sum_{n=0}^\infty a_n z^n \\ &=\left(\frac\mu{\lambda+\mu}\right)^2\sum_{n=0}^\infty (n+1)\left(\frac{\lambda z}{\lambda+\mu}\right)^n\\ &=\left(\frac\mu{\lambda+\mu}\right)^2\frac{(\lambda+\mu)^2}{(\lambda+\mu-\lambda z)^2}\\ &= \frac{\mu^2}{(\mu+\lambda(1-z))^2}. \end{align} The condition $\pi=\pi P$ yields the system of equations $$\sum_{k=0}^n \pi_{n+1-k}a_k + \pi_0a_n,\ n=0,1,\ldots.$$ Let $Q(z)$ be the generating function of $\{\pi_n\}$, then we compute \begin{align} Q(z) &= \sum_{n=0}^\infty \left(\sum_{k=0}^n \pi_{n+1-k}a_k + \pi_0 a_n\right)z_n\\ &= z^{-1}\sum_{n=0}^\infty\sum_{k=0}^\infty\left( \pi_{n+1-k} z^{n+1-k}\pi_k z^k\right) + \sum_{n=0}^\infty \pi_0 a_n z^n\\ &= z^{-1}\sum_{k=0}^\infty\sum_{n=k}^\infty\left( \pi_{n+1-k} z^{n+1-k}\pi_k z^k\right) + \pi_0 P(z)\\ &= z^{-1} \sum_{k=0}^\infty \pi_k z^k\sum_{n=k}^\infty \pi_{n+1-k}z^{n+1-k} + \pi_0 P(z)\\ &= z^{-1} P(z)(Q(z)-\pi_0) + \pi_0 P(z), \end{align} from which $$Q(z) = \frac{\pi_0 P(z)\left(1-z^{-1}\right)}{1-z^{-1}P(z)}.$$ The server utilization is $\rho=\frac{2\lambda}\mu$, so $\pi_0=1-\rho=\frac{\mu-2\lambda}\mu$. It follows that \begin{align} Q(z) &= \frac{\left(\frac{\mu-2\lambda}\mu\right) \left(\frac{\mu^2}{(\mu+\lambda(1-z))^2}\right)(1-z)}{\frac{\mu^2}{(\mu+\lambda(1-z))^2} -z}\\ &= \frac{\mu(\mu-2\lambda)(1-z)}{\mu^2 - z(\mu+\lambda(1-z))^2}. \end{align} The equilibrium mean number of customers in the system is thus \begin{align} L &= \lim_{z\uparrow1} Q'(z)\\ &= \lim_{z\uparrow1} \frac{\lambda \mu (\mu -2 \lambda ) (\lambda +2 \mu -2 \lambda z)}{\left(\lambda^2z(1-z)+2\lambda\mu z-\mu^2 \right)^2}\\ &= \frac{\lambda(2\mu-\lambda)}{\mu(\mu-2\lambda)}, \end{align} and so by Little's Law we conclude that the equilibrium mean sojourn time is $$W = \frac L\lambda =\frac{2\mu-\lambda}{\mu(\mu-2\lambda)}.$$