# Moments from pdf

I got confused reading about moments and their relationship with the pdf.

Given a pdf and the values of the parameters, can we calculate the moments of the distribution? More importantly, what is the formula for the second and third moment, (variance and skewness)?

I saw a formula for the variance with an integral minus the mean squared. Is this an integral over all the support of the pdf? What is the equivalent for the third moment?

The moments are defined in terms of integrals.

For continuous random variables

$E(X)=\int_{-\infty}^\infty x f(x) dx$

More generally:

$E(X^k)=\int_{-\infty}^\infty x^k f(x) dx$

$E[(X-\mu)^k]=\int_{-\infty}^\infty (x-\mu)^k f(x) dx$

See Wikipedia on Moments (mathematics).

Given a pdf and the values of the parameters, can we calculate the moments of the distribution?

If we can evaluate the relevant integral, yes.

More importantly, what is the formula for the second and third moment, (variance and skewness)?

The skewness of a random variable is not the third moment of that variable.

Wikipedia on skewness

Variance is the second central moment, so it follows from the formula I gave above by putting $k=2$.

I saw a formula for the variance with an integral minus the mean squared.

Yes, using basic properties of expectation, you can write $E[(X-\mu)^2]=E[X^2]-\mu^2$.

See Wikipedia on variance.

Is this an integral over all the support of the pdf?

Strictly the integral is over the real line, but the pdf is only non-zero within its support, so effectively, yes.

What is the equivalent for the third moment?

\begin{eqnarray} E[(X-\mu)^3]&=&E[(X^3-3\mu X^2+3\mu^2 X - \mu^3)]\\ &=&E(X^3)-3\mu E(X^2)+3\mu^2 E(X) - E(\mu^3)\\ &=&E(X^3)-3\mu E(X^2)+2\mu^3 \end{eqnarray}

The general case is given by Wikipedia in the article on central moments

• As a side question, why is your formula for the third moment different from the one in wiki page for skewness? – Diogo Santos Jul 18 '16 at 10:53
• I'm not sure which formula you mean. Do you mean the one that starts $\gamma_1=...$ and ends with a fraction whose numerator is $\operatorname {E} [X^{3}]-3\mu \sigma ^{2}-\mu ^{3}$? If so, they start with the same formula I have and then instead of collecting the last two terms in $\mu^3$ to have all raw moments they collect the two central terms.to give the middle terms with the second central moment. Two different ways of writing the same thing. Look at their derivation closely. – Glen_b -Reinstate Monica Jul 18 '16 at 10:59