Biased random walk in 1D - expected hitting time for either edge of box I have a random walk process, discrete in time and state, where at each step the probability of $+1$ is $p$ and $−1$ is $q$. $p+q=1$ and $p$ may be different from $q$ (i.e. the random walk is "biased", "asymmetric", has "drift").
Starting from $x$, where $a<x<b$, I'd like to find the expected hitting time to hit either $a$ or $b$.
There's usually a nonzero probability of the random walk never hitting either boundary, which may imply difficulties getting an expectation. So a median of the hitting time distribution could be a useful alternative, if that can be expressed well.
My question seems related to other hitting time questions such as this on the time of first return and this on the distribution of the hitting time. However I'm rather unsure how to go to those helpful points to the expectation, and to the answer regarding hitting either boundary.
 A: Thanks to @Did for pointing out the answer is given in the textbook by Feller "An introduction to probability theory and its applications" volume I, section XIV.3. It deals with this exactly and is clearly written, phrased in terms of the "classic ruin problem" (using the random walk as a model of a gambler). You can download the book from the Internet Archive here.
In Feller's terms, the walk starts at $z$ and the "box" is between $0$ and $a$. The expected time to reach either $0$ or $a$ is denoted $D_z$. $D_z$ can be shown to be finite as given later in the textbook.
The balanced case $p=q$ has to be handled separately, in which case $D_z = z(a-z)$.  For $p\neq q$,
$$
D_z = \frac{z}{q-p} - \frac{a}{q-p} \frac{1-(q/p)^z}{1-(q/p)^a} \quad .
$$
A: The above answer has a dead link, so I just include another reference here: Levin–Peres–Wilmer "Markov Chains and Mixing Times" (Second Edition), Section 2.5. This does't show exactly what the OP requests, but has highly related material and the OP's exact question can be derived from said material.
This link works at the moment, but if it goes dead, it should be easy to find online: the book is very popular, with over 4k citations as of writing this, and freely available online.
