9
$\begingroup$

Let $X \sim \mathcal{N}(\mu_X,\sigma_X^2) = \mathcal{N}(0,1)$. Let $f(x) = e^{-x^2}$. I want to approximate $E[f(X)]$.

Wolfram Alpha gives \begin{align} E[f(X)] \approx \frac{1}{\sqrt{3}}. \end{align}

Using a Taylor expansion approach, and noting that $f''(0) = -2$, I get \begin{align} E[f(X)] &\approx f(\mu_X) + \frac{f''(\mu_X)}{2} \sigma_X^2 \\ & = f(0) + \frac{f''(0)}{2} \\ & = 1 + \frac{-2}{2} \\ & = 0. \end{align}

Why does my approximation fail to match the Wolfram Alpha result? What can be done to fix it?

$\endgroup$
6
  • $\begingroup$ Ok, we need $\sigma_X^2$ to be small, then it works. Then smaller the better. Makes sense. $\endgroup$ – Bertus101 Nov 4 '20 at 14:07
  • 2
    $\begingroup$ $e^{-x^2}$ looks like an upside down parabola near zero, but it is strictly positive everywhere (and so the expected value must also be strictly positive), whereas the parabola will eventually turn negative. The more probability mass you have far from zero, the more you are landing in the region where it is a very bad approximation. $\endgroup$ – Chris Haug Nov 4 '20 at 14:18
  • 1
    $\begingroup$ Shouldn't you use a univariate transformation? i.e: define Y as $e^{-x^2}$, and then calculate $F(a) = P(Y < a) = P(e^{-x^2} < a) = P(X > \sqrt{-ln(a)}) = 1 - P(X < \sqrt{-ln(a)}) $ and then differentiate wrt a to get f(a), where F is the cdf and f the pdf. Then, calculate the expected value $E(Y) = \int f(y) \times y$. Wolfram alpha is giving you the exact result, it's only approximating $\frac{1}{\sqrt{3}}$, my guess is that it's using the univariate transformation I mentioned above. $\endgroup$ – Caio C. Nov 4 '20 at 14:26
  • 2
    $\begingroup$ @CaioC. You can do it a lot easier than that by noting that the form of $f$ is such that it combines with the normal density into a standard Gaussian integral. $\endgroup$ – Chris Haug Nov 4 '20 at 14:34
  • 1
    $\begingroup$ @ChrisHaug you're right, that's a lot easier. $\endgroup$ – Caio C. Nov 4 '20 at 14:48
14
$\begingroup$

You does not need an approximation here. Use properties of moment generating functions, $X$ is standard normal so $X^2$ is chisquared with one df, with moment generating function $M_{X^2}(t)=\frac1{\sqrt{1-2t}}$ (for $t<1/2$.) Then note that $$\DeclareMathOperator{\E}{\mathbb{E}}M_X(t)=\E e^{t X} $$ is the definition, so that $$\E e^{-X^2}=M_{X²}(-1)=\frac1{\sqrt{1-2\cdot (-1)}}=\frac1{\sqrt{3}} $$ We can check that in R with a fast simulation (always a good idea to do a simulation check):

 mean( exp(-rnorm(1E6)^2) )
[1] 0.5774847
 1/sqrt(3)
[1] 0.5773503

Answer in comments:

What about if 𝑋 was not standard normal but normal with mean $𝜇_𝑋$ and variance $𝜎^2_𝑋$. Can your approach still be used or is it specific to the case of a standard normal distribution?

It can still be used. I will not give full details. First, the easy case $X \sim \mathcal{N}(0,\sigma^2)$. Then $X=(\sigma Z)^2$ with $Z$ standard normal, so in the above argument you get the argument $-\sigma^2$ in place of $-1$ for the mgf (moment generating function.) For the fully general case, see for instance Moment-generating function (MGF) of non-central chi-squared distribution and work from there.

$\endgroup$
2
  • $\begingroup$ Very nice thanks, I'll keep an eye out for when I can use that approach in future! $\endgroup$ – Bertus101 Nov 4 '20 at 15:58
  • 1
    $\begingroup$ What about if $X$ was not standard normal but normal with mean $\mu_X$ and variance $\sigma_X^2$. Can your approach still be used or is it specific to the case of a standard normal distribution? $\endgroup$ – Bertus101 Nov 4 '20 at 16:00
8
$\begingroup$

There's no need to "approximate" when you can derive the exact value of $\mathbb{E}[f(X)]$ . Let us apply the Law of the Unconscious Statistician (LoTUS) to obtain : \begin{align*} \mathbb{E}[f(X)] &= \int_{-\infty}^{+\infty} e^{-x^2} \cdot \frac{1}{\sqrt{2\pi}} \exp\left(-\frac{x^2}{2}\right)~dx\\ &= 2\int_0^{+\infty} \frac{1}{\sqrt{2\pi}} \exp\left(-\frac{3x^2}{2}\right)~dx\\ &= 2\int_0^{+\infty} \frac{1}{\sqrt{2\pi}} \cdot\frac{1}{\sqrt{6z}} e^{-z}~dz\\ &= \frac{2}{2\sqrt{3\pi}} \int_0^{+\infty} e^{-z} z^{\frac{1}{2} -1} ~dz\\ &=\frac{1}{\sqrt{3\pi}}\cdot \Gamma\left(\frac{1}{2}\right)\\ &= \frac{1}{\sqrt{3\pi}}\cdot \sqrt{\pi}\\ &= \frac{1}{\sqrt{3}} \end{align*}

Hope this helps. :)

$\endgroup$

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.