Period-two martingale corrector for a birth-death chain (source code)

= Period-two martingale corrector for a birth-death chain
{title2=$h_\theta(k)=k-\theta\mathbf1_{\{k\text{ odd}\}}$}

For a <birth-death chain> on the integers with right/left probabilities $p_i,q_i>0$ depending on parity $i\in\{0,1\}$, define $h_\theta(k)=k-\theta\mathbf1_{\{k\text{ odd}\}}$. It is a <harmonic function for a Markov chain> exactly when
$$
\theta=\frac{p_0-q_0}{p_0+q_0}=-\frac{p_1-q_1}{p_1+q_1},
$$
equivalently $p_0p_1=q_0q_1$. The correction is bounded. Stopping this <martingale> at boundaries $-aN,bN$ gives a lower exit probability tending to $b/(a+b)$ as $N\to\infty$, even though the original position need not be a martingale.

// Target: markov-process.bigb