The problem is stated as the following:
Suppose we have a man walking along a pavement, whose width is 5. For each step forward, the drunk man can either move to the left, or to the right. Both outcomes are equally as likely. However, when the drunk man encounters the 5th position, he must return to the 4th, and when the drunk man encounters the 1st position, he can either go left or right. If he chooses to go right, the drunk man falls off, and the game ends.
The question is now:
- How far on average will the walker walk?
- What is the probability of the walker returning home after moving K positions.
I'll try to solve the latter question, since I believe it's easier for me. First of all, we have to form our transition matrix T.
$$ T = \begin{pmatrix} 1 & 0 & 0 & 0 & 0 & 0 \\ 1/2 & 0 & 1/2 & 0& 0 & 0 \\ 0 & 1/2 & 0 & 1/2 & 0 & 0 \\ 0 & 0 & 1/2 & 0 & 1/2 & 0 \\ 0 & 0 & 0 & 1/2 & 0 & 1/2 \\ 0 & 0 & 0 & 0 & 1 & 0 \\ \end{pmatrix} $$
Where the rows are indexed as E,1,2,...,5 where E stands for "end", and thus the random walk terminates if the drunk man falls into this position.
To answer what the probability for the walker to arrive at home after K positions, we can note one obivous fact
- If the K moves are odd, the probability of returning home is $0$.
We might need to use this later to check whether our answer is reasonable.
More generally, we can write the probability of returning home after $K$ positions, which we can denote as the event $H_K$, as:
$$ P(H_K) = \begin{pmatrix} 0& 0 & 0 & 1 & 0 & 0 \end{pmatrix} T^k \cdot \begin{pmatrix} 0& 0 & 0 & 1 & 0 & 0 \end{pmatrix} $$
However, I don't really know if there's any way to create a closed form expression for this probability given this. It's not really that easy to calculate $T^k$ for some general $k$ too.
I tried to plot the probabilities of the positions after 30 steps in Python, and got this graph:
Notice, position $1$ is what I previously labeled as position $E$. Position $2$ in the graph represents position $1$ in my previous definition, and so forth. I also tried to plot the probabilities after 100 steps, and it really looks some exponential decay regarding the probabilites for positions. So I assume there might be some easy expression to derive from this.
For the question regarding how far the walker will get on average, I've really no idea how to start. I'm thinking that I want to find the expected value of arriving at position $E$ given that our starting position is $3$. However, I don't really know how to express this in terms of our transition matrix $T$. I'd be glad if anyone could share their ideas for this problem.
Thanks in advance.