Can somebody help me with the following expectation:
$E[(\sum_{i=1}^{\tau} X_{i})^2 \mid \tau)$ where $X_{i}$, $i=1,2,..$ are independent random variables taking values $1$ and $-1$ with equal chance $\dfrac{1}{2}$ and $S_{n}=\sum_{i=1}^{n}X_{i}$ and $\tau$ independent of $X_{i}$.
Hint: Write $$\begin{align*} \left( \sum_{i=1}^{\tau(\omega)} X_i(\omega) \right)^2 &= \sum_{n \in \mathbb{N}} 1_{\{\tau=n\}}(\omega) \left( \sum_{i=1}^n X_i(\omega) \right)^2 \end{align*}$$
to conclude
$$\mathbb{E} \left( \left[ \sum_{i=1}^{\tau} X_i \right]^2 \mid \tau \right) = \sum_{n=1}^{\infty} 1_{\{\tau=n\}} \mathbb{E} \left( \left[ \sum_{i=1}^n X_i \right]^2 \right).$$
The expectation at the right-hand side can be calculated explicitly using the independence of the random variables $(X_i)_i$ and the fact that $\mathbb{P}(X_i=1)= \mathbb{P}(X_i=-1) = \frac{1}{2}$.