# Expected value of sum of a random number of i.i.d. random variables

The question:

$X_1$, $X_2$, etc. are independent and identically distributed non-negative integer valued random variables. $N$ is a non-negative integer valued random variable which is independent of $X_1$, $X_2$ etc.., and $Y$ = $X_1 + X_2 + X_3 + … + X_N$ . (We take $Y = 0$ if $N = 0$).

Prove that $\mathbb{E}[Y] = \mathbb{E}[X_1]\mathbb{E}[N]$.

My attempt:

I know that the probability generating $G_Y(s)$ of $Y$ is equal to $G_N(G_X(s))$... but I'm not sure how that's helpful here.

My intuition leads me in this direction:

$\mathbb{E}[Y] = \sum\limits_{n=0}^{\infty} \mathbb{E}[Y|N=n]\mathbb{P}(N=n)$

$= \sum\limits_{n=0}^{\infty} \mathbb{E}[nX_1|N = n]\mathbb{P}(N=n)$

$= \sum\limits_{n=0}^{\infty} n \mathbb{E}[X_1|N = n]\mathbb{P}(N=n)$ (is this step valid??)

But I don't know where to go from here.

• Don't you mean that $N$ is a positive integer random variable? You start with $X_1$. Also don't you mean that $Y=X_1+\cdots+X_N$? – drhab Nov 26 '17 at 13:04
• @drhab No to your first question - Y is taken to be 0 if N=0. Yes to your second question, thanks! Have edited it to make both points clearer. – StackExchanger10293848 Nov 26 '17 at 13:12
• I suspect not $Y=X_1+\cdots +X_n$ but $Y=X_1+\cdots +X_N$ – drhab Nov 26 '17 at 13:13
• D'oh! Third time's a charm... – StackExchanger10293848 Nov 26 '17 at 13:16
• drhab's answer is the correct continuation of your work. But to be clear, your work is good and you just need to drop the condition to get $E(X_1\mid N=n)=E(X_1)$. Then factor this out of the summation. The step you have a question about validity for is indeed valid because $n$ is just a constant at the point (relative to that particular term in the summation). You just need to keep $n$ inside the summation over $n$. – jdods Nov 26 '17 at 13:34

## 1 Answer

\begin{aligned}\mathsf{E}Y & =\sum_{n=0}^{\infty}\mathsf{E}\left[Y\mid N=n\right]\mathsf{P}\left(N=n\right)\\ & =\sum_{n=1}^{\infty}\mathsf{E}\left[Y\mid N=n\right]\mathsf{P}\left(N=n\right)\\ & =\sum_{n=1}^{\infty}\mathsf{E}\left[X_{1}+\cdots+X_{n}\mid N=n\right]\mathsf{P}\left(N=n\right)\\ & =\sum_{n=1}^{\infty}\mathsf{E}\left[X_{1}+\cdots+X_{n}\right]\mathsf{P}\left(N=n\right)\\ & =\sum_{n=1}^{\infty}\left[\mathsf{E}X_{1}+\cdots+\mathsf{E}X_{n}\right]\mathsf{P}\left(N=n\right)\\ & =\sum_{n=1}^{\infty}n\mathsf{E}X_{1}\mathsf{P}\left(N=n\right)\\ & =\mathsf{E}X_{1}\sum_{n=1}^{\infty}n\mathsf{P}\left(N=n\right)\\ & =\mathsf{E}X_{1}\mathsf{E}N \end{aligned}

second equality: because the first term is $0$ since $\mathsf E[Y\mid N=0]=0$.

fourth equality: because $N$ is independent wrt the $X_i$

fifth equality: linearity of expectation.

seventh equality: factor $\mathsf EX_1$ does not depend on index $n$ so can be taken out of the summation and placed before summation symbol.