# exponential distributions and waiting.

I am waiting for two friends to arrive at my house. The time until A and B arrive is exponentially distributed with rate $\lambda_A$ and $\lambda_B$ respectively. Once they arrive, they will spend exponentially distributed times here with rates $\mu_A$ and $\mu_B$ respectively. All R.V.s are independent. What is the expected time of the last departure?

I know we have to just condition on which is greater, but I'm having trouble reasoning this out, since the only formula our book gives us is for the minimum of two exponential random variable

Should I condition on both who arrives first and then who leaves first? That just seems too computationally messy to be the correct approach. Any ideas would be greatly appreciated!

Let $X_A$ be the time $A$ arrives, and $Y_A$ be the time $A$ stays. We can first calculate sums of independent exponential random variables, $Z_A=X_A+Y_A$, \begin{align} f_{Z_A}(z) &= f_{X_A}*f_{Y_A} = \int^z_0\lambda_A\exp(-\lambda_Ax)\mu_A\exp(-\mu_A(z-x))dx\\ &=\lambda_A\mu_A\exp(-\mu_Az)\int^z_0\exp((\mu_A-\lambda_A)x)dx\\ &= \frac{\lambda_A\mu_A}{\mu_A-\lambda_A}\left(\exp(-\lambda_Ax)-\exp(-\mu_Ax)\right) \end{align} Similarly we have \begin{align} f_{Z_B}(z) =\frac{\lambda_B\mu_B}{\mu_B-\lambda_B}\left(\exp(-\lambda_Bx)-\exp(-\mu_Bx)\right) \end{align} Let $M = \max(Z_A,Z_B)$, we calculate the CDF
Since $Z_A$ and $Z_B$ are independent, this is easy to calculate. Once this is done, you can do