How to find the conditional probability density function $f_{X|X\geq 0}$ where $X\sim N(\mu , {\sigma}^2)$? Problem:
Assume $X\sim N(\mu , {\sigma}^2)$, please find
(1) The conditional probability density function of $X$ given $X \geq 0$;
(2) $E(X|X\geq 0)$ when $\mu = 2, \sigma=1$.

I tried to first write out the conditional distribution function:
$F(x|D)=P(X\leq 0| Y\in D)=P(X\leq x|X\geq0)=\frac{P(X\leq x, X\geq 0)}{P(X\geq 0)}=\frac{P(0\leq X\leq x)}{P(X\geq 0)}=\frac{\int_{0}^{x}f(x)dx}{\int_{0}^{+\infty}f(x)dx}$, if $x\geq0$.
$F(x|D)=0$, if $x <0$.
However, I can't extract a $\int_{-\infty}^{x}$ from $F(x|D)=\frac{\int_{0}^{x}f(x)dx}{\int_{0}^{+\infty}f(x)dx}$ in order to get the density function out of the distribution function.

I don't know whether my trial is on the right way or not, please help me, thanks a lot!
 A: See here :  https://en.wikipedia.org/wiki/Truncated_normal_distribution where $a=0$ and $b=\infty$. You have the answer for the two questions.
A: I would like to motivate how conditional densities of the form $$X \mid X \ge c$$ for some constant $c$ arise from the unconditional density.  The idea is this:  on the interval for which the given condition is true, the conditional density is proportional to the unconditional density, just scaled in such a way that the conditional total probability is $1$.
So for your specific case, $X \mid X \ge 0$ would look like a normal density with the same parameters as $X$, but "cut off" when $X < 0$, and the remaining probability mass $\Pr[X \ge 0]$ is rescaled so that the area under the curve from $0$ to $\infty$ is $1$.  Before conditioning, this area was $$\Pr[X \ge 0] = \int_{x=0}^\infty f_X(x) \, dx = \int_{x=0}^\infty \frac{1}{\sqrt{2\pi} \sigma} e^{-(x-\mu)^2/(2\sigma^2)} \, dx.$$  We can also write this as $$\Pr[X \ge 0] = \Pr\left[\frac{X - \mu}{\sigma} \ge \frac{0 - \mu}{\sigma}\right] = \Pr[Z \ge -\mu/\sigma] = 1 - \Phi(-\mu/\sigma),$$ where $\Phi$ is the standard normal CDF.
Therefore, the conditional density is
$$f_{X \mid X \ge 0}(x) = \begin{cases} 0, & x < 0 \\
\frac{f_X(x)}{1 - \Phi(-\mu/\sigma)}, & x \ge 0 \end{cases},$$ which we can also write as
$$f_{X \mid X \ge 0}(x) = \frac{e^{-(x-\mu)^2/(2\sigma^2)}}{(1 - \Phi(-\mu/\sigma))\sqrt{2\pi}\sigma}  \mathbb 1 (x \ge 0).$$  Here we explicitly wrote out the density and applied an indicator function to represent the piecewise nature of the expression.
Now, based on this, how would you compute the conditional expectation?
