Absolute value martingale of a simple symmetric random walk (source code)

= Absolute value martingale of a simple symmetric random walk
{title2=$M_n=|S_n|-\sum_{k=0}^{n-1}\mathbf1_{\{S_k=0\}}$}

Let a <simple symmetric random walk> start from a deterministic integer $S_0=i$, and put $L_n=\sum_{k=0}^{n-1}\mathbf1_{\{S_k=0\}}$. Then $M_n=|S_n|-L_n$ is a <martingale> with $M_0=|i|$. The visit count includes time $0$ if $i=0$.

For every integer $s$ and step $\xi\in\{-1,1\}$, the pathwise identity
$$
|s+\xi|-|s|=\operatorname{sgn}(s)\xi+\mathbf1_{\{s=0\}}
$$
holds with $\operatorname{sgn}(0)=0$. Subtract the <indicator function> and sum over time to obtain
$$
M_n=|i|+\sum_{k=0}^{n-1}\operatorname{sgn}(S_k)(S_{k+1}-S_k).
$$
The <sign function> of the current state is a bounded <predictable process> for the next increment, so the sum is a <martingale transform>. Alternatively, averaging the two possible next absolute values shows directly that the conditional drift is $\mathbf1_{\{S_k=0\}}$. Bounds $|S_n|\leq|i|+n$ and $L_n\leq n$ verify <integrability> at each finite time.

This is an absolute-value version of the <discrete Tanaka formula>. The correction records the occasions when the <random walk> is at the corner of the absolute-value <function>; away from zero that <function> is locally linear along a single step.