How would I go about computing this?
What is $E[X|a<X<b]$ if $X$ is normally distributed with mean $\mu$ and variance $\sigma^2$?
48 Views Asked by user46234 https://math.techqa.club/user/user46234/detail AtThere are 3 best solutions below
On
First compute the conditional distribution of $X$ given that $a < X < b$. You know the density of $X$ is $$f_X(x) = \frac{1}{\sigma\sqrt{2\pi}}e^{-\frac12\left(\frac{x-\mu}{\sigma}\right)^2},$$
so the conditional density is given by $$ f_{X|a<X<b}(x) = \frac{f_X(x)1_{(a,b)}(x)}{\int_a^b f_X(y)dy}. $$
Once you know the conditional density, you can calculate the expectation by $$ E[X|a<X<b] = \int_{-\infty}^\infty x f_{X|a<X<b}(x)dx. $$
On
You wont get the answer in closed form in terms of elementary functions (exponentials, logs, polynomials, radicals, sines, etc.) but the answer can be expressed in terms of the error function $\text{erf}(x)$.
Start from the definition of expected value in terms of the distribution function $f(x)$: $$ E(X) = \frac{ \int_a^b x f(x) dx }{\int f(x) dx} $$ The denominator is easy to express in terms of the cumulative distribution function $F(x) = \int_{-\infty}^x f(x) dx$ as $F(b) - F(a)$.
In the case of a normal distribution, the c.d.f. is $$ \frac{1}{2}\left[ 1+\text{ erf}\left(\frac{x-\mu}{\sigma\sqrt{2}}\right) \right] $$ so the denominator is $$ \frac{1}{2}\left[ \text{ erf}\left(\frac{b-\mu}{\sigma\sqrt{2}}\right) - \text{ erf}\left(\frac{a-\mu}{\sigma\sqrt{2}}\right)\right] $$
and the numerator is $$\int_a^b x f(x) dx = \int_a^b \frac{1}{\sqrt{2\pi}\sigma }x e^{-(x-\mu)^2/(2\sigma^2)} \\ = \int_a^b \frac{1}{\sqrt{2\pi}\sigma }(x-\mu) e^{-(x-\mu)^2/(2\sigma^2)} + \int_a^b \frac{1}{\sqrt{2\pi}\sigma }\mu e^{-(x-\mu)^2/(2\sigma^2)}\\ =\int_{a-\mu}^{b-\mu} \frac{1}{\sqrt{2\pi}\sigma }t e^{-t^2/(2\sigma^2)}dt + \mu \int_a^b \frac{1}{\sqrt{2\pi}\sigma } e^{-(x-\mu)^2/(2\sigma^2)}\\ = \frac{1}{\sqrt{2\pi}}\left[ e^{-(a-\mu)^2/(2\sigma^2)} -e^{-(b-\mu)^2/(2\sigma^2)}\right]+ \frac{\mu}{2} \left[ \text{ erf}\left(\frac{b-\mu}{\sigma\sqrt{2}}\right) - \text{ erf}\left(\frac{a-\mu}{\sigma\sqrt{2}}\right)\right] $$ Combining and simplifying, $$ E(x) = \mu + \frac{2}{\sqrt{2\pi}}\frac{ e^{-(a-\mu)^2/(2\sigma^2)} -e^{-(b-\mu)^2/(2\sigma^2)}}{\text{ erf}\left(\frac{b-\mu}{\sigma\sqrt{2}}\right) - \text{ erf}\left(\frac{a-\mu}{\sigma\sqrt{2}}\right)} $$ Notice that for $a$ highly negative and $b$ highly positive, the numerator of the seocnd term goes to zero and $E(X)$ goes to $\mu$ as expected (excuse the pun).
I solve this first for $Z\sim N(0,1)$. Noting that $f(z|a<z<b)=\frac{\phi(z)}{\Phi(b)-\Phi(a)}$, we have:
\begin{align*}\mathbb{E}[Z|a<Z<b] &=\ \int^b_azf(z|a<z<b)dz=\int^b_a\frac{z\phi(z)}{\Phi(b)-\Phi(a)}dz \\ &=\ \frac{1}{\Phi(b)-\Phi(a)}\int^b_az\phi(z)dz \\ &=\ \frac{[-\phi(z)]^b_a}{\Phi(b)-\Phi(a)} = \frac{\phi(a)-\phi(b)}{\Phi(b)-\Phi(a)}\end{align*}
I now solve it for the case where $X\sim N(\mu,\sigma^2)$.
\begin{align*}\mathbb{E}[X|a<X<b]&=\ \mathbb{E}[X|\frac{a-\mu}{\sigma}<Z<\frac{b-\mu}{\sigma}] \\ &=\ \mathbb{E}[\sigma Z+\mu|\frac{a-\mu}{\sigma}<Z<\frac{b-\mu}{\sigma}] \\ &=\ \mu+\sigma\mathbb{E}[Z|\frac{a-\mu}{\sigma}<Z<\frac{b-\mu}{\sigma}] \\ &=\ \mu+\sigma\frac{\phi(\frac{a-\mu}{\sigma})-\phi(\frac{b-\mu}{\sigma})}{\Phi(\frac{b-\mu}{\sigma})-\Phi(\frac{a-\mu}{\sigma})}\end{align*}