# Conditional Expectation of Random Sum of Random Variables

Given two random variables $X,Z$, both integrable, the conditional expectation $E[X | Z]$ is defined as a random variable which is $\sigma(Z)$-measurable, and satisfies $\int_A E[X | Z] dP = \int_{A} X dP$ for all $A \in \sigma(Z)$, which is the sigma algebra generated by $Z$.

My question is : we know that conditional expectation is linear, however what if the factor of linearity depends on another random variable occuring within the expectation?

For, suppose that $Y$ is a random variable with finite variance, and $N$ is an integer valued random variable, with finite variance. I want to show that if $Z = \sum_{i=1}^N Y_i$, where $Y_i$ are iid copies of $Y$, then $E[Z|N] = E[Y]N$.

So, is the following permitted? $$E[Z | N] =^? \sum_{i=1}^N E[Y_i | N] = E[Y_i] + ... + E[Y_i] = E[Y]N$$

If not, then how would I approach this problem, because proceeding by definition also means I get stuck.

Observe that \begin{align} E[Z | N] &= E[Y_1 + \dots + Y_N| N] \\ &= E[E[Y_1 + \dots + Y_N| N]|N] \\ &= E[E[Y_1| N] + \dots + E[Y_N| N]|N] \\ &= E[E[Y| N] + \dots + E[Y| N]|N] \\ &= E[N\cdot E[Y| N]|N] \\ &= E[N\cdot E[Y]|N] \\ &= N\cdot E[Y] \end{align}
• So it is completely permitted? For example, if say $Y = N$, even in that case? The reason why I am asking, is because for example, the derivative is linear, but $\sum_{i=1}^x x$ does not have the same derivative as $x^2$. Oct 30, 2017 at 4:06
• Yes, although the case with $Y=N$ is really boring: you are taking the sum of $N$ copies of $E[N|N]$, so it's almost trivial that the answer is $N^2$. Also, $\sum_{i=1}^x x = x^2$; you may have gotten confused with $\sum_{i=1}^x i$. Oct 30, 2017 at 4:15
• Ok. However, the dertivative by linearity of $\sum_{i=1}^x x$ is $1+1+ ... + 1 = x$ while the actual derivative of $x^2 = 2x$, so that's what I wanted to point out. But thanks anyway. Oct 30, 2017 at 4:16
• Ah alright, I see what you mean. The difference is that here, we condition on $N$ again before using linearity, so we can say that $N$ behaves like a constant inside the conditional expectation. (Recall that sometimes we write $E[f(X,N)|N=n]$, i.e. we assert that the expectation assumes that $N$ takes some particular value.) Oct 30, 2017 at 4:23