Biased gambler's ruin probability (source code)

= Biased gambler's ruin probability

For a walk that steps right with probability $p>1/2$, put $\lambda=(1-p)/p$. If $a<0<b$ and $T_x$ is the first hitting time of $x$, then the martingale $\lambda^{S_n}$ and the <optional stopping theorem> give
$$
\mathbb P(T_a<T_b)
=\frac{\lambda^b-1}{\lambda^b-\lambda^a}.
$$
Letting the opposite boundary tend to infinity gives
$$
\mathbb P(T_a<\infty)=\lambda^{-a},
\qquad
\mathbb P(T_b<\infty)=1.
$$