= Solution
Use the positive-integer convention for the <geometric distribution>:
$$
\mathbb P(K=k)=p(1-p)^{k-1},\quad k\geq1,\qquad\mathbb EK=1/p.
$$
Conditional on $K=k$, <independence> gives $\mathbb E[S\mid K=k]=k/\lambda$. Taking <expectations> gives
$$
\boxed{\mathbb ES=\frac1{p\lambda}.}
$$
This is the convention required below because a chain starting at $i$ makes at least one visit to $i$. If instead $K$ counts failures on $\{0,1,\ldots\}$, its mean is $(1-p)/p$, and the corresponding answer for that different random sum is $(1-p)/(p\lambda)$.
For the chain of part (b), let $K_i$ count visits to $i$, including the initial visit, before absorption. After a departure to $i-1$, <gambler's ruin> on $\{0,\ldots,i\}$ gives probability $1/i$ of reaching zero before returning to $i$. After a departure to $i+1$, the analogous probability of reaching $N$ before returning is $1/(N-i)$. The departure is equally likely in either direction, so the probability of absorption before a return is
$$
p_i=\frac12\left(\frac1i+\frac1{N-i}\right)
=\frac{N}{2i(N-i)}.
$$
At every return to $i$, the <Strong Markov property> resets these alternatives. Hence the <geometric return count before absorption> gives $K_i\sim\operatorname{Geom}(p_i)$ on positive integers. One may construct the chain from its embedded jump chain and a separate sequence of fresh <independent> exponential clocks. Then its successive <holding times> at $i$ are <independent and identically distributed> rate-$\lambda_i$ <exponential random variables>, independently of $K_i$, and
$$
I=\sum_{j=1}^{K_i}E_j^{(i)}.
$$
Using the first calculation gives the <occupation time at an interior state of a variable-rate symmetric walk>:
$$
\boxed{\mathbb E_iI=\frac1{p_i\lambda_i}
=\frac{2i(N-i)}{N\lambda_i}.}
$$
For $N=2,i=1$, $p_i=1$ and the only visit is the initial one; the degenerate positive-integer <geometric distribution> at one handles this case. Other states' rates affect the time of each excursion, but not its probability of return, which explains why only $\lambda_i$ appears in this <expectation>.
Back to article page