3

Suppose we're given some absorbing boundary that encloses the origin/starting position, and we take a simple random walk (up/down/left/right with equal probability). For simplicity's sake say we have access to a function which tells us for (x,y) whether it's crossed the barrier

I know simulating this is straightforward, and calculating the expected time until hitting is pretty easy to numerically approximate - but is there a neat algorithmic way to get the exact answer?

I've tried to get something working with DP/DFS but the lack of base-case in the recursion seems to be stumping me. Not sure if there's a way to do this besides simulation/maybe some more in-depth math

addawaddawoo
  • 47
  • 1
  • 5
  • 1
    This is more of a math problem, I think. – user1984 Nov 04 '21 at 09:08
  • Try here https://math.stackexchange.com/ – c0der Nov 04 '21 at 10:54
  • Is the boundary symmetric around the starting point? I.e. can the boundary be expressed as |x| + |y| = B? – Dave Nov 04 '21 at 11:52
  • There are many well known results for random walks (1d and nd) that can be found by looking in the right place (i.e. mathematical resources.) Highly recommend asking the math stack exchange, as there is a closed form answer to your question. – ldog Nov 04 '21 at 19:34

1 Answers1

2

Number the states inside the barrier, form the matrix A of transition probabilities (A[i,j] is the probability of going from state j to state i), solve the matrix equation A x + 1 = x for x (where 1 is the all-ones vector, equivalent to (AI) x = 1 where I is the identity matrix). The element x[i] gives the expected time to absorption starting at i.

David Eisenstat
  • 64,237
  • 7
  • 60
  • 120