Reflected biased random walk on the nonnegative integers (source code)

= Reflected biased random walk on the nonnegative integers

Let a discrete-time chain move up with probability $q$ and down with probability $p=1-q$ away from zero, while at zero it moves up with probability $q$ and stays with probability $p$. It is transient for $q>p$, null recurrent for $q=p$, and positive recurrent for $q<p$. In the positive-recurrent case its invariant distribution is
$$
\pi_k=(1-r)r^k,
\qquad r=\frac qp,
$$
and aperiodicity from the self-loop at zero implies convergence to this distribution.