0
$\begingroup$

Let's say $x \in \mathbb{R}$ is normally distributed so that $x \sim \mathcal{N}(\mu,\sigma^2)=p(x)$. I want to simplify the following integral, which includes arbitrary, but fixed integration limits $a\in \mathbb{R}$ and $b\in \mathbb{R}$.

$I := \int_{a}^{b} x^2 p(x)dx$.

In the case of $a=-\infty, b=\infty$ the integral $I$ equals $\sigma^2$, right? Does anyone have an idea how to simplify $I$ with different bounds?

$\endgroup$
2
  • 1
    $\begingroup$ With bounds of $\pm\infty$, and assuming by "$p$" you mean the normal density function, this integral equals $\mu^2+\sigma^2$. For arbitrary bounds there are two basic techniques that will work: integrate by parts or use the substitution $y=x^2$. The latter will exhibit the solution as proportional to the sum of two incomplete Gamma integrals. $\endgroup$
    – whuber
    Feb 14, 2018 at 23:11
  • $\begingroup$ Thanks for your comment @whuber. I did forget that $\sigma^2 = \text{var}[x] = \mathbb{E}[x^2]-\mathbb{E}[x]^2 = I_{-\infty,\infty} - \mu^2$, such that $I_{-\infty,\infty} = \sigma^2 + \mu^2$. $\endgroup$
    – Looper
    Feb 16, 2018 at 9:06

2 Answers 2

3
$\begingroup$

Hint: Since $\frac{\mathrm d}{\mathrm dx}\phi(x) = -x\phi(x)$ where $\phi(x)$ is the pdf of the standard normal variable, it is possible to find the anti-derivative of $x^2\phi(x)$ by writing it as $x\cdot (x\phi(x))$ and then using the integration by parts formula: $$\int u\, \mathrm dv = uv - \int v \,\mathrm du$$ with $u = x$ and $v = \phi(x)$. Your mission, if you choose to accept it, is to figure out how this idea can be adapted for use with $p(x)$, the pdf of an arbitrary normal random variable. Good luck! This answer will self-destruct in thirty days.

$\endgroup$
0
$\begingroup$

Thanks for the hint @sarwarte. Here's what I got so far:

$ I := \int_a^bx^2p(x)dx = \frac{1}{\sqrt{2\pi\sigma^2}} \int_a^bx^2\exp(-\frac{(x-\mu)^2}{2\sigma^2})dx.$

Sidenote: Using the Substituation $z := \frac{x-\mu}{\sigma}$, and therefore $dx = \sigma dz$.

$I = \frac{1}{\sqrt{2\pi}} \int_{(a-\mu)/\sigma}^{(b-\mu)/\sigma}(z\sigma+\mu)^2\exp(-\frac{z^2}{2})dz.$

Sidenote: Define $\hat{a} := (a-\mu)/\sigma$ and $\hat{b} := (b-\mu)/\sigma$.

$I = \frac{1}{\sqrt{2\pi}} ( \sigma^2\int_{\hat{a}}^{\hat{b}}z^2\exp(-\frac{z^2}{2})dz + 2\mu\sigma \int_{\hat{a}}^{\hat{b}}z\exp(-\frac{z^2}{2})dz + \mu^2 \int_{\hat{a}}^{\hat{b}}\exp(-\frac{z^2}{2})dz)$

Calculating the antiderivative for each of these integrals seperatly.

$(i): \int{z^2\exp(-\frac{z^2}{2})dz} = -z\exp(-\frac{z^2}{2}) + \int{\exp(-\frac{z^2}{2})}dz \\ \qquad \qquad \qquad \qquad = -z\exp(-\frac{z^2}{2}) + \sqrt{\pi/2} \, \text{erf}(z/\sqrt{2}),$

where $erf(\cdot)$ is the error function. Here I used the hint with the partiell integration.

$(ii): \int z\exp(-\frac{z^2}{2})dz = -\exp(-\frac{z^2}{2}).$

$(iii): \int \exp(-\frac{z^2}{2})dz = \sqrt{\pi/2} \, \text{erf}(z/\sqrt{2}).$

Now putting things togehter:

$I = \frac{1}{\sqrt{2\pi}} ( \sigma^2[-z\exp(-\frac{z^2}{2}) + \sqrt{\pi/2} \, \text{erf}(z/\sqrt{2})]_{\hat{a}}^{\hat{b}} + 2\mu\sigma[-\exp(-\frac{z^2}{2})]_{\hat{a}}^{\hat{b}} \qquad + \mu^2 [\sqrt{\pi/2} \, \text{erf}(z/\sqrt{2})]_{\hat{a}}^{\hat{b}}) \\ \qquad = \frac{1}{\sqrt{2\pi}} ( \exp(-\hat{a}^2/2)(\hat{a}\sigma^2+2\mu\sigma) - \exp(-\hat{b}^2/2)(\hat{b}\sigma^2+2\mu\sigma) \\ \qquad + \sqrt{\pi/2} (\sigma^2+\mu^2) (\text{erf}(\hat{b}/\sqrt{2}) - \text{erf}(\hat{a}/\sqrt{2})) ).$

And thats my final result; Mission accomplished?

edit: Result verified.

$\endgroup$
1
  • 1
    $\begingroup$ The overall form is about right but in detail there are multiple errors. This is made immediately clear by applying dimensional analysis: for instance, the factor $\hat a + 2\mu$ is the sum of a dimensionless constant $\hat a$ and a constant $\mu$ that has the same units of measurement as $z$ itself. $\endgroup$
    – whuber
    Feb 16, 2018 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.