Consider the random sum:
$$X=\left\{\begin{array}{ll} 0 & \text { if } N=0 \\ \xi_{1}+\cdots+\xi_{N} & \text { if } N>0 \end{array}\right.$$
Where $\xi_k$ are i.i.d. random variables, and $N$ is a positive integer-valued random variable.
Assuming that we have:
$$\begin{array}{ll} E\left[\xi_{k}\right]=\mu, & \operatorname{Var}\left[\xi_{k}\right]=\sigma^{2} \\ E[N]=v, & \operatorname{Var}[N]=\tau^{2} \end{array}$$
I'm trying to understand my textbook's (Pinsky & Karlin, "An Introduction to Stochastic Modelling", ed. 4, p. 60) derivation for the variance of $$\operatorname{Var}[X]=v \sigma^{2}+\mu^{2} \tau^{2}$$.
It goes as follows:
To determine the variance, we begin with the elementary step $$ \begin{aligned} \operatorname{Var}[X]=& E\left[(X-\mu v)^{2}\right]=E\left[(X-N \mu+N \mu-v \mu)^{2}\right] \\ =& E\left[(X-N \mu)^{2}\right]+E\left[\mu^{2}(N-v)^{2}\right] \\ &+2 E[\mu(X-N \mu)(N-v)] \end{aligned} $$ Then, $$ \begin{aligned} E\left[(X-N \mu)^{2}\right] &=\sum_{n=0}^{\infty} E\left[(X-N \mu)^{2} \mid N=n\right] p_{N}(n) \\ &=\sum_{n=1}^{\infty} E\left[\left(\xi_{1}+\cdots+\xi_{n}-n \mu\right)^{2} \mid N=n\right] p_{N}(n) \\ &=\sigma^{2}+\sum_{n=1}^{\infty} n p_{N}(n)=v \sigma^{2} \end{aligned} $$ (...)
I've looked at the last three steps for an embarrassing amount of time, but cannot figure out:
Whether there is an error in the textbook: why is it the sum of $\sigma^2$ and the summation? $\sum_{n=1}^{\infty} n p_{N}(n)$ is clearly the expected value of $N$ which is $v$, so how does that turn into $v\cdot\sigma^2$?
Assuming there is an error, and the penultimate expression is supposed to be $\sigma^2 \cdot \sum_{n=1}^{\infty} n p_{N}(n)$ instead, then how can I go from the previous step to that one? My reasoning would be that since $n$ is a specific number within the summation, the conditional expectation can become a normal expectation, thus: $$\sum_{n=1}^{\infty} E\left[\left(\xi_{1}+\cdots+\xi_{n}-n \mu\right)^{2}\right] p_{N}(n)$$
Furthermore, $\xi_1,...,\xi_n$ all have the same expectation (since they are i.i.d), so my intuitive approach (which I am pretty sure is incorrect, but can't put the finger on why) would be to say that the expression can be transformed to:
$$ \begin{aligned} & \sum_{n=1}^{\infty} E\left[\left(n\xi_{1}-n \mu\right)^{2} \right] p_{N}(n) \\ &= \sum_{n=1}^{\infty} E\left[\left(n(\xi_{k}-\mu)\right)^{2} \right] p_{N}(n) \\ &= \sum_{n=1}^{\infty} E\left[n^2\left(\xi_{k}-\mu\right)^{2} \right] p_{N}(n) \\ &= \sum_{n=1}^{\infty} n^2E\left[\left(\xi_{k}-\mu\right)^{2} \right] p_{N}(n) \\ &= \sum_{n=1}^{\infty} n^2\sigma^2 p_{N}(n) \\ &= \sigma^2 \sum_{n=1}^{\infty} n^2 p_{N}(n) \\ \end{aligned}$$
But that leaves a $n^2$ term, instead of the correct $n$. What's the right way to do it?
Thanks in advance !
(Note: I am aware that there are alternative ways to derive the expression for the variance, and I've found a few online, but I would like to understand how to finish with this approach...)
You can’t replace all $\xi_k$'s by $\xi_1$, lest you lose independence!
Since all $\xi_k$ are i.i.d., $$ \operatorname{Var}\left(\sum_{i = 1}^{n} \xi_i\right) = \sum_{i = 1}^{n} \operatorname{Var}(\xi_i) = n \sigma^2\text. $$
Now, recognize that $$ \operatorname{E}\left[{(\xi_1 + \, \ldots \, + \xi_n - n \mu)}^2\right] $$ is by definition $$ \operatorname{Var}\left(\sum_{i = 1}^{n} \xi_i\right) $$ and therefore equal to $n \sigma^2$ and not $n^2 \sigma^2$.