-1

Suppose we have a random walker on the 2D integer lattice $\mathbb{Z}^2$ starting at the origin (0,0), it can move in any direction (up, down, left, right) with equal probability (1/4).

What's the probability that it passes through the point (x, y) at least once in N steps.

I've tried multiple approaches, but didn't get far, this is a problem I stumbled upon while working on another, larger issue, and I'm not that well versed in random walks, I'm still looking for learning material.

In the meantime I wrote a small piece of python code that simulates the problem:

import random

def random_walk(n, a, b): x = 0 y = 0

for i in range(n):
    dx, dy = random.choice([(1,0), (-1,0), (0,1), (0,-1)])
    x += dx
    y += dy
    if x == a and y == b:
        return True # It reached the point (a, b)

return False # It never reached the point (a, b)


count = 0 for i in range(100000): if random_walk(7, 3, 4): count += 1

print("Percentage of times the random walk passes through (3, 4) with 7 steps: {:.2f}%".format(100 * count / 100000)) # About 0.2%

  • 1
    Welcome to [math.se] SE. Take a [tour]. You'll find that simple "Here's the statement of my question, solve it for me" posts will be poorly received. What is better is for you to add context (with an [edit]): What you understand about the problem, what you've tried so far, etc.; something both to show you are part of the learning experience and to help us guide you to the appropriate help. You can consult this link for further guidance. – Christian E. Ramirez Feb 13 '23 at 02:02

1 Answers1

0

Let $P_n(x,y)$ be the probability that, when you start at $(0,0)$ and take $n$ steps, you end up at $(x,y)$. It turns out this is easy to calculate: $$ P_n(x,y)= \begin{cases} \binom{n}{(n+x+y)/2}\binom{n}{(n+x-y)/2}4^{-n} & \text{if $n+x+y$ is even} \\ 0 & \text{otherwise} \end{cases} $$ Now, let $Q_n(x,y)$ be the probability that, when you start at $(0,0)$ and take $n$ steps, the $n^\text{th}$ step takes you to $(x,y)$ for the first time. You can prove that $$ P_n(x,y)=\sum_{k=0}^n Q_k(x,y)P_{n-k}(0,0) $$ This is because any path from $(0,0)$ to $(x,y)$ can be uniquely decomposed into an initial portion which reaches $(x,y)$ for the first time after $k$ steps, followed by a path from $(x,y)$ to $(x,y)$ for the remaining $n-k$ steps.

Rewriting this as $$ Q_n(x,y)=P_n(x,y)-\sum_{k=0}^{n-1}Q_k(x,y)P_{n-k}(0,0), $$ we now have a recursive equation to compute $Q_n(x,y)$ in terms of itself. Using dynamic programming, this leads to an $O(n^2)$ algorithm to compute the entire following list: $$[Q_1(x,y),Q_2(x,y),\dots,Q_n(x,y)].$$

Finally, you want to find the probability that you visit $(x,y)$ at any point during your $n$-step journey. This is simply the sum of the above list.

Mike Earnest
  • 75,930