# $(X|Y=y)\sim N(y,y^2)$, $Y\sim U[3,9]$. Find $Var(X).$

$$(X|Y=y)\sim N(y,y^2)$$, $$Y\sim U[3,9]$$, where $$N(y,y^2)$$ is a normal distribution with mean $$y$$ and variance $$y^2$$, $$U[3,9]$$ is a uniform distribution on $$[3,9].$$

On this condition, find $$Var(X).$$

My attempt:

Use the law of total variance : $$Var(X) = E(Var(X|Y))+Var(E(X|Y)).$$

Since $$(X|Y=y)\sim N(y,y^2)$$, $$E(X|Y)=Y$$ and $$Var(X|Y)=Y^2$$ (?)

Plug them into the law : $$Var(X)=E(Y^2)+Var(Y).$$

Since $$Y\sim U[3,9]\implies Var(Y)=\frac{(9-3)^2}{12}=3, E(Y)=\frac{9+3}{2}=6\implies E(Y^2)=Var(Y)+E(Y)^2=3+6^2=39.$$

$$\implies Var(X)=39+3=42.$$

The thing is, I'm not sure about the part I marked with (?).

I'm comfortable with saying that $$(X|Y=y)\sim N(y,y^2)\implies E(X|Y=y)=y,\ Var(X|Y=y)=y^2$$ because it's just what it is.

But I don't quite feel right about saying that $$(X|Y=y)\sim N(y,y^2)\implies E(X|Y)=Y,\ Var(X|Y)=Y^2$$, because $$y$$ is just a number and $$Y$$ is a random variable. (and of course $$E(X|Y=y)$$ and $$E(X|Y)$$ are different things, I guess)

Actually my answer is correct, and it makes me feel more uncomfortable since I don't know what exactly I'm doing right now.

More specifically, I know by the definition that $$E(X|Y=y)=\int x\frac{f(x,y)}{f_Y(y)}dx$$, but not sure what $$E(X|Y)$$ means. Is $$E(X|Y)=\int x\frac{f(x,Y)}{f_Y(Y)}dx$$ a valid expression? But does $$f(x,Y)$$ make sense? And what's the relationship between $$(X|Y=y)$$ and $$X|Y$$? The right side of $$|$$ symbol only affects to the PDF?

I want to know what I'm doing. Any help would be appreciated.

The conditional distribution of $$X$$ given $$Y$$ is normal with mean $$Y$$ and variance $$Y^2$$; so by construction, what this means is $$\operatorname{Var}[X \mid Y] = Y^2.$$ In fact, the property that $$X \mid Y$$ is normally distributed is not relevant to the total variance calculation. So long as $$X \mid Y$$ is a random variable whose mean is $$Y$$ and variance $$Y^2$$, you will get the same result for $$\operatorname{Var}[X]$$.
I am a bit puzzled as to why you accept $$\operatorname{E}[X \mid Y = y] = y$$, yet not $$\operatorname{E}[X \mid Y] = Y$$. The latter has simply replaced a deterministic variable with a random one. The result is that the moment is itself a random variable. So when we write something like $$\operatorname{Var}[X \mid Y]$$, we are talking about a random variable that is a function of the random variable $$Y$$. For example, $$W = Y^2$$ is also a function of the random variable $$Y$$. I could even write something like $$\int_{x=0}^\infty Y x^2 e^{-Y x} \, dx$$ and this is a random variable that is a function of $$Y$$. In fact, it is $$\operatorname{E}[X^2 \mid Y]$$ when $$X \mid Y \sim \operatorname{Exponential}(Y)$$ where $$Y$$ is a rate parameter. So long as $$Y \ge 0$$ this integral and the resulting conditional expectation, is well-defined.