# Confusion related to expectation notation

I have a confusion regarding notation of the expectation. Consider the following:

$$E_x(x^2) = \sum_x x^2p(x)$$ $$E_x(x|y) = \sum_x xp(x|y)$$

So the same notation here is giving different meaning right isn't it?

Up to now I was assuming $E_x$ taking $p(x)$ and calculating the expectation. However after looking at $E_x(x|y) = \sum_x xp(x|y)$, I am a bit confused

• The subscript in $E$ tells us over which variable(s) we must sum (or integrate, for continuous r.v.'s). What probability mass or density function we will use (marginal or conditional in your case) is indicated by the argument of $E$. – Alecos Papadopoulos Sep 14 '13 at 2:10
• @AlecosPapadopoulos. I didn't get it. So in your definition $E_x(x^2) = \sum_x x^2*(p(x^2))$. Further what tell us that we multiply the density by like in the above examples we have x and x^2 which are multiplied to the density/mass functions. What tells us whether to us x or $x^2$ – user34790 Sep 14 '13 at 2:13
• The argument of $E$ dictates whether we will use a conditional or marginal mass or density function of the variable that is indicated by the subscript. So $E_x(x^2) = \sum_x x^2p(x)$ but $E_x(x^2|y) = \sum_x x^2p(x|y)$: the existence of conditioning in the argument of $E$ indicates that we should use the pmf of $x$ conditional on $y$. The conditioning symbol and the conditioning variable is part of the notation too, so it is not the same notation. – Alecos Papadopoulos Sep 14 '13 at 2:21

## 1 Answer

I think that the source of your confusion is that $E_x(x^2)$ and $E_x(X|Y)$ are two very different things. $E_x(x^2)$ is an expected value -- a number, say 10 or 2000 or -13. However, $E_x(X|Y)$, the conditional expected value, is in fact not a single value, but a function of $y$. You could write it more explicitly as

$E_x(X|Y) = g(y) = \sum_{x \in X} x \cdot P( X = x | Y = y )$

(I use $g(y)$ to indicate that $E_x(X|Y)$ is a function).