Why does $y \int_0^\infty x^2 e^{-y|x|} \, dx=\frac 1 {y^2}\int_0^\infty x^2 e^{-x}\,dx$? Find the variance of variance of random variable with pdf $f(x)=\frac \lambda 2 e^{-\lambda|x|}$
Solution:
$\operatorname E(X)$ is zero because density is even.
$$\operatorname{Var}X=\operatorname E(X^2)=\int x^2 f(x)\,dx=\lambda \int_0^\infty x^2e^{-\lambda|x|} \, dx=\frac 1 {\lambda^2}\int_0^\infty x^2 e^{-x} \, dx$$
Confusion:


*

*So $\operatorname E(X)$ is zero because density is even means that because pdf is an even function? So for even functions, when we integrate from negative $\infty$ to positive $\infty$ we get $0$? I forgot calculus so can anyone write out the full function of $\operatorname E(X)$ for me?


2.Why does $\lambda \int_0^\infty x^2 e^{-\lambda|x|} \, dx=\frac 1 {\lambda^2}\int_0^\infty x^2 e^{-x} \, dx$? Is there something from calculus I totally forgot about that relates to this?


*I did some research and the generalizaion of $\lambda \int_0^\infty x^p e^{-\lambda|x|} \, dx=\frac 1 {\lambda^p}\int_0^\infty x^p e^{-x} \, dx = \frac 1 {\lambda^p} \gamma(p+1)$ with $\gamma(p+1)$ being the gamma function. Can anyone explain the gamma function here being equal to integral of $x^p e^{-x}$?

 A: You have
$$
\operatorname E(X) = \int_{-\infty}^\infty xf(x)\, dx
$$
provided $$\int_0^\infty xf(x)\,dx <+\infty \text{ and } \int_{-\infty}^0 xf(x)\,dx >-\infty. \tag 1$$
If $(1)$ holds, then
$$
\int_{-\infty}^\infty xf(x)\, dx = \lim_{a\,\to\,\infty} \int_{-a}^a xf(x)\,dx.
$$
If $f$ is an even function then $x\mapsto xf(x)$ is an odd function; i.e. $(-x)f(-x) = -\big( xf(x)\big).$ Thus we have
\begin{align}
\int_{-a}^0 xf(x)\,dx & = \int_a^0 (-w)f(-w) (-dw) \quad \text{where } w=-x \\[10pt]
& = \int_a^0 (-w) f(w) (-dw) \quad \text{because $f$ is even} \\[10pt]
& = \int_a^0 wf(w)\,dw \\[10pt]
& = -\int_0^a wf(w)\,dw \\[10pt]
& = -\int_0^a xf(x)\,dx \quad \text{because $w$ and $x$ are bound variables.}
\end{align}
Therefore
$$
\int_{-a}^a xf(x) \,dx = 0
$$
and thus $\lim\limits_{a\,\to\,\infty}$ of that integral is $0.$
\begin{align}
\lambda \int_0^a x^2 e^{-\lambda x} \, dx = \lambda \cdot \frac 1 {\lambda^3} \int_0^a (\lambda x)^2 e^{-\lambda x} (\lambda\, dx) = {} & \frac 1 {\lambda^2} \int_0^{\lambda a} u^2 e^{-u} \, du & & \text{where } u = \lambda x \\
& & & \text{and thus } du = \lambda\,dx \\[12pt]
= {} & \frac 1 {\lambda^2} \int_0^{\lambda a} x^2 e^{-x} \, dx
\end{align}
and then let $a\to\infty.$
A: 1) For odd functions you have that if you integrate from some interval [-t,t], you get 0 since the function is essentially flipped according to the origin. Now, when you are taking the expectation, you are multiplying by an odd function ("x"), and an even function times an odd function is odd.
Of course, that is a very calculus-y way to explain it; a more probabilistic explanation would be that for any value X=c, it is equally likely to take X=-c since the density is symmetric w.r.t 0. That should tell you why the expectation is 0. (To be pedantic about continuous random variables, you really should look at an open interval around c, but it might be too much detail.)
2) The thing you forgot is called u-substitution, which allows you to change your domain of integration. Here, you just need to rescale x by $\lambda$.
3) You can do integration by parts again and again, and every time you do an integration by parts, one of the powers of p "falls down".
