Showing that for $X_1, \ldots, X_n$ iid random variables independent of $N$, $E\left(\sum_{i=1}^NX_i \mid N=n\right) = n\mu$.

Suppose that $X_1, \ldots, X_n$ are iid random variables with mean $\mu$. Consider the sum with number of random variables added a random variable itself. That is, $\sum_{i=1}^NX_i$ where $N$ is a random variable that is independent of all the $X_i$'s. I am interested in showing that:

$$E\left(\sum_{i=1}^NX_i \mid N=n\right) = n\mu$$

To do so, I have that:

$$E\left(\sum_{i=1}^NX_i \mid N=n\right) = E\left(X_1 \mid N=n\right) + \ldots + E\left(X_N \mid N=n\right)$$

It appears that due to $N$ being independent of the $X_i$'s, at first glance it seems I can just drop the conditonals, but that would give me $N\mu$ and not $n\mu$. Furthermore, we can decompose it by its definition as an infinite sum or an integral, which would require us to find:

$$f\left(\sum_{i=1}^NX_i =T \mid N=n\right) = \frac{f\left(\sum_{i=1}^NX_i =T , N=n\right)}{f(N=n)}$$

But, $f\left(\sum_{i=1}^NX_i =T , N=n\right)$ appears to equal:

$$f\left(\sum_{i=1}^NX_i =T , N=n\right) = f\left(\sum_{i=1}^nX_i =T\right)$$

and we are left with the $f(N=n)$ denominator. Can someone tell me what I'm doing wrong?

• If $N = n$, you can just swap in $n$ in the sum, i.e. $E\left(\sum_{i = 1}^N X_i \mid N= n\right) = E\left(\sum_{i = 1}^n \mid N = n\right)$ and then since the $X_i$'s are iid you have what you were after. – Therkel Dec 6 '16 at 11:00
• @Therkel Is there a more formal or rigorous way of thinking about what allows me to swap in the $n$? Is it because $\{\omega: E\left(\sum_{i = 1}^N X_i(\omega) \mid N(\omega)= n\right)\} = \{\omega: E\left(\sum_{i = 1}^n X_i(\omega)\mid N(\omega) = n\right)\}$? – user321627 Dec 6 '16 at 11:08
• Formally, your conditional expectation is not a random variable; rather you are looking at a (discrete) function $f : n \mapsto E\left(\sum_{i=1}^N X_i \;\middle\vert\; N = n\right)$ for which the swap of $N$ and $n$ make sense. Compare with $E\left(\sum_{i = 1}^N X_i\;\middle\vert\; N\right)$, which is a random variable mapping $E\left(\sum_{i = 1}^N X_i\;\middle\vert\; N\right) : \omega \mapsto E\left(\sum_{i = 1}^{N} X_i\;\middle\vert\; N = N(\omega)\right)$. – Therkel Dec 6 '16 at 11:18
• I noticed there appears no $\omega$ in the $X_i$ term. Is it interpreted as being a constant, a random variable, or both, as in a fixed random variable? – user321627 Dec 6 '16 at 11:25
• @user321627: Use the fact that $\mathrm{E}[X\mid A]=\mathrm{E}[X\mathbf{1}_A]/P(A)$ for events $A$ with $P(A)>0$. That allows you to easily conclude that $\mathrm{E}[S_N\mid N=n]=\mathrm{E}[S_n\mid N=n]$ since $S_N\mathbf{1}_{N=n}=S_n\mathbf{1}_{N=n}$ pointwise (here $S_n=\sum_{i=1}^nX_i)$. (Unrelated: Those sets you defined above makes no sense). – Stefan Hansen Dec 6 '16 at 11:36

From your second formula you have \begin{align} \mathbb{E}\left[ \sum_{i=1}^{N} X_i \; \bigg| \; N=n \right] &= \mathbb{E}\left[ X_1 | N=n\right] + \cdots + \mathbb{E}\left[ X_1 | N=n\right], \end{align} however written this way it is not clear how many times that summation is being performed, but using the fact we are conditioning on $N=n$ we can tidy that up as \begin{align} \mathbb{E}\left[ \sum_{i=1}^{N} X_i \; \bigg| \; N=n \right] &= \sum_{i=1}^{n} \mathbb{E}\left[ X_i | N=n \right] = \sum_{i=1}^{n}\mathbb{E}\left[ X_i \right]. \end{align} For your second part note that using independence we actually have \begin{align} f\left(\sum_i^N X_i = T , N=n\right) = f\left(\sum_i^n X_i = T \right) \cdot f_N (N=n) \end{align} so the term in the denominator will cancel, as it stands you have ignored the probability of $N = n$.
• I would avoid writing $E[X_1\mid N = n] + \ldots + E[X_1\mid N =n]$ because it is not clear how many variables you are summing or why. Rather, perhaps skip that step? – Therkel Dec 6 '16 at 11:23