Example 5. Find the first, second, and third order moments of the random variable $X$ with the probability density function

$$
p(x)=\left\{\begin{array}{lr}
0 & \text { if } x \leq 0 \\
e^{-x} & \text { if } x>0
\end{array}\right.
$$
Solution. Let's find the initial moments according to formula (2.6.6):

$$
\begin{aligned}
& v_{1}=M(X)=\int_{-\infty}^{+\infty} x p(x) d x=\int_{0}^{+\infty} x e^{-x} d x=\int_{0}^{+\infty} x d\left(-e^{-x}\right)= \\
& =-\left.x e^{-x}\right|_{0} ^{+\infty}+\int_{0}^{+\infty} e^{-x} d x=0-\left.e^{-x}\right|_{0} ^{+\infty}=1 \\
& v_{2}=M\left(X^{2}\right)=\int_{-\infty}^{+\infty} x^{2} p(x) d x=\int_{0}^{+\infty} x^{2} e^{-x} d x=\int_{0}^{+\infty} x^{2} d\left(-e^{-x}\right)= \\
& =-\left.x^{2} e^{-x}\right|_{0} ^{+\infty}+2 \int_{0}^{+\infty} x e^{-x} d x=0+2 \cdot 1=2, \\
& v_{3}=M\left(X^{3}\right)=\int_{-\infty}^{+\infty} x^{3} p(x) d x=\int_{0}^{+\infty} x^{3} e^{-x} d x=\int_{0}^{+\infty} x^{3} d\left(-e^{-x}\right)= \\
& =-\left.x^{3} e^{-x}\right|_{0} ^{+\infty}+3 \int_{0}^{+\infty} x^{2} e^{-x} d x=0+3 \cdot 2=6
\end{aligned}
$$

Thus, $v_{1}=1, v_{2}=2, v_{3}=6 ; v_{1}=M(X)=a=1$.

Let's compute the central moments using formula (2.6.11):

$$
\begin{aligned}
& \mu_{2}=\int_{-\infty}^{+\infty}(x-a)^{2} p(x) d x=\int_{0}^{+\infty}(x-1)^{2} e^{-x} d x=\int_{0}^{+\infty}\left(x^{2}-2 x+1\right) e^{-x} d x= \\
& =\int_{0}^{+\infty} x^{2} e^{-x} d x-2 \int_{0}^{+\infty} x e^{-x} d x+\int_{0}^{+\infty} e^{-x} d x=2-2 \cdot 1+1=1, \mu_{2}=1
\end{aligned}
$$

$$
\begin{aligned}
& \mu_{3}=\int_{-\infty}^{+\infty}(x-a)^{3} p(x) d x=\int_{-\infty}^{+\infty}(x-1)^{3} e^{-x} d x= \\
& =\int_{-\infty}^{+\infty}\left(x^{3}-3 x^{2}+3 x-1\right) e^{-x} d x= \\
& =\int_{0}^{+\infty} x^{3} e^{-x} d x-3 \int_{0}^{+\infty} x^{2} e^{-x} d x+3 \int_{0}^{+\infty} x e^{-x} d x-\int_{0}^{+\infty} e^{-x} d x= \\
& =\int_{0}^{+\infty} x^{3} e^{-x} d x-3 \cdot 2+3 \cdot 1-1=\int_{0}^{+\infty} x^{3} e^{-x} d x-4
\end{aligned}
$$

Since

$$
\int_{0}^{+\infty} x^{3} e^{-x} d x=\int_{0}^{+\infty} x^{3} d\left(-e^{-x}\right)=-\left.e^{-x} x^{3}\right|_{-\infty} ^{+\infty}+3 \int_{-\infty}^{+\infty} x^{2} e^{-x} d x=0+3 \cdot 2=6
$$

then

$$
\mu_{3}=6-4=2
$$

It has already been proven above that $\mu_{1}=0$ (see example 2, $\mu_{1}=M(X-a)=0$). Thus, the central moments are found: $\mu_{1}=0, \mu_{2}=1, \mu_{3}=2$.

Remark 1. The central moments can also be computed using formulas (2.6.12) and (2.6.13):

$$
\begin{gathered}
\mu_{2}=v_{2}-v_{1}^{2}=2-1^{2}=1 \\
\mu_{3}=v_{3}-3 v_{1} v_{2}+2 v_{1}^{3}=6-3 \cdot 1 \cdot 2+2 \cdot 1^{3}=2
\end{gathered}
$$

Remark 2. The random variable $X$ has moments of all orders. By integrating by parts, we find the initial moment of the $k$-th order:

$$
\begin{aligned}
& v_{k}=M\left(X^{k}\right)=\int_{0}^{+\infty} x^{k} e^{-x} d x=\int_{0}^{+\infty} x^{k} d\left(-e^{-x}\right)= \\
& =-\left.x^{k} e^{-x}\right|_{0} ^{+\infty}+k \int_{0}^{+\infty} x^{k-1} e^{-x} d x=k v_{k-1}, v_{k}=k v_{k-1}, k=1,2,3, \ldots
\end{aligned}
$$

For $k=1$, we get $v_{0}=1$ (see example 1). Therefore,

$$
\begin{gathered}
v_{k}=k v_{k-1}=k(k-1) v_{k-2}=k(k-1)(k-2) v_{k-3}=\ldots k(k-1)(k-2) \ldots 1=k! \\
v_{k}=k!
\end{gathered}
$$