VarX of given density function of 2-dimensional random variable (X,Y)

The density function of 2-dimensional random variable (X,Y) is :

$$f_{X,Y}(x,y) = \begin{cases} \frac{x^2}{2y^3}\cdot e^{-\frac{x}y},& 0<x<\infty, 0<y<1 \\0,& \text{otherwise.} \end{cases}$$

To find VarX, I did the following: $$VarX = EVar(X|Y) + Var(E(X|Y))\\ Var(X|Y)=E(X^2|Y)-(E(X|Y))^2\\ E(X^2|Y=y) = \int_{-\infty}^{+\infty} x^2\cdot f_{X|Y}(x)dx = \begin{cases} \int_{0}^{+\infty}x^2\cdot \frac{x^2}{2y^3}\cdot e^{-\frac{x}{y}}dx, & 0<x<\infty, 0<y<1 \\ 0, & otherwise. \end{cases} = \\ \begin{cases} \frac{1}{2y^3}\int_{0}^{+\infty}x^4\cdot e^{-\frac{x}{y}}dx, & 0<x<\infty, 0<y<1 \\ 0, & otherwise. \end{cases} = \begin{cases} \frac{1}{2y^3} \cdot (\frac{4!}{\frac{1}{y^5}}), & 0<x<\infty, 0<y<1 \\ 0, & otherwise. \end{cases} = \\ \begin{cases} 12y^2, & 0<x<\infty, 0<y<1 \\ 0, & otherwise. \end{cases} \\ Var(X|Y) = E(X^2|Y) - (E(X|Y))^2 = 12y^2 - 9y^2 = 3y^2, \ where \ E(X|Y) = 3y \ was \ determined \ before \\ EVar(X|Y) = Ev(Y) = E(3y^2) = 3 \cdot E(Y^2) = \begin{cases} 3\cdot \int_0^1{y^2 \cdot 3y dy}, & 0<y<1 \\ 0, & otherwise \end{cases} = \begin{cases} 9 \cdot \int_0^1{y^3 dy}, & 0<y<1 \\ 0, & otherwise \end{cases} = \begin{cases} \frac{9}{4}, & 0<y<1 \\ 0, & otherwise \end{cases} \\ Var(E(X|Y)) = Var(h(Y)) = Var(3Y) = 3 \cdot Var(Y) = 3 \cdot (E(Y^2) - E(Y)^2) = 3 \cdot (\frac {3}{4} - \frac{1}{4}) = \frac{3}{2} \\ Var(X) = EVar(X|Y) + Var(E(X|Y)) = \frac{9}{4} + \frac{3}{2} = 3.75 \\$$ The book gives the answer as "1.75". I have checked bunch of times but being blind - where did I make a mistake?

Thank you

• To find the variance of X, it would be much faster to first compute the PDF of X, then use it to compute the expectations of X and X^2. (No I did not check your computations, sorry.) – Did Mar 28 '17 at 15:34

For $0<y<1$ the marginal density of $Y$ is $$f_Y(y)=\int_0^\infty \frac{x^2}{2y^3}\cdot e^{-\frac{x}y}\,dx=1.$$ The distribution of $Y$ is uniform on $[0,1]$. Therefore $$E Var(X|Y)=E(3Y^2)=3\cdot E(Y^2) = 3\int_0^1 y^2 dy=1.$$ And also $$Var(E(X|Y))=Var(3Y)={\color{red}9}\cdot Var(Y)=9\cdot\frac{1}{12}=\frac34.$$ And then $$Var(X)=E Var(X|Y)+ Var(E(X|Y))=1+\frac34=1.75.$$