# Example of finding the conditional expected amount of time a person spends waiting in line given that she is eventually served

This is an Example from Ross' Introduction to Probability Models. I don't understand the answer to this question. Namely, why $W_n$ is given in the below equation from the argument given in the preceding sentence. I would greatly appreciate it if anyone could explain this in more detail.

Example 5.10. Suppose that customers are in line to receive service that is provided sequentially by a server; whenever a service is completed, the next person in line enters the service facility. However, each waiting customer will only wait an exponentially distributed time with rate $\theta$; if its service has not yet begun by this time then it will immediately depart the system. These exponential times, one for each waiting customer, are independent. In addition, the service times are independent exponential random variables with rate $\mu$. Suppose that someone is presently being served and consider the person who is $n$th in line.

(b) Find $W_n$, the conditional expected amount of time this person spends waiting in line given that she is eventually served.

Solution. To determine an expression for $W_n$, we use the fact that the minimum of independent exponentials is, independent of their rank ordering, exponential with a rate equal to the sum of the rates. Since the time until the $n$th person in line enters service is the minimum of these $n+1$ random variables plus the additional time tehreafter, we see , upon using the lack of memory property of exponential random variables, that $$W_n = \frac{1}{n\theta + \mu}+W_{n-1}$$ Repeating the preceding argument with successively smaller values of $n$ yields the solution $$W_n = \sum_{i=1}^n \frac{1}{i\theta + \mu}$$

The time spent waiting for service when you are the $n^\text{th}$ customer in line is equal to the time spent in the $n^\text{th}$ position plus the time spent in the $n-1^\text{th}$ position, plus the time spent in the $n-2^\text{th}$ position, and so on.

By construction, the time spent in all the positions but the $n^\text{th}$ is $W_{n-1}$. Hence, all we need to figure out is how long in expectation it will take you to leave the $n^\text{th}$ position in line.

You leave the $n^\text{th}$ spot when someone in front of you decides to depart, or if the first customer in the queue is served. This time is exponentially distributed with rate $n\theta + \lambda$, hence the expression in the first term of $W_n$.