I would like to calculate the variance of a uniformly distributed continuous random variable. The probability density function of a uniformly distributed continuous random variable is $$f_{X}(x) = \frac{1}{b-a}.$$

To obtain the variance, my book suggests to first calculate the second moment $$E[X^{2}]=\int_{-\infty}^{\infty}\frac{x^{2}}{b-a}dx.$$

However, I fail to see where the expression comes from. The expected value of a random variable is $$E[X] = \int_{-\infty}^{\infty} xf_{X}(x)dx.$$

So, when calculating $E[X^{2}]$ the density part remains the same and $X^{2}$ somehow translates to $x$ in the integral to be raised to the second power. Why does that happen?

  • $\begingroup$ This question should be tagged as [self-study] please edit to add such tag. $\endgroup$
    – Tim
    Commented Oct 16, 2015 at 10:51

1 Answer 1


$$E[X^{2}]=\int_{-\infty}^{\infty}\frac{x^{2}}{b-a}dx.$$ is from law of unconscious statistician. You can search the proof of the theorem.

Simply say, suppose $Y=g(X)$

then $$E(Y)=\int_{-\infty}^{\infty} g(x)f(x)dx$$

Now $g(x)=x^2$



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.