Expected value of $X$ which follows a normal distribution, between a certain interval What is the process of finding the expected value of $X$ in a normal distribution between a certain interval?
In particular I want to find: $E(X | a \le X \le b)$.
For example, if $X$ has $\mu=0$ and $\sigma=0.5$,  I want to calculate
 $E(X | 0.2 \le X \le0.3)$.
I have read this question but it refers to the truncation of the upper tail only.
 A: Like in the other answer, we know that  $$f(x\vert a\leq X \leq b) = \frac{f(x)\mathbb{I}_{(a,b)}}{\int_a^b f(x')dx'}$$
Where I'm using $\mathbb{I}_{(a,b)}$ as the identity function (i.e. it bounds it between $a$ and $b$).
For the denominator, we have:
$$ \int_a^bf(x')dx'  = \int_{-\infty}^bf(x')dx' - \int_a^{\infty}f(x')dx' = \Phi(b) - \Phi(a) $$
Where $\Phi$ is the CDF of a $X$. Putting this together, we see that
$$ \mathbb{E}(X\vert a\leq X \leq b) = \frac{1}{\int_a^bf(x)dx}\int x f(x)\mathbb{I}_{(a,b)}dx = \frac{1}{\Phi(b) - \Phi(a)}\int_a^b x f(x)dx$$
Now, this question does a really good job at calculating $\int_a^b x f(x)dx$. Notice that they what's above is what their missing to calculate $\mathbb{E}(X\vert a\leq X \leq b)$. I'll re-write the rest below:
$$\int_a^bxf(x)dx = \int_a^b(x-\mu)f(x)dx - \int_a^b\mu f(x)dx $$
It's clear that $$\int_a^b\mu f(x)dx = \mu[\Phi(b)-\Phi(a)]$$
And through some manipulation we see that $$\int_a^b(x-\mu)f(x)dx = \sigma(-\phi(\beta) + \phi(\alpha)]$$ where $\alpha = (a - \mu)/\sigma$ and $\beta = (b - \mu)/\sigma$. See the above link for a definition of $\phi$.
Putting this all together and rearranging gives us:
$$\mathbb{E}(X \vert a\leq X \leq b) = \mu + \sigma \frac{\phi(\alpha) - \phi(\beta)}{\Phi(\beta) - \Phi(\alpha)}$$
A: Integrate with respect to the density
$$
f(x \mid a \le X \le b) = \frac{f(x)}{\int_a^b f(x')dx'}.
$$
I like to think of this as $f_{X\mid Y}(x \mid y)$ where $Y = \mathbb{1}_{[a,b]}(X)$. Clearly $$P(Y = 1) = P(a \le X \le b) = \int_a^b f(x) dx.$$ Writing it this way resembles the possibly more familiar thing you have where it's the density of one random variable given a different random variable.
More information on why this truncating move works can be found here, and the special case where $X$ is Gaussian is discussed here. 
