Randomized Steps on a Grid

Whenever Richard takes a step, he chooses one of the four cardinal directions at random and moves one unit in that direction. For a certain number of steps n , n, the probability of Richard starting at the origin and ending at the point ( 4 , 4 ) (4,4) is maximized.

What is n ? n?

Note: If you decide to use a more brute force solution to this problem, it is highly recommended and encouraged that you use a calculator and/or a bit of programming.


The answer is 32.

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.

9 solutions

Patrick Corn
Oct 16, 2018

The probability of reaching ( 4 , 4 ) (4,4) is the coefficient of x 4 y 4 x^4y^4 in the expansion of f n ( x , y ) = ( 1 4 x + 1 4 x 1 + 1 4 y + 1 4 y 1 ) n . f_n(x,y) = \left( \frac14 x + \frac14 x^{-1} + \frac14 y + \frac14 y^{-1} \right)^n. Well, f n ( x , y ) = ( 1 4 ) n ( x y ) n ( x 2 y + y + x y 2 + x ) n = ( 1 4 ) n ( x y ) n ( x + y ) n ( x y + 1 ) n . \begin{aligned} f_n(x,y) &= \left( \frac14 \right)^n (xy)^{-n} (x^2y + y + xy^2 + x)^n \\ &= \left( \frac14 \right)^n (xy)^{-n} (x+y)^n (xy+1)^n. \end{aligned} The coefficient of x 4 y 4 x^4y^4 in f n ( x , y ) f_n(x,y) is the coefficient of x n + 4 y n + 4 x^{n+4}y^{n+4} in ( 1 4 ) n ( x + y ) n ( x y + 1 ) n . \left( \frac14 \right)^n (x+y)^n (xy+1)^n. Looking at degrees of terms makes it clear that the only way to get x n + 4 y n + 4 x^{n+4}y^{n+4} is by getting x n / 2 y n / 2 x^{n/2} y^{n/2} in the first part and ( x y ) n / 2 + 4 (xy)^{n/2+4} in the second part. (It makes sense that n n has to be even; otherwise it's easy to see from the polynomial or from thinking about the problem that the probability will be 0.)

So the conclusion is: let n = 2 k . n=2k. Then the probability of getting to ( 4 , 4 ) (4,4) in n n steps is exactly p k = ( 1 4 ) 2 k ( 2 k k ) ( 2 k k + 4 ) . p_k = \left( \frac14 \right)^{2k} \binom{2k}{k} \binom{2k}{k+4}.

Consider p k / p k + 1 . p_k/p_{k+1}. The claim is that for k 15 k \le 15 this is less than 1, and for k 16 k \ge 16 it's greater than 1, which would mean that p k p_k is maximized when k = 16. k=16. Let's write it down: p k p k + 1 = 16 ( 2 k k ) ( 2 k k + 4 ) ( 2 k + 2 k + 1 ) ( 2 k + 2 k + 5 ) = 16 ( k + 1 ) ( k + 1 ) ( k + 5 ) ( k 3 ) ( 2 k + 2 ) ( 2 k + 1 ) ( 2 k + 2 ) ( 2 k + 1 ) = 4 ( k + 5 ) ( k 3 ) ( 2 k + 1 ) 2 = 4 k 2 + 8 k 60 4 k 2 + 4 k + 1 = 1 + 4 k 61 4 k 2 + 4 k + 1 , \begin{aligned} \frac{p_k}{p_{k+1}} &= 16 \frac{\binom{2k}{k} \binom{2k}{k+4}}{\binom{2k+2}{k+1} \binom{2k+2}{k+5}} \\ &= 16 \frac{(k+1)(k+1)(k+5)(k-3)}{(2k+2)(2k+1)(2k+2)(2k+1)} \\ &= 4 \frac{(k+5)(k-3)}{(2k+1)^2} \\ &= \frac{4k^2+8k-60}{4k^2+4k+1} \\ &= 1 + \frac{4k-61}{4k^2+4k+1}, \end{aligned} which is greater than 1 1 for k 16 k \ge 16 and less than 1 1 for k 15 k \le 15 . So the claim is proved, and p k p_k is maximized when k = 16 , k=16, or n = 32 . n=\fbox{32}.

Edit: For any point ( a , b ) , (a,b), here is a partial proof that the probability of reaching ( a , b ) (a,b) in n n steps is maximized when n = a 2 + b 2 . n=a^2+b^2.

First note that the parity of a 2 + b 2 a^2+b^2 is correct: if a a and b b are both even or both odd, it takes an even number of steps to reach ( a , b ) , (a,b), and a 2 + b 2 a^2+b^2 is even. Otherwise, it takes an odd number of steps to reach ( a , b ) (a,b) and a 2 + b 2 a^2+b^2 is odd.

Now the same argument as above gives a value of p n , p_n, the probability of reaching ( a , b ) (a,b) in n n steps, as p n = ( 1 4 ) n ( n n a + b 2 ) ( n n + a + b 2 ) , p_n = \left( \frac14 \right)^n \binom{n}{\frac{n-a+b}2} \binom{n}{\frac{n+a+b}2}, and, similar to the above, we get p n p n + 2 = ( n + 2 + a + b ) ( n + 2 + a b ) ( n + 2 a + b ) ( n + 2 a b ) ( n + 2 ) 2 ( n + 1 ) 2 . \frac{p_n}{p_{n+2}} = \frac{(n+2+a+b)(n+2+a-b)(n+2-a+b)(n+2-a-b)}{(n+2)^2(n+1)^2}. Let r n r_n be the top and s n s_n be the bottom. Then I get r a 2 + b 2 s a 2 + b 2 = 4 a 4 + 4 a 2 b 2 + 12 a 2 + 4 b 4 + 12 b 2 + 12 > 0 r a 2 + b 2 2 s a 2 + b 2 2 = 4 a 2 b 2 0. \begin{aligned} r_{a^2+b^2} - s_{a^2+b^2} &= 4a^4 + 4a^2b^2 + 12a^2 + 4b^4 + 12b^2 + 12 > 0 \\ r_{a^2+b^2-2} - s_{a^2+b^2-2} &= -4a^2b^2 \le 0. \end{aligned} This at least shows that p a 2 + b 2 2 p a 2 + b 2 > p a 2 + b 2 + 2 . p_{a^2+b^2-2} \le p_{a^2+b^2} > p_{a^2+b^2+2}. But it is not quite so clear that this "local maximum" is a "global maximum" in general. The numerator of p n p n + 2 1 \frac{p_n}{p_{n+2}}-1 is a cubic, so it might have some other critical points...

How did you find that expression in the bracket? i.e the expression of F(x,y)

thermo dynamics - 2 years, 7 months ago

Log in to reply

These kinds of problem are often solved most easily by generating functions. Here there are two variables--the "left-right" variable is x x and the "up-down" variable is y . y. Going right corresponds to multiplying by x , x, going left corresponds to multiplying by x 1 , x^{-1}, going up corresponds to multiplying by y , y, and going down corresponds to multiplying by y 1 . y^{-1}. Each of those things has a probability of 1 / 4 , 1/4, and we take n n steps, so that's where that expression comes from.

Patrick Corn - 2 years, 7 months ago
Laszlo Mihaly
Oct 9, 2018

Let us ask a simpler question: What if the expected value of d d , the distance to the origin, after n n steps are made. The answer is straightforward, one of the principal property of random walks, d = n d=\sqrt{n} . Using d 2 = 4 2 + 4 2 = 32 d^2=4^2+4^2=32 we get n = 32 n=32 .

This happens to be the solution to the current problem. Is that a coincidence or is it always true?

I believe I can prove that for any point ( a , b ) , (a,b), the solution is always n = a 2 + b 2 . n=a^2+b^2. I edited my solution to reflect this generalization.

Patrick Corn - 2 years, 7 months ago

Log in to reply

Thanks, this is very interesting.

Laszlo Mihaly - 2 years, 7 months ago

Log in to reply

Well, I have to walk back my statement a bit. I haven't finished the proof (and I'm not totally sure it's true). In particular, it's not hard to see that for points on the x x - or y y -axis, the probability of reaching the point in a 2 + b 2 a^2+b^2 steps is equal to the probability of reaching it in a 2 + b 2 2 a^2+b^2-2 steps. So there's already a slight subtlety there.

Patrick Corn - 2 years, 7 months ago

Very much interested in your proof!

Your result seems to be correct, except on the main axes at distance>1 from the origin (where we have to subtract 2). I made a small program that outputted this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
  0    1    2    7   14   23   34   47   62   79   98   119  142  167  194  223   ? 

  1    2    5   10   17   26   37   50   65   82   101  122  145  170  197  226   ? 

  2    5    8   13   20   29   40   53   68   85   104  125  148  173  200  229   ? 

  7   10   13   18   25   34   45   58   73   90   109  130  153  178  205  234   ? 

 14   17   20   25   32   41   52   65   80   97   116  137  160  185  212  241   ? 

 23   26   29   34   41   50   61   74   89   106  125  146  169  194  221   ?    ? 

 34   37   40   45   52   61   72   85   100  117  136  157  180  205  232   ?    ? 

 47   50   53   58   65   74   85   98   113  130  149  170  193  218  245   ?    ? 

 62   65   68   73   80   89   100  113  128  145  164  185  208  233   ?    ?    ? 

 79   82   85   90   97   106  117  130  145  162  181  202  225   ?    ?    ?    ? 

 98   101  104  109  116  125  136  149  164  181  200  221  244   ?    ?    ?    ? 

 119  122  125  130  137  146  157  170  185  202  221  242   ?    ?    ?    ?    ? 

 142  145  148  153  160  169  180  193  208  225  244   ?    ?    ?    ?    ?    ? 

 167  170  173  178  185  194  205  218  233   ?    ?    ?    ?    ?    ?    ?    ? 

 194  197  200  205  212  221  232  245   ?    ?    ?    ?    ?    ?    ?    ?    ? 

 223  226  229  234  241   ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ? 

  ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ?    ? 

K T - 10 months ago

I think you have it. I reasoned exactly as you have.
Whether it is "always true" here at Brilliant is another question, best left to the admin folks to answer.. :-)

