If X is an exponentially distributed random variable, denoted as X ∼ Exp (2).
And E[Y|X] = 15 − 5X + 0.5X^2
Var[Y|X] = 3 + 0.5X
What would be E[Y] and Var[Y] separating the “between” and the “within” components?
For the first part (E[Y]), I got the answer attached, but I don't get a closed-form solution rather than a function. So I'm not sure if it's right or not.
There's a very easy way to proceed...
$$\mathbb{E}[X^n]=\int_0^{\infty} x^n 2 e^{-2x}dx=\frac{1}{2^n}\int_0^{\infty}(2x)^n e^{-2x}d(2x)=\frac{n!}{2^n}$$
This result has been obtained using Gamma Function
$$\mathbb{E}[Y]=\mathbb{E}[\mathbb{E}[Y|X]]=\mathbb{E}\Bigg[15-5X+\frac{X^2}{2}\Bigg]=15-\frac{5}{2}+\frac{1}{4}=\frac{51}{4}$$
3.
$$\mathbb{V}[Y]=\mathbb{E}[\mathbb{V}(Y|X)]+\mathbb{V}[\mathbb{E}(Y|X)]=$$
$$=\mathbb{E}\Bigg[3+\frac{X}{2}\Bigg]+\mathbb{V}\Bigg[15-5X+\frac{X^2}{2}\Bigg]=3+\frac{1}{4}+25\mathbb{V}[X]+\frac{1}{4}\mathbb{V}[X^2]-5Cov(X,X^2)$$
...being
$$\mathbb{V}[X^2]=\mathbb{E}[X^4]-(\mathbb{E}[X^2])^2$$
$$Cov(X,Y)=\mathbb{E}[XY]-\mathbb{E}[X]\mathbb{E}[Y]$$
The result is
$$\mathbb{V}[Y]=3+\frac{1}{4}+\frac{25}{4}+\frac{1}{4}\Bigg[\frac{4!}{16}-\frac{1}{4}\Bigg]-5\Bigg[\frac{3!}{2^3}-\frac{1}{2}\cdot\frac{1}{2}\Bigg]=\frac{117}{16}$$