Definite integral of x times Gaussian

calculusdefinite integralsgaussian-integralintegrationnormal distribution

I am tryng to solve the following definite integral:

$$ \int _ 0^\infty x \, \exp \left( {-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2} \right) \, dx
$$

I have tried making the substitution $u = (x-\mu)/\sigma$, which allowed me to divide the integral into what I think are two simpler integrals:

$$
\int _ 0^\infty x \, \exp \left( {-\frac{1}{2}\left(\frac{x-\mu}{\sigma}\right)^2} \right) \, dx \, = \, \int _ {-\mu/\sigma}^\infty (u\sigma + \mu) \, \exp \left( {-\frac{u^2}{2}} \right) \, \sigma \,du \\
$$

$$ = \int _ {-\mu/\sigma}^\infty u \, \sigma^2 \, \exp \left( {-\frac{u^2}{2}} \right) \, du \quad+\quad \int _ {-\mu/\sigma}^\infty \mu \, \sigma \, \exp \left( {-\frac{u^2}{2}} \right) \, du
$$

The one on the left can be solved with some help from wolfram-alpha, and turns out to be $\sigma^2\,\exp(-\frac{\mu^2}{2\sigma^2})$. However, I don't know how to handle the one on the right. I have the vague intuition it can be somehow expressed in terms of the Cumulative Density Function (CDF) of a normal distribution, but not sure how to make that work.

Best Answer

Let’s continue OP’s journey by letting $y=\frac{x-\mu}{\sigma}$, then $$ \begin{aligned} I & =\int_{-\frac{\mu}{\sigma}}^{\infty}(\sigma y+\mu) e^{-\frac{1}{2} y^2} \sigma d y \\ & =\sigma^2 \int_{-\frac{\mu}{\sigma}}^{\infty} y e^{-\frac{1}{2} y^2} d y+\mu \sigma \int_{-\frac{\mu}{\sigma}}^{\infty} e^{-\left(\frac{y}{\sqrt{2}}\right)^2} dy\\ & =-\sigma^2 \int_{-\frac{\mu}{\sigma}}^{\infty} e^{-\frac{1}{2} y^2} d\left(-\frac{y^2}{2}\right)+\mu \sigma\sqrt{2} \int_{-\infty}^{\frac{\mu}{\sqrt 2 \sigma}} e^{-v^2} d v \textrm{ where }v=\frac{-y}{\sqrt2} \\ & =-\sigma^2\left[e^{-\frac{1}{2} y^2}\right]_{-\frac{\mu}{\sigma}}^{\infty}+\mu \sigma\sqrt{2} \cdot\frac{1}{2} \sqrt{\pi}\left[\operatorname{erf} \left(\frac{\mu}{\sqrt{2}\sigma} \right) +1\right]\\ & =\sigma^2 e^{-\frac{\mu^2}{2 \sigma^2}}+\mu \sigma\sqrt{\frac{\pi}{2}}\left[\operatorname{erf}\left(\frac{\mu}{\sqrt{2} \sigma}\right)+1\right] \end{aligned} $$

Related Question