# Explain these functions.

We are given two functions of moments of a random variable X:

$${\bf E}(X)=\int_{-\infty}^{\infty} tf_X(t)\,dt.$$ $${\bf E}(X^2)=\int_{-\infty}^{\infty} t^2f_X(t)\,dt.$$

Then we are given a piecewise function $f_X(t) = \begin{cases} 0 \text{ ; } t<0 \\ 1 \text{ ; } 0\leq t \leq 1 \\ 0 \text{ ; } t>1 \end{cases}$

I'm sorry, I don't know how to format this in a better way. But could someone explain what is being done? I have the work and the answers but I am unsure of what all of this means.

The answer for ${\bf E}(X) = 1/2$ and for ${\bf E}(X^2) = 1/3$.

It's been awhile since I took calculus so please explain in details.

-

The "formula" for $E(X)$, the expectation of the random variable $X$, also called the first moment of $X$ about the origin, is $$E(X)=\int_{-\infty}^{\infty} tf_X(t)\,dt,$$ where $f_X(t)$ is the density function of the random variable $X$. Since $f_X(t)$ is $0$ on the interval $(-\infty,0)$, and also on the interval $(1,\infty)$, these parts make no contribution to the integral. If you want to be formal about this, we have for example $\int_{-\infty}^0 (t)(0)\,dt=0$. Because the density function is $0$ in this interval, there is no "weight" there, no contribution to the average value $E(X)$. The same is true for the interval $(1,\infty)$.

Since the density function is $1$ between $0$ and $1$, we want to find $$\int_0^1 (t)(1)\,dt,$$ which is just $$\int_0^1 t\,dt.$$ To calculate the integral, we find an "antiderivative" $G(t)$ of $t$. Then our definite integral is $G(1)-G(0)$. An antiderivative of $t$ is given by $G(t)=\dfrac{t^2}{2}$. You may remember this, and if you don't, you can check that it works by differentiating. Finally, $$G(1)-G(0)=\dfrac{1^2}{2}-\dfrac{0^2}{2}=\dfrac{1}{2}.$$

For $E(X^2)$, use the same reasoning. We end up needing $$\int_0^1t^2\,dt.$$ Finally, $H(t)=\dfrac{t^3}{3}$ is an antiderivative of $t^2$. Now calculate $H(1)-H(0)$.

-
First, you can write $\mathbb{E}(X) = \int_{-\infty}^0 t \cdot0 \,dt + \int_0^1 t \cdot 1 \,dt + \int_1^\infty t \cdot 0 \,dt$, by just plugging in the value of $f_X(t)$ on the intervals in its definitions.
The integrals of zero evaluate to zero, whereas the one from $0$ to $1$ is just $\int_0^1t\,dt = \frac{1}{2}t^2 |_{0}^1 = \frac{1}{2} - 0$. To check that $\frac{1}{2}t^2$ is an antiderivative of $t$, you can differentiate the former.
For the second integral, split up the limits of integration in the exact same way. The only nonvanishing integral will be that of $t^2$, over the interval from 0 to 1. Perhaps you know that this is $\frac{1}{3}t^3 |_0^1 = \frac{1}{3}-0$.