Queuing with impatience I am considering simple M/M/1 queue with customer impatience. Customer waits and leaves the system if the delay before service is more than an exponential 
wait time. Arrival rate is $\lambda$, service rate is $\mu$, and abandonment rate due to delay is $\lambda_W$. 
I assume state probabilities $p_n$ are known.
My problem is to find expected wait time given that customer receives service. 
My approach to the problem is very simple: 


*

*if customer finds one customer in the system average queueing delay is  $E[S_1 | S_1 < W]$ = $\frac{1}{\mu + \lambda_w}$, where $S_1$ is the random variable of service time (~exp($\mu$)), and $W$ is the exponential delay.

*Similarly, if customer finds 2 customer in the system average queueing delay is the conditional expectation $E[S_1 + S_2 |S_1 + S_2 < W ] = \frac{1}{\mu + \lambda_w} + \frac{1}{\mu + 2\lambda_w}$ 

*If customer finds $n$ customer  in queue and successfully receives service, total queuing delay until service time begins is the sum of $n$ independent exponentials with rates $\mu +\lambda_w$, $\mu+2\lambda_w$, $\mu +3\lambda_w$...$\mu+n\lambda_w$. Thus, the expectation of queueing delay is $\frac{1}{\mu +\lambda_w}+...+\frac{1}{\mu + n \lambda_w}$ 
Thus, average delay $\overline{W}_q$  conditioning on states is
$\overline{W}_q = \sum_{i=1}^{\infty} E[S_n| S_n <W] p_n $.
The result I obtained from this approach does not agree with simulation results. I don`t know where I am doing wrong?
 A: So, to begin with, your expectations are shifted over by one: $\frac{1}{\mu + \lambda_w}$ is the expected waiting time, given that a customer doesn't leave, when there were no other customers in line. $\frac{1}{\mu + \lambda_w} + \frac{1}{\mu + 2\lambda_w}$ is the expected waiting time, given that a customer doesn't leave, when there was one other customer in line, and so on. But that's a minor error.
The real killer is that if we adjust for this, we get the final expression $$\sum_{n=0}^\infty \left(\frac{1}{\mu + \lambda_w} + \cdots + \frac{1}{\mu + (n+1)\lambda_w}\right) p_{n} \tag{1}$$ which is still wrong: instead of $p_n$, you should have the conditional probability that there are $n$ customers, given that the next customer to arrive gets served. These are not independent events: the next customer to arrive is much more likely to get impatient first if there are 100 customers already in line. 
So you'll need to explicitly figure out the probability (call it $q_n$) that a customer that's behind $n$ others in line will be served before getting impatient. This is not too hard: we have $q_0 = \frac{\mu}{\mu + \lambda_w}$, and more generally, $q_n = \frac{\mu + n \lambda w}{\mu + (n+1) \lambda_w} \cdot q_{n-1} = \frac{\mu}{\mu + (n+1)\lambda_w}$. Then we can find the overall probability that a customer is served: $q = \sum_{n=0}^\infty p_i q_i$.
Finally, to make $(1)$ correct, we should replace $p_{n}$ by the conditional probability, which is (via Bayes's formula) $\frac{p_{n} q_{n}}{q}$.
