# Derivation of the expectation of exponential random variable

I am following some course notes for the expectation of an exponential random variable, $$X \sim \text{Expon}(\mu)$$. I believe this is a correct derivation:

\begin{align} \mathbb{E}[X] &= \int_{0}^{\infty} x \mu e^{-\mu x} dx \\\\ &= \mu \int_{0}^{\infty} x e^{-\mu x} dx \\\\ &= \mu \int_{0}^{\infty} \frac{d}{d \mu} -e^{-\mu x} dx \\\\ &= -\mu \frac{d}{d \mu} \int_{0}^{\infty} e^{-\mu x} dx \\\\ &= -\mu \frac{d}{d \mu} \frac{1}{\mu} \\\\ &= \frac{1}{\mu} \end{align}

where we used the facts that

$$x e^{-\mu x} = \frac{d}{d \mu} - e^{-\mu x}$$

and

$$\int_{0}^{\infty} e^{-\mu x} dx = \frac{1}{\mu}$$

What I don't follow is the second fact. I would have used calculus rules to compute

$$\int_{0}^{\infty} e^{-\mu x} dx = \frac{1}{- \mu} e^{- \mu x} + C$$

What am I missing?

• This is just a "trick" method. It works as a clever manipulation, but, most people would not actually compute it this way. The standard way is integration by parts. An alternative way is to use the formula for nonnegative random variables $X\geq 0$ that $E[X] = \int_{0}^{\infty} P[X>x]dx$. – Michael Mar 12 at 16:59
• I notice your actual question at the bottom, you are doing it correctly but you are missing a final step: you found an antiderivative $F(x)$ of $e^{-\mu x}$ (so $F'(x) = e^{-\mu x}$) and now you must evaluate it over the limits of integration $F(\infty) -F(0) = (-1/\mu)e^{-\mu x}|_0^{\infty} = 0 - (-1/\mu) = 1/\mu$. Recall that $$\int_a^b F'(x)dx = F(x)|_a^b=F(b)-F(a)$$ So $$\int_0^{\infty} F'(x)dx = F(\infty)-F(0)$$ where $F(\infty) = \lim_{b\rightarrow\infty} F(b)$. – Michael Mar 12 at 17:10
• @Michael: Granted most people would not have done it this way, but Feynman would have. :-) (See "Integration: The Feynman Way.") – Brian Tung Mar 12 at 17:18
• @BrianTung : Would Feynman also have justified passing the derivative with respect to $\mu$ through the integral with respect to $x$? – Michael Mar 12 at 17:20
• @Michael: I don't know, but my guess is that while he was doing this most of the time, he wasn't terribly rigorous. – Brian Tung Mar 12 at 17:20

This is just a formal summary of my comments above, with some detail. Recall the difference between an indefinite integral $$\int f(x)dx$$ and definite integral $$\int_a^bf(x)dx$$.

• Indefinite integral: $$\int e^{-\mu x}dx = \frac{-1}{\mu} e^{-\mu x} + c$$

• Definite integral : $$\int_a^b e^{-\mu x}dx = (\frac{-1}{\mu} e^{-\mu x} + c)|_a^b = \frac{-1}{\mu}e^{-\mu b} - \frac{-1}{\mu}e^{-\mu a}$$

Notice that the $$+c$$ cancels out when taking the difference. So we can use any antiderivative and we might as well use $$c=0$$.

On computing $$E[X]$$ via integration by parts:

$$\frac{d}{dx} [f(x)g(x)] = f'(x)g(x) + f(x)g'(x) \implies \boxed{\int_a^b f(x)g'(x)dx = f(x)g(x)|_a^b - \int_a^b f'(x)g(x)dx}$$

So $$E[X]=\int_0^{\infty} \underbrace{x}_{f(x)} \underbrace{\mu e^{-\mu x}}_{g'(x)}dx = f(x)g(x)|_0^{\infty} - \int_0^{\infty} \underbrace{f'(x)}_{1}\underbrace{g(x)}_{-e^{-\mu x}}dx$$ and $$f(x)g(x)|_0^{\infty} = (-xe^{-\mu x})|_0^{\infty} = \left(\lim_{b\rightarrow\infty} -be^{-\mu b}\right) - 0 = 0$$