Bert Seegmiller - 2 years, 7 months ago
Mark Hennings
Oct 16, 2018

To reach ( 4 , 4 ) (4,4) from ( 0 , 0 ) (0,0) , we need to take a + 2 a+2 steps to the right, a 2 a-2 steps to the left, b + 2 b+2 steps up, and b 2 b-2 steps down, for some integers a , b 2 a,b \ge 2 , which means that we have achieved our goal after a total of 2 ( a + b ) 2(a+b) steps. Thus the probability of reaching ( 4 , 4 ) (4,4) from ( 0 , 0 ) (0,0) after 2 n 2n steps is equal to p n = 1 4 2 n a = 2 n 2 ( 2 n ) ! ( a 2 ) ! ( a + 2 ) ! ( n a 2 ) ! ( n a + 2 ) ! = 1 4 2 n × 2 4 n Γ ( n + 1 2 ) 2 π ( n 4 ) ! ( n + 4 ) ! p_n \; = \; \frac{1}{4^{2n}}\sum_{a=2}^{n-2} \frac{(2n)!}{(a-2)!(a+2)!(n-a-2)!(n-a+2)!} \; = \; \frac{1}{4^{2n}} \times \frac{2^{4n} \Gamma(n+\frac12)^2}{\pi (n-4)!(n+4)!} After simplification, this is equal to p n = ( ( 2 n ) ! ) 2 4 2 n ( n ! ) 2 ( n 4 ) ! ( n + 4 ) ! n 4 p_n \; = \; \frac{\big((2n)!\big)^2}{4^{2n}(n!)^2(n-4)!(n+4)!} \hspace{2cm} n \ge 4 Thus we deduce that p n + 1 p n = ( 2 n + 2 ) 2 ( 2 n + 1 ) 2 16 ( n + 1 ) 2 ( n 3 ) ( n + 5 ) = ( 2 n + 1 ) 2 4 ( n 3 ) ( n + 5 ) \frac{p_{n+1}}{p_n} \; = \; \frac{(2n+2)^2(2n+1)^2}{16(n+1)^2(n-3)(n+5)} \; = \; \frac{(2n+1)^2}{4(n-3)(n+5)} and this implies that p n p n + 1 p_n \le p_{n+1} provided that 4 n 61 4n \le 61 . Hence we deduce that the largest value of p n p_n is p 16 p_{16} .

