TITLE: About Wald's equation, why can't I simply use total expectation to prove?
QUESTION [5 upvotes]: Wald's equation: for i.i.d r.v $X_i$, if $N$ is a stopping time, then:
$$E \sum_{i=1}^N X_i = E[N] E[X_1]$$
I just read this equation, but it seems to me if I do:
$$E \sum_{i=1}^N X_i =E_N [\sum_{i=1}^N X_i|N]=E_N[NEX_i]=E[N]E[X_1]$$
I don't know what's wrong with this proof. But in this proof it does not use the fact that $N$ is stopping time.

REPLY [4 votes]: Wald's identity fails if $N$ and $X_i$ are too strongly coupled to one another. Wikipedia gives a nice example to illustrate this point: if you have a sequence of iid Bernoulli(1/2) variables $X_n$, and you set $N=1-X_1$, then $E \left [ \sum_{i=1}^N X_i \right ] = 0$ (because the sum is either empty or a sum of a single zero) but $E[N]E[X_i]=1/4$.
That said, with no additional assumptions, you can write this:
$$E \left [ \sum_{i=1}^N X_i \right ] = \sum_{n=1}^\infty E \left [ \left. \sum_{i=1}^n X_i \right | N=n \right ] P(N=n).$$
You can also use linearity of conditional expectation to get
$$E \left [ \sum_{i=1}^N X_i \right ] = \sum_{n=1}^\infty \sum_{i=1}^n E[X_i \mid N=n] P(N=n).$$
But you cannot replace $E[X_i \mid N=n]$ by $E[X_i]$, unless you have some independence-type hypothesis. (For instance, in Wikipedia's example, $E[X_i \mid N=0]=1$ and $E[X_i \mid N=1]=0$.)