This is a question 2c from here. Solutions here.
Essentially $X$ is an RV of the amount we take to the casino on any given night (less than 40 dollars) and we can show: $$f_X(x) = \frac{x}{800}$$ and $Y$ is an RV of money we have on leaving the casino, uniform on $[0, 2X]$.
$Z=Y-X$ is an RV of the profit we make on any given night. The question as given is to find $E[Z]$.
Note that: $$f_Z(z) = \frac{1}{2x}$$ and is bounded between $-x$ and $x$.
In the solution we use:
$$f_{X,Z}(z,x) = f_X(x)\,f_{Z \mid X}(z \mid x)=\frac{1}{1600}$$ and then integrate:
$$ f_Z(z) = \int_{x=\mid z \mid}^{x=40}{\frac{1}{1600}} \, dx $$
to get $E[Z]$.
I have two questions:
- Methodology wise this is fine though we didn't use $Y$ in the solution... I guess this is just a choice to make it simpler given $f_Z(z)$ turns out to be a nice function with terms cancelling?
- I'm confused by the lower bound on the integral of $x=\mid z \mid$. I get that we can't take less money to the casino than profit we make but I missed this first time around and it doesn't feel natural to define the $x$ limits in terms of $z$ given we have just defined $Z$ in terms of $X$. My guess is that it's due to $f_{Z \mid X}(z \mid x)$ only having +ve probability for $x>\mid z \mid$.
Any clearing up of this confusion (and slight circular feeling I'm having) would be greatly appreciated.
1) Methodology wise, you do use $Y$, just a bit indirectly.
2) That is also how you determine the bounds.
Because $Z=Y-X$, and $Y\mid X\sim \mathcal U[0;2X]$ therefore $Z\mid X ~\sim~\mathcal U[-X;X]$, so ...
$$f_{Z\mid X}(z)=\tfrac 1{2x}\mathbf 1_{z\in[-x;x]}$$
Because $Z=Y-X$, and $(X,Y)\in \{(x,y): 0\leq x\leq 40, 0\leq y\leq 2x\}$ therefore $(X,Z)\in\{(x,z):0\leq x\leq 40,-x\leq z\leq x\}$, so...
$$(X,Z)\in\{(x,z):-40\leq z\leq 40~, -z\leq x~, z\leq x\leq 40\}$$
Putting this together, since $\lvert z\rvert =\max(-z,z)$.... $$\begin{split}f_Z(z) &= \int_\Bbb R f_{Z\mid X}(z\mid x)~f_{X}(x)~\mathrm d x \\&=\int_{\lvert z\rvert}^{40}\dfrac 1{2x}~\dfrac x{800}~\mathbf 1_{z\in[-40,40]}~\mathrm d x\end{split}$$
PS: $\mathsf E(Z)=\mathsf E(\mathsf E(Z\mid X))=\mathsf E(0)$