# Markov chain - Can anyone explain me why this is the solution?

Customers arrive according to a Poisson process at a rate of four customers per hour. A customer who finds four other customers in already waiting gives up and leaves. Some clients in the 3rd and 4th position also leave the queue without being served. Customers in the 3rd position do so after an exponential waiting time with mean $30$ minutes and customers in the 4th position after an exponential time with mean $15$ minutes. The service time is exponentially distributed with a mean of $15$ minutes.

(1) Formulate a Markov chain that helps to study the long run average number of customers in the system per unit time and solve the balance equations of this Markov chain.

(2) Calculate the expected number of customers in the system and the expected time a customer is waiting before he gets served.

From the solution below I don't understand how in (b) the probability is obtained that a customer is accepted and served ($P_2 \frac{2}{6} + P_4 \frac{4}{8}$), and the rate that follows. Can anyone please help?

This solution contains a number of errors, especially in the part that you refer to. Notice that the solved values for $P_0, P_1, P_2, P_3, P_4$ do not sum to 1; this is a mistake. The solution is correct up to the point of finding $P_0=P_1=P_2, P_3=\frac23P_0$ and $P_4=\frac4{15}P_0$, but from here we should get $P_0=P_1=P_2=\frac{15}{59}, P_3=\frac{10}{59}$ and $P_4=\frac{4}{59}$.
The formula for the expected number of customers in the system is correct: $L=P_1+2P_2+3P_3+4P_4$. But there is a little mistake in the expected number of customers in queue: it should be $L_q = 0P_1 + 1P_2+ 2P_3+3P_4 = L-(1-P_0)$; the omitted subtraction symbol was probably just a typo.
The expected number of customers receiving service per hour is $4(1-P_0)$, while the expected number of customers arriving per hour is 4, so the proportion of customers who are served is $4(1-P_0)/4 = 44/59$. I may be missing something, but I'm not seeing how PASTA would help here, and the value $P_2\frac26+P_4\frac48$ appears to be incorrect. The rate at which customers arrive to the queue is $\lambda_q=\lambda(1-P_0-P_4)$ (which is not the same as the rate at which customers are served), so by Little's law, the expected time spent in the queue by customers who enter the queue is $W_q=\frac{L_q}{\lambda_q}$.
Note, however, that $W_q$ is not the expected time that a customer waits before being served, because not all customers are served -- some leave the queue early. According to the most straightforward interpretation of part (2) of the problem, what we're really looking for is the expected waiting time for a customer who does not leave without being served, and who arrives to a not-already-full queue; in other words, we're looking for a certain conditional expectation, and this is a trickier than calculating $W_q$. Maybe I'm overlooking a shortcut, but the simplest way I can think of doing this would be to construct a new Markov chain which models not just the number of customers in the system but also the position of the designated customer. We can do this with 7 states, if we notice that we only need one state where the designated customer is being served (or has been served), because it doesn't matter if there are 0, 1, 2, or 3 people in the queue at that point.
• Thank you very much for your detailed explanation. However, about your second paragraph: I think that $L(1-P_0)$ is correct: as it measures the number of customers that are in the system and that are not in state $0$ (because in state zero you don't have to wait). I still wonder how the solutions got to $P_2 \frac{2}{6} + P_4 \frac{4}{8}$ for the proportion of customers served, but your method seems to work. Thanks again! – learner Feb 23 '15 at 12:02
• Also, if I'm not missing anything, you don't seem to be using the proportion of customers who are served ($44/59$) for computation of $W_q$, while the solution uses this. Maybe that is their shortcut? – learner Feb 23 '15 at 12:15