It is not possible to reach ( 4 , 4 ) (4,4) from ( 0 , 0 ) (0,0) after an odd number of steps, and hence the number N N of steps that maximizes the probability of getting from ( 0 , 0 ) (0,0) to ( 4 , 4 ) (4,4) in N N steps is N = 2 × 16 = 32 N = 2\times16 = \boxed{32} .

I found a similar expression to the one you found with the sum. How did you find the closed form of that?

Nate Jellis - 2 years, 7 months ago

Log in to reply

Ultimately, it is Patrick’s argument that proves the identity.

Mark Hennings - 2 years, 7 months ago

Log in to reply

jo persistently

Gil Wuttke - 2 years, 7 months ago

Terrific solution! Thanks!

G Silb - 2 years, 7 months ago
Bufang Liang
Oct 9, 2018

Here is a counting approach to this problem (that will require the assistance of a calculator to realistically solve):

Let's create a bijection. If we write out the steps of that path Richard takes, the number of ways to reach ( 4 , 4 ) (4,4) is the number of sequences of these steps. For example, N N N E W E E N E N S E NNNEWEENENSE is one possible path, where each letter represents a cardinal direction (north, south, east, west).

In order to reach ( 4 , 4 ) (4,4) , we need a minimum of 8 8 steps total. We also note that if we have an odd number of steps, we cannot possibly reach our destination. Let s s be the number of pairs of steps more than the minimum needed to reach ( 4 , 4 ) (4,4) . In other words, s = 1 2 ( n 8 ) s = \frac{1}{2}(n-8) . Let k k be the number of pairs of steps assigned to just the north and south directions. This makes s k s-k represent the number of pairs of steps assigned to the east and west directions.

