Example: Suppose that the number of people entering a department store on a given day is a random variable with mean 50. Suppose further that the amounts of money spent by these customers are independent random variables having a common mean of $8. Finally, suppose also that the amount of money spent by a customer is also independent of the total number of customers who enter the store. What is the expected amount of money spent in the store on a given day?
Below is a suggested solution,
Let $N$ denote the number of customers that enter the store and $X_i$ the amount of money spent by the $i$th such customer, then the total amount of money spent can be expressed as $\sum_{i=1}^{N} X_i$. Now,
$$E\left[ \sum_{1}^{N} X_i\right] = E\left[ E\left[ \sum_{1}^{N} X_{i}|N\right]\right]$$
where, $E\big[ \sum_{1}^{N} X_{i}|N=n\big ] = E\big [\sum_{i}^{n}X_i|N=n\big ] = E\big[ \sum_{1}^{n}X_i\big ]$ (by the independence of $X_i$ and $N$) (*)
My question: I always thought that $E\big[ \sum_{1}^{N} X_{i}|N=n\big ] =E\big[ \sum_{1}^{n}X_i\big ]$ holds intuitively. But i don't undestand the equation (*) and what it means by "by the independence of $X_i$ and $N$".
For every $n$, let $S_n=\sum\limits_{k=1}^nX_k$. Your first question is to understand why some independence condition is needed for the double identity $$E(S_N\mid N=n)=E(S_n\mid N=n)=E(S_n)$$ to hold. While the first $=$ sign always holds, by definition, the second may very well fail.
To understand this, consider the case when $(X_n)$ is i.i.d. Bernoulli with $P(X_n=1)=p$ and $P(X_n=0)=1-p$ for some $p$ in $(0,1)$, and $$N=\inf\{n\geqslant1\mid X_n=1\}$$ Then, obviously, $$E(S_n)=np$$ for every $n$, while $S_n=1$ on $N=n$ hence, in general, $$E(S_n\mid N=n)=1\ne E(S_n)$$ If $(X_n)$ is independent of $N$, on the contrary, $(\ast)$ holds since each $S_n$ is independent of the event $[N=n]$.