16
$\begingroup$

I wish to use the Computational formula of the variance to calculate the variance of a normal-distributed function. For this, I need the expected value of $X$ as well as the one of $X^2$. Intuitively, I would have assumed that $E(X^2)$ is always equal to $E(X)^2$. In fact, I cannot imagine how they could be different.

Could you explain how this is possible, e.g. with an example?

  • 13
    If two random variables $X, Y$ are independent, then it is indeed true that $\mathbb{E}(XY) = \mathbb{E}(X) \mathbb{E}(Y)$. But $X$ is as far as possible from being independent of itself!2012-05-25
  • 3
    Just take a simple example: if we have $1$ and $2$ as being equally probable, then $\left(\frac{1+2}{2}\right)^2 = \frac{9}{4}$ but $\frac{1^2 + 2^2}{2} = \frac{5}{2}$.2012-05-25
  • 15
    No offense, but if you tried anything at all (even just blindly guessing a distribution) and computed $E(X^2)$ and $E(X)^2$, you would almost surely have found an example on your own. Experimentation is a very useful tool in mathematics.2012-05-26
  • 0
    Jensens inequality. See http://mathoverflow.net/questions/47258/when-is-the-function-of-a-median-closer-to-the-median-of-the-function-than-the-me2012-05-26
  • 1
    @David: No, Cauchy-Schwarz. (Besides, indicating **this** MO page as a reference for Cauchy-Schwarz or for Jensen is, at best, a joke.)2012-07-25
  • 0
    $\int f^2\ne(\int f)^2$2016-02-04

9 Answers 9

17

Assume $X$ is a random variable that is 0 half the time and 1 half the time. Then $$EX = 0.5 \times 0 + 0.5 \times 1 = 0.5$$ so that $$(EX)^2 = 0.25,$$ whereas on the other hand $$E(X^2) = 0.5 \times 0^2 + 0.5 \times 1^2 = 0.5.$$ By the way, since $Var(X) = E[(X - \mu)^2] = \sum_x (x - \mu)^2 P(x)$, the only way the variance could ever be 0 in the discrete case is when $X$ is constant.

12

Actually, if $EX=\mu$ and $E(X-\mu)^2=\sigma^2$

$$ EX^2 = E[X-\mu+\mu]^2=\\ =E(X-\mu)^2-2E[(X-\mu)\mu]+E(\mu^2)=\\=\sigma^2-2\mu E(X-\mu)+\mu^2=\\ =\sigma^2+\mu^2 $$

So $EX^2 =\sigma^2+\mu^2$, no matter the distribution, and $EX^2\ne(EX)^2$ unless the variance equals zero.

8

Note that your logic applied to a uniform distribution would give that $$(x_1+x_2+\cdots+x_n)^2=n({x_1}^2+{x_2}^2+\cdots+{x_n}^2)$$ which is clearly not true in general.

  • 1
    What are the dots for?2012-05-25
  • 0
    whoops. Meant to include them in both as an ellipsis. Fixed.2012-05-25
  • 0
    The usual style is $x+y+z+\cdots$, FYI.2012-05-26
  • 0
    Thanks the for the tip Rahul!2012-05-26
  • 3
    This (highly upvoted) explanation is seductive but it seems to miss the point: what $E(X^2)=E(X)^2$ would imply is something more like the square of the sum being the sum of the squares times the number of terms (not simply the sum of the squares). Another way to see it is that $E(X^2)=E(X)^2$ is true when $X$ is constant while the square of the sum is not the sum of the squares, even when the arguments are all equal.2012-05-26
  • 0
    Robert: Coming from somebody *who wants to learn math properly*, to leave this answer in disarray is... surprising.2012-07-25
  • 0
    @did I had completely forgotten about this question. Thanks for the reminder.2012-07-26
8

One is an average of squares, the other a square of an average. In general, when you reverse two procedures (mix cookies, bake cookies), you have no right to expect the same outcome.

6

Let us take for example $X$ the standard normal, or any normal with mean $0$. Then $E(X)=0$.

But $X^2$ is always positive, so clearly its mean must be positive.

This shows that (in this case) $E(X^2)\ne (E(X))^2$.

In fact, when the expectations exist, $E(X^2)>(E(X))^2$ except when $X$ is constant with probability $1$.

  • 3
    Even easier to see, maybe, if you make the values $-1$ and $1$.2012-05-25
  • 0
    @RobertIsrael: I had deleted my post, since someone had posted the same example. Then decided to use normal, since that's what OP was working with, and ended up with a variant of your example.2012-05-25
1

Say you have a fair coin that says $X=1$ on one side and $X=3$ on the other side. You flip the coin. Clearly, $E(X)=\frac12(1+3) = 2$.

If you are counting $X^2$ instead of $X$, then one side of the coin is worth $1^2=1$ and the other side is worth $3^2=9$, so $E(X^2) = \frac12(1+9)=5$.

$5\ne 2^2$.

0

May as well chime in :)

Expectations are linear pretty much by definition, so $E(aX + b) = aE(X) + b$. Also linear is the function $f(x) = ax$. If we take a look at $f(x^2)$, we get

$f(x^2) = a(x^2) \not= (ax)^2 = f(x)^2$.

If $E(X^2) = E(X)^2$, then $E(X)$ could not be linear, which is a contradiction of its definition. So, it's not true :)

0

My turn:

Let $X$ be uniformly distributed on $[0,1]$. The $E X =\int_{t=0}^1 t dt = \frac{1}{2}$, but $E X^2 =\int_{t=0}^1 t^2 dt = \frac{1}{3}$.

0

Assuming $X$ is a discrete random variable $E(X)=\sum x_ip_i$. Therefore $E(X^2)=\sum x_i^2p_i$ while $[E(X)]^2=\left(\sum x_ip_i\right)^2$. Now, as Robert Mastragostino says, this would imply that $(x+y+z+\cdots)^2=x^2+y^2+z^2+\cdots$ which is not true unless $X$ is constant.

  • 2
    How so? See my comment on the other answer.2012-05-26