0

Letting $E[X]= E[X^2] - (E[X])^2$, can anyone explain why $E[X^2]$ is simply the integral over $x^2f(x)$ instead of $f(x)^2$ ?

For example in the below picture: enter image description here

Why isn't the last line $f(x)^2$ instead of $x^2f(x)$ since $X$ simply describes $f(x)$? It doesn't make sense as it takes the expectation outside the domain of $X$ if it has finite bounds.

scoopfaze
  • 976
edd91
  • 27
  • 5
  • See https://math.stackexchange.com/questions/700160/intuition-behind-variance-forumla/700231#700231 and here https://math.stackexchange.com/questions/2005675/what-is-ex2-mean-in-literal-terms/2006462#2006462. – Michael Hoppe Jun 30 '19 at 06:07
  • 2
    That doesn't answer my question – edd91 Jun 30 '19 at 06:10
  • https://en.wikipedia.org/wiki/Riemann%E2%80%93Stieltjes_integral#Application_to_probability_theory –  Jun 30 '19 at 06:18

3 Answers3

3

This is a particular case of the "Law of the Unconscious Statistician". $$\mathsf E[g(X)]=\int_\Bbb R g(x)~f_X(x)~\mathrm d x$$


Let $Z=X^2$

$\begin{align}\mathsf E(X^2) &=\mathsf E(Z)\\&=\int_{\Bbb R^+} z~f_{Z}(z)~\mathrm d z\\&=\int_{\Bbb R^+} x^2~f_{X^2}(x^2)~\mathrm d (x^2)\\&=\int_{x^2\in\Bbb R^+} x^2~\mathrm d \mathsf P(X^2\leqslant x^2)\\&=\int_{x\in\Bbb R^+} x^2~\mathrm d\mathsf P(-x\leqslant X\leqslant x)\\&=\int_{x\in\Bbb R^+} x^2~\mathrm d\mathsf P(X\leqslant x)+\int_{x\in\Bbb R^-}~x^2~\mathrm d \mathsf P(X\leqslant x)\\&=\int_\Bbb R x^2~f_X(x)~\mathrm d x\end{align}$

Graham Kemp
  • 129,094
  • I'm afraid this goes over my head but it seems to have the consensus and thanks for answering – edd91 Jun 30 '19 at 19:40
2

Hint: Suppose each value of $h(X)$ is unique for strictly positive $x$ (and zero for less than zero $X$). Hence, the probability of $h(X) = h(x)$ is the same as the probaility of $X = x$. Therefore, $\mathbb{E}(h(X)) = \int_{-\infty}^{\infty}h(x)f(x)$. Now, you can try to follow this case to find when we can have duplicate values ($X^2$ is a specific case here).

OmG
  • 3,138
2

Because this is how it is "defined". For an absolutely continuous random variable $X$ with probability density function $f$ and a measurable function $g$, we have $$\mathbb{E}[g(X)]= \int g(x) f(x) dx.$$ In your case, $g(x)= x^2$.

EDIT: If you want a rigorous explanation of the formula above, have a look into transformation formula for pdfs.

max
  • 312
  • I don't follow this because it is E[X^2] where X is a capital letter, i.e. representing f(x) – edd91 Jun 30 '19 at 06:30
  • No, $f(x)$ is the p.d.f. of $X$, it stays unchanged. The function you try to find expectation of is $g(X)$, which is in your case $g(x)=x^2$. – max Jun 30 '19 at 06:31
  • This is not the definition of $E(X^2)$, it's a consequence of the Law of the Unconscious Statistician. – littleO Jun 30 '19 at 07:05
  • 1
    I agree. It's a consequence of transforming one pdf into another, which is the consequence of basic change of variables... Never heard of the "Law of the Unconscious Statistician" though. I believe for the question it was useful to understand the difference between the pdf $f(x)$ and the function $g(x)$. – max Jun 30 '19 at 07:24