Exercise comes from "1000 exercices in probability" (12.9.6). Let $X_1, X_2, \dots$ be independent random variables with $X_n=\begin{cases} 1, & \text{with probability} & (2n)^{-1}, \\ 0, & \text{with probability} & 1-(n)^{-1}, \\ -1, & \text{with probability} & (2n)^{-1}. \end{cases}$
Let $Y_{1}=X_{1}$ and for $n\geq2$
$Y_n=\begin{cases} X_{n}, & \text{if}& Y_{n-1}=0, \\ nY_{n-1}|X_{n}|, & \text{if} & Y_{n-1}\neq0. \end{cases}$
Show that, $Y_{n}$ is a martingale, with respect to $F_{n}=\sigma(Y_{1},Y_{2},\dots,Y_{n})$.
Solution
With $I_{k}=I_{\{Y_{k}=0\}}$ , where $I$ is indicator function $E(Y_{n}|F_{n-1})=E(X_{n}I_{n-1}+nY_{n-1}|X_n|(1-I_{n-1})\mid F_{n-1})=\dots$
My question is what information this indicator provides and why it is needed. Thanks for help.
Note that $Y_{n-1}$, $I_{n-1}$ and $(1-I_{n-1})$ are $\mathcal{F}_{n-1}$-measurable, thus
$$\mathbb{E}(Y_n \mid \mathcal{F}_{n-1}) = I_{n-1} \cdot \mathbb{E}(X_n \mid \mathcal{F}_{n-1}) + n (1-I_{n-1}) \cdot Y_{n-1} \cdot \mathbb{E}(|X_n| \mid \mathcal{F}_{n-1})$$
Moreover, we have $\mathcal{F}_n = \sigma(Y_1,\ldots,Y_n) \subseteq \sigma(X_1,\ldots,X_n)$. By applying tower property we obtain $$ \begin{align*} \mathbb{E}(|X_n| \mid \mathcal{F}_{n-1}) &= \mathbb{E}(\mathbb{E}(|X_n| \mid \sigma(X_1,\ldots,X_{n-1}) \mid \mathcal{F}_{n-1}) \stackrel{\ast}{=} \mathbb{E}(\mathbb{E}(|X_n|) \mid \mathcal{F}_{n-1}) \\ &= \mathbb{E}(|X_n|) = 2 \cdot \frac{1}{2n} = \frac{1}{n} \end{align*}$$ where we used in $(\ast)$ the independence of $X_n$ and $\sigma(X_1,\ldots,X_{n-1})$. Similarily, $$\mathbb{E}(X_n \mid \mathcal{F}_{n-1}) = \mathbb{E}X_n = 0$$
Thus $$\begin{align*} \mathbb{E}(Y_n \mid \mathcal{F}_{n-1}) &= 0 + n \cdot (1-I_{n-1}) \cdot Y_{n-1} \cdot \frac{1}{n} \\ &= (1-I_{n-1}) \cdot Y_{n-1} + 0 \cdot I_{n-1} = Y_{n-1} \end{align*}$$
(The last equality follows from the fact that $Y_{n-1} \cdot I_{n-1} = 0 = 0 \cdot I_{n-1}$.)