Conditional expectation and conditional variance I am trying to solve an exercise for my homework and am stuck. The question is the following:
Assume you have two dependent random variables $X,Y$. The expectation and the variance are given by $E(Y|X=x)=5x$ and $var(Y|X=x)=2x+x^2$ and assume that $E(X)=12$ and $Var(X)=4$. Compute the expectation and variance of $Y$
I succeeded in computing the expectation, but unfortunately I am stuck for the variance. Here is what I tried:
$$Var(Y)= \int_{\mathbb{R}^2}(y-\mu_Y)^2 f_{X,Y}(x,y)dxdy$$
$$=\int_\mathbb{R}\big( \int_\mathbb{R} (y-\mu_Y)^2 f_{Y|X}(y|x)dy\big)f_X(x)dx.$$
Question: Can the integral in the parentheses be expressed in terms of $E(Y|X=x)=5x$ and $var(Y|X=x)=2x+x^2$? If yes, then I know how to conclude the computation. However I am not able to show this. First I thought that the integral in the parentheses is just $Var(Y|X=x)$, but it isn't. In fact, the following holds:
$$Var(Y|X=x)=\int_\mathbb{R} (y-E(Y|X=x))^2 f_{Y|X}(y|x)dy,$$
where $\mu_Y$ is known (see below).
Note: For completeness, I write down the computation for the expectation, as I guess that the one of the variance must be similar.
$$E(Y)=\int_{\mathbb{R}^2}y f_{X,Y}(x,y)dxdy=\int_\mathbb{R}\big( \int_\mathbb{R} y f_{Y|X}(y|x)dy\big)f_X(x)dx=\int_\mathbb{R}E(Y|X=x) f^X(x) dx=\int_\mathbb{R}5xf^X(x)dx=5E(X).$$
In the third equation, I used the definition of conditional expectation, and in the last one the definition of expectation of $X$.

We can write: $$\mathbb E[Y\mid X]=5X\text{ and }\mathsf{Var}[Y\mid X]=2X+X^2$$
Then there are two nice equalities:$$\mathbb EY=\mathbb E[\mathbb E[Y\mid X]]$$
and:$$\mathsf{Var}Y=\mathsf{Var}(\mathbb E[X\mid Y])+\mathbb E(\mathsf{Var}[Y\mid X])$$
Have a look here for conditional variance.
