<s>[INST] Total Expectation problem to solve in 2 ways - regular and by the law of total expectancy Im trying to solve the question in the way of total expectancy (meaning $E[X]=E[E[X|Y]]$).
the question: "A fair cube with 4 sides is thrown twice. each side has a number from 1 to 4. Let's mark Y - maximum of two results. Evaluate E(Y) both by regular way and by the law of total expectation."
So I managed to do it by the regular path:

However, by the law of total expectation I can't figure out how to do that. I found out that if we mark X - result of first throw then:


*

*$P(Y=1|X=1)=P(Y=2|X=1)=P(Y=3|X=1)=P(Y=4|X=1)=\frac{1}{4}$

*$P(Y=1|X=2)=0$, $P(Y=2|X=2)=\frac{1}{2}$, $P(Y=3|X=2)=P(Y=4|X=2)=\frac{1}{4}$

*$P(Y=1|X=3)=P(Y=2|X=3)=0$, $P(Y=3|X=3)=\frac{3}{4}$, $P(Y=4|X=3)=\frac{1}{4}$

*$P(Y=1|X=4)=P(Y=2|X=4)=P(Y=3|X=4)=0$, $P(Y=4|X=4)=1$


so I see that only $Y|X=1$ ~$U[0,4]$ but I can't say anything about distributions $Y|X=2$, $Y|X=3$, $Y|X=4$. thus I can't use the law of total expectation.
Any advice would be appreciated! thanks
 [/INST] Who knows if anyone is looking anymore, never mind OP, but this is a concept I'm trying to grasp as well.  I think I understand Ami's dissatisfaction with her own solution -- I too started by computing each conditional probability and wondered what I was supposed to have learned -- and so I've come up with my own attempt to sidestep the tedious, point-by-point computation.  So --
We begin with $P(Y = y  | X)$.
$\circ$ If $y < X$, then clearly $P(Y = y  | X)  = 0$.
$\circ$ If $y > X$, then $Y = y$ if and only if the second die yields $y$ -- i.e., precisely when $X_2 = y$.  Hence, $P(Y = y  | X) = 1/4$.
$\circ$ Finally, if $y = X$, then this is because $X_2 \le X$.  There are $X$ ways for this to happen, and so $P(Y = y  | X) = X/4$.
We can condense this as
\begin{align}
P(Y = y  | X) = \frac{1_{\left[ y > X\right]} + X \cdot 1_{\left[ y = X \right]}}{4},
\end{align}
where $1_A$ is the usual indicator function.
This gives us
\begin{align}
E[Y] &= E[E[Y|X]] \\
&= E\left[\sum_{y = 1}^{4} y \cdot \frac{1_{\left[ y > X\right]} + X \cdot 1_{\left[ y = X \right]}}{4} \right] \\
&= \frac{1}{4} E\left[\sum_{y = 1}^{4} y \cdot \left( 1_{\left[ y > X\right]} + X \cdot 1_{\left[ y = X \right]} \right) \right] \\
&= \frac{1}{4} \sum_{x = 1}^4 \frac{1}{4} \left( \sum_{y = 1}^{4} y \cdot \left( 1_{\left[ y > x\right]} + x \cdot 1_{\left[ y = x \right]} \right) \right) \\
&= \frac{1}{16} \left( \sum_{x = 1}^4 \sum_{y = 1}^{4} y \cdot 1_{\left[ y > x\right]}  + \sum_{x = 1}^4 \sum_{y = 1}^{4} yx \cdot 1_{\left[ y = x \right]} \right). \\
\end{align}
Now, the first double summation is the sum of all values of $y$ multiplied by the number of $x$-values that are smaller.  The second is the sum of squares from $1$ to $4$.  Therefore,
\begin{align}
E[Y] &= \frac{1}{16} \left[ \left( 1\cdot 0 + 2 \cdot 1 + 3 \cdot 2 + 4 \cdot 3 \right) + \left( 1^2 + 2^2 + 3^2 + 4^2 \right) \right] \\
&= \frac{20 + 30}{16} \; = \; \frac{25}{8} \\
\end{align}
Is this simpler than the brute-force method?  I don't know.  But at least it
generalizes -- with appropriate adjustments to the denominator in the conditional probability -- to dice with any number of sides.
</s>