Showing a function of Bernoulli random variable is a martingale Let $X_{0},X_{1},\cdots$ be i.i.d Bernoulli random variables with parameter $p$ (i.e., $\mathbb {P}(X_{i}=1)=p$, $\mathbb {P}(X_{i}=0)=1-p$). Define $S_{n}=\sum_{i=1}^{n} X_{i}$ where $S_{0}=0$. Define
\begin{align*}
Z_{n}=\left(\frac {1-p}{p}\right)^{2S_{n}-n},\quad n=0,1,2,\cdots
\end{align*}
Let $\mathcal {F}_{n}=\sigma(X_{0},X_{1},\cdots,X_{n})$. I want to show that $Z_{n}$ is a martingale with respect to this filtration. When I check if $\mathbb {E}(Z_{n+1}\vert \mathcal {F}_{n})=Z_{n}$, I have the following:
\begin{align*}
\mathbb {E}(Z_{n+1}\vert \mathcal {F}_{n})=\mathbb {E}\left( \left(\frac {1-p}{p}\right)^{2S_{n+1}-n-1}\vert\mathcal {F}_{n}\right)=\mathbb {E}\left( \left(\frac {1-p}{p}\right)^{2S_{n}-n}\cdot \left(\frac {1-p}{p}\right)^{2X_{n+1}-1}\vert\mathcal {F}_{n}\right)=\left(\frac {1-p}{p}\right)^{2S_{n}-n}\mathbb {E}\left(\left(\frac {1-p}{p}\right)^{2X_{n+1}-1}\vert\mathcal {F}_{n}\right)=\left(\frac {1-p}{p}\right)^{2S_{n}-n}\mathbb {E}\left(\frac {1-p}{p}\right)^{2X_{n+1}-1}=\left(\frac {1-p}{p}\right)^{2S_{n}-n}\cdot\left(\frac {1-p}{p}\right)^{2p-1}
\end{align*}
I don't know how to show that $\left(\frac {1-p}{p}\right)^{2p-1}=1$ or is there anything wrong with my argument?
 A: Your computation of $\Bbb{E} \left(\frac{1-p}{p} \right)^{2X_{n+1}-1}$ is wrong. Note that it is not equal to $\left(\frac{1-p}{p}\right)^{2\Bbb{E}[X_{n+1}]-1}$, which is what you have written. It is in fact equal to (using the formula $E[f(X)] = \sum_{k} P(X=k)f(k)$):
$$
\Bbb{E} \left(\frac{1-p}{p} \right)^{2X_{n+1}-1} = \left(\frac{1-p}{p}\right)^{2(0)-1} P(X_{n+1} = 0) + \left(\frac{1-p}{p}\right)^{2(1)-1} P(X_{n+1} = 1) \\
= \frac{p}{1-p}(1-p) + \frac{1-p}{p}(p) = p+1-p = 1
$$
and therefore the result of your computation is just $\left(\frac{1-p}{p}\right)^{2S_n - n}$, which shows one part of the martingale conditions. You still need to show that the random variable $Z_i$ has finite expectation, and is adapted to the required filtration. Both of these are easy exercises.

EDIT : To see a use of this martingale, let us imagine we are playing a simple game , where you are tossing coins that turn heads with probability $p$, and you are counting the number of successes, which is $S_n$. The above martingale provides great control on $S_n$. Furthermore, if we were , say losing /gaining a rupee for each time we won/lost (refer to Gambler's ruin) then the above martingale(or a variant) , along with stopping time results , will give us probabilties for various functions of the game (the most common being : if we start with $n$ dollars and wish to get to $N>n$ dollars before we go bankrupt while playing this game, what is the probability of that happening?)
