Your formula for the law of total expectation is correct., : $$\mathbb E[X] = \mathbb E[X\mid Y=1]\mathbb P(Y=1) + \mathbb E[X\mid Y=2]\mathbb P(Y=2) +\mathbb E[X\mid Y=3]\mathbb P(Y=3)\tag1 $$ here is how to deal with the conditional expectations :
- For the case $Y=1$ (when the student stays ingoes to the playground), you are being told that the student plays for 2 hours before restarting the process from scratchdeciding between playing 2 more hours or going home, in a recursive manner. This translates
By applying the law of total expectation to $X\mid Y=1$, we get the recursion $$\mathbb E[X\mid Y=1] = 2 + \mathbb E [X] $$$$\mathbb E[X\mid Y=1] = \mathbb E[X\mid Y=1, \text{student stays}] \mathbb P(\text{student stays}) + \mathbb E[X\mid Y=1, \text{student leaves}] \mathbb P(\text{student leaves})$$ Assuming that he stays in the playground with probability $0.4$, we get $$\mathbb E[X\mid Y=1] = (2+\mathbb E[X\mid Y=1])\cdot0.4 + 1\cdot0.6 $$ Which yields $\mathbb E[X\mid Y=1] \approx 2.33$ - By the same reasoning, we find for the case $Y=2$ that $$\mathbb E[X\mid Y=2] = 3 + \mathbb E [X] $$$$\mathbb E[X\mid Y=2] = (3 + \mathbb E [X\mid Y=2])\cdot0.3 + 1\cdot0.7 $$ From which you can deduce $\mathbb E[X\mid Y=2]$
- Lastly, the easiest case is $Y=3$, in which the student heads straight home (which takes one hour) : $$\mathbb E[X\mid Y=3] = 1 $$ WeYou can now have by the lawplug in all these values of total expectation that $$\mathbb E[X] =(2 + \mathbb E [X])\mathbb P(Y=1) + (3 + \mathbb E [X])\mathbb P(Y=2) + 1\cdot\mathbb P(Y=3) $$ Replacing with the appropriate probabilitiesconditional expectations in the original equation $(1)$, and rearranging we find $$0.3\mathbb E[X] = 2\iff \mathbb E[X]=2/0.3 \approx 6.67$$get an equation in $\mathbb E[X]$ that is easy to solve.