# Law of total expectation and max(Y1, Y2)

Let $Y_1,Y_2 \sim exp(\mu)$ and are independent.

Now I want to find the expected value of $Z= \max(Y_1,Y_2)$.

I know how to do this using another way (involving $\min(Y_1,Y_2)$ ) but I wanted to do this using conditional expectation and I couldn't succeed. Here are my steps:

$\mathbb{E}(Z) = \mathbb{E}(Z | Y_1 < Y_2)\cdot \mathbb{P}(Y_1 < Y_2) + \mathbb{E}(Z | Y_1 \geq Z_2)\cdot \mathbb{P}(Y_1 \geq Y_2)$

$\ \ \ \ \ \ \ \ \ = \mathbb{E}(Y_2) \cdot \mathbb{P}(Y_1 < Y_2) + \mathbb{E}(Y_1)\cdot \mathbb{P}(Y_1 \geq Y_2)$

$\ \ \ \ \ \ \ \ \ = \mathbb{E}(Y_2) \cdot \mathbb{P}(Y_1 < Y_2) + \mathbb{E}(Y_1)\cdot ( 1-\mathbb{P}(Y_1 < Y_2) )$

$\ \ \ \ \ \ \ \ \ = \frac{1}{\mu} \cdot \frac{\mu}{2\mu} + \frac{1}{\mu}( 1 - \frac{\mu}{2\mu} ) = \frac{1}{\mu}$

But this is wrong. The answer should be $\frac{3}{2\mu}$.

To me it seems that using the law of total expectation is possible here, as the events $\{Y_1 < Y_2\}$ and $\{Y_1 \geq Y_2\}$ are a partitioning of the whole outcome space. So what did I do wrong?

• "So what did I do wrong?" Note that $\mathbb{E}(Z | Y_1 < Y_2)=\mathbb{E}(Y_2 | Y_1 < Y_2)\ne\mathbb{E}(Y_2)$. Likewise, $\mathbb{E}(Z | Y_1 \geqslant Y_2)\ne\mathbb{E}(Y_1)$.
– Did
Feb 20, 2015 at 17:01
• @Did: Makes sense. So how would I continue with $\mathbb{E}(Y_2|Y_1 < Y_2)$ Feb 20, 2015 at 17:07
• Computing $E(Y_2;Y_1\lt Y_2)$ and $P(Y_1\lt Y_2)$, obviously.
– Did
Feb 20, 2015 at 20:48

I know this is a stale post, but just in case anyone is looking (like I was) I'll add the answer here because it took me a while to understand how to compute these expectations.

\begin{align}\Bbb E(Z)~=~\Bbb E(Z\mid Y_{1} < Y_{2})*P(Y_{1} < Y_{2}) + E(Z\mid Y_{2} < Y_{1})*P(Y_{2} < Y_{1})\end{align}

\begin{align}~=~\Bbb E(Y_{2}\mid Y_{1} < Y_{2})*P(Y_{1} < Y_{2}) + E(Y_{1}\mid Y_{2} < Y_{1})*P(Y_{2} < Y_{1})\end{align}

Let's compute the probabilities first (which you had correct): \begin{align}P(Y_{2} < Y_{1})~=~&\int_{0}^{\infty}\int_{y_{2}}^{\infty} \mu^2e^{-\mu(y_{2}+y_{1})}~dy_{1}~dy_{2}= 1/2\end{align}

And the compliment, which partitions the space: \begin{align}P(Y_{1} < Y_{2})~=~1-P(Y_{2} < Y_{1}) = 1/2\end{align}

The expectations are tricky because we have the joint of $Y_{1},Y_{2}$ but we want the expectation of either one or the other. So we need to marginalize the joint probabilities on the variables of interest -- all while accounting for the condition:

\begin{align}\Bbb E(Y_{2}\mid Y_{1} < Y_{2})~=~\int_{0}^{\infty} y_{2}~f_{Y_{2}\mid Y_{1} < Y_{2}}~dy_{2}\end{align}

\begin{align}f_{Y_{2}\mid Y_{1} < Y_{2}}~=~\int_{y_{2}}^{\infty}f_{Y_{1}Y_{2}\mid Y_{1} < Y_{2}}~dy_{1}~=~\int_{y_{2}}^{\infty}f_{Y_{1}Y_{2}}/P(Y_{1} < Y_{2})~dy_{1}\\[1ex]~=~\int_{y_{2}}^{\infty} \mu^2e^{-\mu(y_{2}+y_{1})}/(1/2)~dy_{1}=(1/2)(\mu~e^{-\mu~y_{2}})(1-e^{-\mu~y_{2}})\end{align}

Plugging that marginal into the integral for the expectation will give $3/2\mu$. Then go back to your original total expectation decomposition plug in all the values:

\begin{align}\Bbb E(Z)~=~(3/2\mu)(1/2) + (3/2\mu)(1/2) = 3/2\mu\end{align}