I'm in trouble to solve this problem:
Let $U$ a random variable with Normal distribution of variance $1$ and mean randomly generated from a random variable $X$ with Uniform distribution in the range $(0,2)$. In other terms: $X\sim U(0,2);U|X=x\sim N(x,1)$. Find:
a) the expected value of $U$
b) the variance of $U$
c) the probability that $U$ assumes a positive value
d) $Cov(X,U)$.
For the point a) I did:
$E[U]=E[E[U|X=x]]:=\int_{\mathbb{R}}E[U|X=x]f_X(x)dx=\int_{0}^{2}E[U|X=x]\cdot\frac{1}{2}dx=\frac{1}{2}\int_{0}^{2}E[U|X=x]dx=\frac{1}{2}\int_{0}^{2}xdx=1$.
For the point b) I did:
$Var[U]=Var[U|X=x]:=E[(U|X=x)^2]-E[U|X=x]^2\Rightarrow $ $E[(U|X=x)^2]:=\int_{0}^{2}E[(U|X=x)^2]\cdot f_X(x)dx=\int_{0}^{2}E[(U|X=x)^2]\cdot\frac{1}{2}dx=\frac{1}{2}\int_{0}^{2}E[(U|X=x)^2]dx=\frac{1}{2}\int_{0}^{2}x^2dx=4/3 \Rightarrow 1=\frac{4}{3}-1\rightarrow \frac{2}{3}$.
It's correct? I'm especially interested to the approach to the problem.
For the points d) I did:
$Cov(X,U):=E[XU]-E[X]E[U]$, and knowing $E[X]:=1$ and $E[U|X=x]=1$ i have to find $E[XU]=E[E[XU|X=x]]=\int_{0}^{2}E[XU|X=x]f_X(x)dx=\frac{1}{2}\int_{0}^{2}E[XU|X=x]dx=\frac{1}{2}\int_{0}^{2}xE[U|X=x]dx=\frac{1}{2}\int_{0}^{2}x^2dx=\frac{4}{3} \Rightarrow Cov(X,U)=\frac{1}{3}$
For the points c) I think I have to use the same approach:
$\mathbb{P}(U>0)=\int_{0}^{+\infty}\mathbb{P}(U>0|X=x)f_X(x)dx$ with $(0,+\infty)$ the range of the Normal. So:
$\int_{0}^{2}[\int_{0}^{+\infty}\frac{1}{2}\cdot \frac{1}{\sqrt{2\pi}}e^{-\frac{(u-x)^2}{2}}du]dx=...$
but I don't understand how transform that integral… Thanks in advance for any help!
a) What you did is okay but can be done more concise.
On base of the observation $\mathbb E[U\mid X=x]=x$ we conclude that $\mathbb E[U\mid X]=X$ which leads to:$$\mathbb EU=\mathbb E\mathbb E[U\mid X]=\mathbb EX=1\tag1$$ Here the first equality of $(1)$ is a general rule.
b) Here you must have made a mistake.
Further note that variance of $U$ does not really depend on the value taken by $X=x$. It takes value $1$ for every $x$ which allows the conclusion that $\mathsf{Var(U\mid X)}=1$, hence $\mathbb E\mathsf{Var}(U\mid X)=1$. This leads to:$$\mathsf{Var}(U)=\mathbb E\mathsf{Var}(U\mid X)+\mathsf{Var}(\mathbb E[U\mid X])=1+\mathsf{Var}(X)\tag2$$Here the first equality of $(2)$ is a general rule.
We find $\mathsf{Var}(X)=\mathbb EX^2-(\mathbb EX)^2=\frac43-1=\frac13$ so that $\mathsf{Var}(U)=1+\frac13=\frac43$.
c)
$\begin{aligned}P\left(U>0\right) & =\int_{0}^{2}P\left(U>0\mid X=x\right)f_{X}\left(x\right)dx\\ & =\frac{1}{2}\int_{0}^{2}P\left(U-x>-x\mid X=x\right)dx\\ & =\frac{1}{2}\int_{0}^{2}1-\Phi\left(-x\right)dx\\ & =\frac{1}{2}\int_{0}^{2}\Phi\left(x\right)dx \end{aligned} $
See the edit below for a computation of this integral.
d)
Again you did okay, but a bit more concise is possible:
$\mathbb{E}XU=\mathbb{E}\mathbb{E}\left[XU\mid X\right]=\mathbb{E}\left[X\mathbb{E}\left[U\mid X\right]\right]=\mathbb{E}X^{2}=\frac{4}{3}$ and $\mathbb{E}X\mathbb{E}U=1\times1=1$ so that $$\mathsf{Cov}\left(X,U\right)=\frac{4}{3}-1=\frac{1}{3}$$
edit: (thanks to Sesame)
Applying integration by parts on the result under c) we find:
$$\begin{aligned}\frac{1}{2}\begin{aligned}\int\end{aligned} _{0}^{2}\Phi\left(x\right)dx & =\frac{1}{2}\left[x\Phi\left(x\right)\right]_{0}^{2}-\frac{1}{2}\int_{0}^{2}xd\Phi\left(x\right)\\ & =\Phi\left(2\right)-\frac{1}{2}\int_{0}^{2}x\phi\left(x\right)dx\\ & =\Phi\left(2\right)-\frac{1}{2\sqrt{2\pi}}\int_{0}^{2}xe^{-\frac{1}{2}x^{2}}dx\\ & =\Phi\left(2\right)-\frac{1}{2\sqrt{2\pi}}\left[-e^{-\frac{1}{2}x^{2}}\right]_{0}^{2}\\ & =\Phi\left(2\right)-\frac{1-e^{-2}}{2\sqrt{2\pi}} \end{aligned} $$