Understanding where the definition of E(X^2) comes from

In the middle of trying to understand how to find E(X^2).

I have read that the definition of this expectation is the integral from b to a of x^2*f(x), where f(x) is the pdf of a random variable.

What direction should I take in developing my understanding of the background to this definition?

Many thanks in advance all!

Re: Understanding where the definition of E(X^2) comes from

Hey Resuscitative.

The easiest way to understand E[g(X)] is to think in terms of a random variable g(X) and then looking at it's mean.

So in the case of g(X) = X^2, we take our random variable and square it and this becomes a new random variable.

Then we look at the mean of this random variable and this is equivalent to E[g(X)] or E[Y] if Y = g(X) = X^2.

That's to give some intuition, but algebraically you can think of these as moments which actually have an interpretation in terms of the frequency spectrum of the random variable. I would use the explanation above for intuition and then just think about the complicated expressions in terms of algebra (try not to think too hard about things like say E[log(X)] or E[X^2 + X]).