Assume $X$ is an exponential random variable with unit mean ($f_X(x)=e^{-x}$, $x>0$). I want to calculate the expected value of $\frac{1}{X}$. Since $X>0$, I am expecting that $\mathbb{E}(\frac{1}{X})>0$, but Mathematica gives some negative value. I tried the following input:

Expectation[1/x, {x \[Distributed] ExponentialDistribution[1]}]

and Mathematica 's answer is: -EulerGamma

Is it possible? Am I doing some mistakes?


migrated from math.stackexchange.com Aug 10 '12 at 15:34

This question came from our site for people studying math at any level and professionals in related fields.

  • $\begingroup$ What does Mathematica give you when you use the definition: $\int_0^\infty e^{-x}/x\,dx$ ... ? $\endgroup$ – GEdgar Aug 10 '12 at 14:00
  • 1
    $\begingroup$ On Mathematica 9.0.0, Mathematica simply returns the input when entering your line of code. $\endgroup$ – Jacob Akkerboom Jul 17 '13 at 9:41

Instead of the exponential distribution, consider its truncation $\mathcal{E}_\epsilon(1)$ to $(\epsilon, \infty)$. The expectation can then be found, but it diverges as $\epsilon \downarrow 0$.

enter image description here

Indeed, writing the expectation as integral: $$ \int_0^\infty \frac{1}{x} \mathrm{e}^{-x} \mathrm{d} x $$ you see that the integral diverges at the lower bound. Thus, while it is natural to expect $\mathbb{E}\left(X^{-1}\right) > 0$, the expectation is infinite.

  • 1
    $\begingroup$ Shouldn't Mathematica's output be Infinity instead of -EulerGamma? The latter is evidently wrong. $\endgroup$ – Sjoerd C. de Vries Aug 10 '12 at 20:23
  • 2
    $\begingroup$ @SjoerdC.deVries It could be Infinity, or it could bounce unevaluated. Current output results from use of GenerateConditions->False, as a way to turn off convergence checking. It has an undesirable side effect, that Integrate returns "renormalized answers", i.e. regularized and the divergent part subtracted. Try Integrate[Exp[-x]/x,{x,0,Infinity},GenerateConditions->False]. $\endgroup$ – Sasha Aug 10 '12 at 20:28

Here's a way to see why it diverges to infinity: Observe that $e^{-x}>1/3$ (since $0<e<3$) if $0<x<1$, so $$ \int_0^\infty \frac 1 x e^{-x} \, dx \ge \int_0^1 \frac 1 x e^{-x} \, dx \ge \int_0^1 \frac 1 x \cdot \frac 1 3 \, dx = \infty. $$


Your Answer

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