To solve $\sum_{i=1}^N E[X_i^2]$ , where $N$ is a random variable, and $X_i$'s are IID, we could apply Wald's equality, which is:
$$ E[Z_N] = E[X_1]E[N] = \cdots = E[X_N]E[N] $$ where $Z_N = X_1 + \cdots + X_N$
So applying this, we can get $$ \sum_{i=1}^N E[X_i^2] = E[X_1^2]E[N] $$
Now my question is since each term of the summation is identical since $X_i$ is IID, why couldn't we instead write the following? $$ \sum_{i=1}^N E[X_i^2] = NE[X_1^2] $$ Obviously, this result is a random variable whereas using Wald's equality did not result in a random variable. What is wrong with this approach? My guess is it's something related to summing from $i=1$ to $N$, where the latter is a random variable.
What I did doesn't make sense, but I don't really have a formal reason why it doesn't work. But I was just started thinking about a different example: $$ \sum_{i=1}^N 1 $$ What is the expected value of this expression? $$ E[\sum_{i=1}^N 1 ] = \sum_{i=1}^N E[1] = \sum_{i=1}^N 1 = E[N] $$ ?
\leftand\right. – joriki May 11 '20 at 05:02