Just Don't Drink In 3-Dimensional Space

A drunkard walks out of a bar at midnight. He is in 3-dimensional space of an infinite size. The probability of his stepping 1 step forward , backward , left , right , up or down is equal. Calculate the probability (to two decimal places) of his (eventually) returning to the bar.

Details and Assumptions:

  • Assume the bar is a point particle at the origin.

  • We require the probability that he will, at any point in time, return to the bar.

  • Do not try this at home.


The answer is 0.34.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Akash Gaonkar
Jun 21, 2015

Python Code:

 import random;

def test(max_steps, n_times=100):
    count = 0
    for i in range(n_times):
        if run(max_steps): count += 1
        print(count/(i+1), "("+str(i+1)+")")
    print("-----")
    print(count/n_times)

def run(max_steps):
    state = [0,0,0]
    for i in range(max_steps):
        move(state)
        if state[0] == 0 and state[1] == 0 and state[2] == 0:
            return True
    return False

def move(state):
    pos = random.randrange(len(state))
    step = random.randint(0, 1) * 2 - 1
    state[pos] += step
    return state

test(50000, 10000)

Wait a while. Run it a few times. You usually get between 0.33 or 0.34.

Is there a way to do this without a computer?

Minjae Son - 5 years, 11 months ago

Log in to reply

I tried, but did not get very far. You need to define variables very carefully to get to a solveable state.

Akash Gaonkar - 5 years, 11 months ago

Yes, look up Polya's random walk constants for more information. The value is 0.3405373296...

Bhavik Mehta - 5 years, 11 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...