First, we find the number of ways to divide up the positions of the north/south letters versus the east/west letters, which is ( 8 + 2 s 4 + 2 k ) \binom{8+2s}{4+2k} . Then we calculate the number of ways to select which letters are north/south, which is ( 4 + 2 k k ) \binom{4+2k}{k} , and the number of ways to select which letters are east/west, which is ( 4 + 2 ( s k ) s k ) \binom{4+2(s-k)}{s-k} , and multiply all of these values together. If we sum this expression for values of k k from 0 0 to s s , we will be able to find the total number of ways to reach the point.

Let P ( s ) P(s) be the number of ways to reach ( 4 , 4 ) (4,4) for a given s s . We now have that P ( s ) = k = 0 s ( 8 + 2 s 4 + 2 k ) ( 4 + 2 k k ) ( 4 + 2 ( s k ) s k ) P(s) = \sum\limits_{k=0}^{s} \binom{8+2s}{4+2k} \binom{4+2k}{k} \binom{4+2(s-k)}{s-k} Since each pair adds 2 2 steps, each pair multiplies the total number of paths Richard can take by 4 2 = 16 4^2 = 16 . To find where the probability is maximized, we find where the probability begins to first decrease. This occurs at the first non-negative integer s s such that P ( s + 1 ) P ( s ) < 16 \frac{P(s+1)}{P(s)} < 16 . We notice that P ( 13 ) P ( 12 ) = 2165548674394987200 135719648326407600 < 16 \frac{P(13)}{P(12)}=\frac{2165548674394987200}{135719648326407600} < 16 so the probability is maximized where n = 8 + 2 12 = 32 n = 8+2\cdot{12} = \boxed{32} .

