Given a symmetric random walk on $\{0,1,2,\ldots,N\}$, and given a starting position $k$, the walker transitions to either $k-1$ or $k+1$ with equal probability. The absorption barriers $0$ and $N$ are “lose” and “win”, respectively. Denote by $p_k$ the probability of “winning” when starting from position $k$.
This yields the recurrence equation $$p_k = \frac{1}{2}(p_{k-1}+p_{k+1})$$ with boundary conditions $p_0 = 0$, and $p_N = 1$. It’s possible to think of this as a random walk on $\mathbb{Z}$ where $p_n = 1\,\forall n\ge N$ and $p_n = 0 \,\forall n\le 0$.
There is an elementary solution (and I know there are plenty of advanced theorems about random walks, too), but I’m stuck finding the solution via generating functions and would appreciate some help.
The elementary solution is:
- Note that the recurrence equation is equivalent to $p_{k+1}-p_k = p_k-p_{k-1} =: \Delta$ for $1\le k \le N-1$
- Therefore $p_N = p_N - p_{N-1}+p_{N-1} - p_{N-2} + p_{N-2} \mp \cdots -p_k+p_k = (N-k)\Delta + p_k$
- Plugging in the boundary conditions $p_N = 1$ and $p_0=0$ yields $\Delta = \frac{1}{N}$
- Thus $p_k = \frac{k}{N}$ for $0\le k\le N$ (or $p_k = \frac{\max\{0,\min\{k,N\}\}}{N}$ for $k\in\mathbb{Z}$).
How to solve this via generating functions? Because I know the solution I can guess a generating function for the $p_k$ by assembling it from well-known building blocks, namely $G(z) = \frac{z(1-z^N)}{N(1-z)^2}$ has the required coefficients. But it’s unclear how to get from the recurrence equation and boundary conditions to this $G(z)$. Any help or hints appreciated, thanks!
For this purpose, we consider a strongly related recurrence relation with natural domain. We consider the recurrence relation \begin{align*} q_k&=\frac{1}{2}\left(q_{k-1}+q_{k+1}\right)& k\geq 1\tag{2.1}\\ q_0&=0, q_1=\frac{1}{N}\tag{2.2}\\ \end{align*} This recurrence relation looks similar to (1.1) and (1.2), but the domain of validity is not restricted to $0\leq k\leq N$. We can use the same derivation OP has used to find $p_k=\frac{k}{N}$ and obtain a generating function $H(z)$ with \begin{align*} \color{blue}{H(z)=\sum_{k=0}^{\infty}q_kz^k=\sum_{k=0}^{\infty}\frac{k}{N}z^n}\tag{2.3} \end{align*} Note, the upper limit of the sum in (2.3) is set to $\infty$ according to the range $k\geq 1$ in (2.1). Using (2.3) we can write $H(z)$ as rational function. We obtain \begin{align*} \color{blue}{H(z)}&=\frac{1}{N}\sum_{k=0}^{\infty}kz^k=\frac{z}{N}\sum_{k=1}^{\infty}kz^{k-1}\\ &=\frac{z}{N}\,\frac{d}{dz}\sum_{k=1}^{\infty}{z^k}=\frac{z}{N}\frac{d}{dz}\left(\frac{1}{1-z}\right)\\ &\,\,\color{blue}{=\frac{z}{N(1-z)^2}}\tag{2.4} \end{align*}
A generating function approach:
We can find a rational function for the recurrence relation (2.1) and (2.2) by recalling a theorem
See for instance theorem 4.1.1 in Enumerative Combinatorics, Vol. I by R. P. Stanley. From the recurrence relation (2.1) with initial condition (2.2) and the theorem we set \begin{align*} H(z)=\frac{P(z)}{Q(z)} \end{align*} get $\alpha_1=-2, \alpha_2=1$ and obtain the denominator \begin{align*} \color{blue}{Q(z)=1-2z+z^2} \end{align*} In order to find $P(z)=a_0+a_1z$ we will use the initial condition (2.2). We also use the coefficient of operator $[z^n]$ to denote the coefficient of $z^n$ of a series. We obtain \begin{align*} \color{blue}{H(z)}&\color{blue}{=\frac{a_0+a_1z}{1-2z+z^2}}\\ \\ \color{blue}{a_0}&=[z^0]H(z)\left(1-2z+z^2\right)=[z^0]\left(q_0+q_1z+q_2z^2+\cdots\right)\left(1-2z+z^2\right)\\ &=q_0\,\,\color{blue}{=0}\\ \color{blue}{a_1}&=[z^1]H(z)\left(1-2z+z^2\right)=[z^1]\left(q_0+q_1z+q_2z^2+\cdots\right)\left(1-2z+z^2\right)\\ &=-2q_0+q_1\,\,\color{blue}{=\frac{1}{N}} \end{align*} and derive finally in accordance with (2.3): \begin{align*} \color{blue}{H(z)}=\frac{0+\frac{1}{N}z}{\left(1-2z+z^2\right)}\,\,\color{blue}{=\frac{z}{N\left(1-z\right)^2}} \end{align*}