<s>[INST] Find $\operatorname{Var}(Y)$ when $f_{X}(x)=3x^{2}I_{\{0Let $X$ be a random variable with the following pdf:
$$
f_{X}(x)=3x^{2}I_{\{0<x<1\}}
$$
let $Y$ be a random variable so $\left(Y\mid X=x\right)\sim \operatorname{Uni}[96x,100x]$. Calculate $\operatorname{Var}(Y)$.
What I did: If $(Y\mid X=xt)\sim \operatorname{Uni}[96x,100x]$ then $f_{Y\mid X}(y\mid x)=\frac{1}{4x}$ and so:
$$
f_{X,Y}(x,y)=f_{Y\mid X}(y\mid x)\cdot f_{X}(x)=\frac{1}{4x}\cdot3x^{2}I_{\{0<x<1\}}=\frac{3}{4}xI_{\{0<x<1\}}
$$
Let's find $f_{Y}(y)$:
$$
f_{Y}(y)=\int_{-\infty}^{\infty}f_{X,Y}(x,y)\,dx=\int_{-\infty}^{\infty}\frac{3}{4}xI_{\{0<x<1\}}dx=\frac{3}{4}\int_{0}^{1}x\,dx=\frac{3}{8}
$$
Let's find $E\left(Y\right)$:
$$
E\left(Y\right)=\int_{-\infty}^{\infty}y\cdot f_{Y}(y)\,dy=\frac{3}{8}\int_{0}^{1}y\,dy=\frac{3}{16}
$$
Lets find $E\left(Y^2\right)$:
$$
E\left(Y^{2}\right)=\int_{-\infty}^{\infty}y^{2}\cdot f_{Y}(y)\,dy=\frac{3}{8}\int_{0}^{1}y^{2}\,dy=\frac{1}{8}
$$
Then we get:
$$
\operatorname{Var}(Y)=\frac{1}{8}-\left(\frac{3}{16}\right)^2=\frac{23}{256}
$$
I'm not even close to the answer $360.95$. Some questions:

*

*When should I write the indicator $I$? I'm a bit confused about what does it represent.

*Where is my mistake? I guess that the integral limits that were used in calculating $E(Y)$ and $E(Y^2)$ ($0$ to $1$) are not correct. What should they be?

 [/INST] The entire calculation is unnecessary.  Rather, apply the law of total variance.
Note for all positive integers $k$, $$\operatorname{E}[X^k] = \int_{x=0}^1 3x^{k+2} \, dx = \frac{3}{k+3}.$$  Then $$\begin{align}
\operatorname{Var}[Y] &= \operatorname{Var}[\operatorname{E}[Y \mid X]] + \operatorname{E}[\operatorname{Var}[Y \mid X]] \\
&= \operatorname{Var}\left[\frac{96X + 100X}{2}\right] + \operatorname{E}\left[\frac{(100X - 96X)^2}{12}\right] \\
&= \operatorname{Var}[98X] + \operatorname{E}[\tfrac{4}{3}X^2] \\
&= 98^2 \operatorname{Var}[X] + \frac{4}{3}\operatorname{E}[X^2] \\
&= (98^2 + \tfrac{4}{3}) \operatorname{E}[X^2] - 98^2 \operatorname{E}[X]^2 \\
&= \left(98^2 + \frac{4}{3}\right) \frac{3}{5} - 98^2 \frac{9}{16} \\
&= \frac{7219}{20}.
\end{align}$$
If you must do it the hard way, we observe that the full joint density is $$f_{X,Y}(x,y) = \frac{3}{4}x \mathbb 1(0 \le x \le 1) \mathbb 1(96x \le y \le 100x),$$ since you cannot ignore the fact that $Y$ given $X$ is supported on an interval that is a function of $X$.  Thus the support is a triangle; the unconditional variance of $Y$ is then computed directly as
$$\begin{align}\operatorname{E}[Y^k] 
&= \int_{x=0}^1 \int_{y=96x}^{100x} y^k \frac{3}{4}x \, dy \, dx \\
&= \int_{x=0}^1 \frac{3}{4} x \left[\frac{y^{k+1}}{k+1}\right]_{y=96x}^{100x} \, dx  \\
&= \frac{3(4^k)(25^{k+1} - 24^{k+1})}{k+1} \int_{x=0}^1 x^{k+2} \, dx \\
&= \frac{3(4^k)(25^{k+1} - 24^{k+1})}{(k+1)(k+3)}.
\end{align}$$
Substituting $k = 1$ and $k = 2$ gives
$$\operatorname{Var}[Y] = \frac{28816}{5} - \left(\frac{147}{2}\right)^2 = \frac{7219}{20}.$$
</s>