Additional comments: The particularly high numbers are a result of choosing a destination point that would make the answer difficult to simply guess. However, using recursion or some other more advanced techniques and identities, solving this problem is equivalent to finding the first non-negative s s such that: ( 9 + 2 s ) 2 4 ( 1 + s ) ( 9 + s ) < 1 \frac{ (9 + 2 s)^2} {4(1 + s) (9 + s)} < 1 Can you figure out how to obtain this condition?

As we have to go from ( 0 , 0 ) (0,0) to ( 4 , 4 ) . (4,4). Lets make a square with side 8 so we a giant square made of 8 × 8 = 64 8\times 8=64 small squares of unit length. We can make use of half the small squares i.e, 32 to move from origin to ( 4 , 4 ) . (4,4).

I came up with this.To move from ( 0 , 0 ) (0,0) to ( r , r ) (r, r) make a square of side 2r with (0,0) as center and symmetric about the coordinate axes, thus giving you total number i.e, 4 r 2 4r^{2} small squares of unit length and using half of them i.e, 2 r 2 2r^{2} will give you maximum probability to reach the point ( r , r ) , (r, r),

So according to this Question, r = 4 r=4

Maximum Steps = 2 r 2 = 2 × 4 2 = 2 × 16 = 32. =2r^{2}=2\times4^{2}=2\times16=32.

Therefore N = 32 N=\boxed{32 }

How did u learn all of this? You did a nice job

Royal Sync - 2 years, 7 months ago
Vinod Kumar
Oct 23, 2018

You go forward 1 step (statistically) after taking four equally probable random steps in any one of the four cardinal directions. Therefore, you need 8×4=32 random walks to travel 8 steps to reach any one of the four points {(4,4), (-4,4), (-4,-4), ( 4,-4)} starting from origin at (0,0).

Answer=32

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#returns position after n steps
def pos(n)
  x=0
  y=0
  n.times do
    case rand(4)
    when 0
      x+=1
    when 1
      x-=1
    when 2
      y+=1
    when 3
      y-=1
    end
  end
  return [x,y]
end


def prob(n,n_of_case)
  count=0
  n_of_case.times do
    #gets a randomly generated position
    c=pos(n)
    # because [-4,-4],[4,-4],[-4,4],[4,4] are symmetrical, it's better to count cases that matches one of them
    count+=1 if [[-4,-4],[4,-4],[-4,4],[4,4]].include?(c)
  end
    # we don't need to divide by 4 cause we don't need exact probabilities
  return count.to_f/n_of_case
end

#I tested with fewer cases and found that probability is maxed at around 30
#so I tested from n=26 to n=34(with step size 2 for obvious reason) with more cases
26.step(34,2) do |n|
  puts n
  puts prob(n,5000000)
end

Bert Seegmiller
Oct 25, 2018

Since we're talking of random walks, the reference I learned when I was 12 mentioned that distance d = s t e p s d = \sqrt{steps} .

The location ( 4 , 4 ) (4,4) is 4 2 + 4 2 \sqrt{4^2+4^2} or 4 × 2 4\times\sqrt{2} steps from the start. Squaring that is 32 32 .

N.b. : I'm not sure how programming or a calculator will help, since that reference is in my dad's bookshelf, next to the Table of Areas and Volumes of Items Used in Physics and Math Problems (Engineering Edition) . The table for Red Rubber Balls has been somewhat famously referenced elsewhere in cyberspace.

Ed Sirett
Oct 24, 2018

Another one I guesstimated right. It is known that the expected distance of a random walk is n \sqrt n . In this problem we have two independent random walks one East-West and one North-West. So to maximize the chance of being +4 on each axis then 16 steps are needed for each and so 32 \boxed{32} for the total.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...