The ant & the wheat

The ant, located on a vertex of a cube, wishes to reach the wheat at the opposite vertex of the cube. The ant selects an adjacent edge uniformly at random before moving along it. The ant continues moving in this manner, but it will never travel to a vertex it just arrived from.

What is the expected value of the number of moves for the ant to reach its destination?


The answer is 6.

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.

6 solutions

Mark Hennings
Aug 21, 2017

Relevant wiki: Linearity of Expectation

Label the ant's starting vertex with 0 0 . Label the three vertices adjacent to the starting vertex with 1 1 . Label the three vertices that are adjacent to the vertex with the wheat with 2. 2. The vertex with the wheat on it needs no label.

Let E i j E_{ij} be the expected number of edges that the ant has to walk to reach the wheat, given that it is currently at a type j j vertex, having reached that vertex from a type i i vertex. Then E 01 = 1 + E 12 E 12 = 1 + 1 2 E 21 E 21 = 1 + 1 2 E 10 + 1 2 E 12 E 10 = 1 + E 01 \begin{aligned} E_{01} & = \; 1 + E_{12} \\ E_{12} & = \; 1 + \tfrac12E_{21} \\ E_{21} & = \; 1 + \tfrac12E_{10} + \tfrac12E_{12} \\ E_{10} & = \; 1 + E_{01} \end{aligned} which we can solve to obtain E 01 = 5 E_{01} = 5 , E 12 = 4 E_{12} = 4 , E 21 = 6 E_{21} = 6 , E 10 = 6 E_{10} = 6 . The expected number of edges that the ant has to walk is therefore 1 + E 01 = 6 . 1 + E_{01} = \boxed{6}.

My solution is the same. To solve the system of equations, I wrote them as [ 1 1 0 0 0 1 1 2 0 0 1 2 1 1 2 1 0 0 1 ] [ E 01 E 12 E 21 E 10 ] = [ 1 1 1 1 ] , \left[\begin{array}{cccc} 1 & -1 & 0 & 0 \\ 0 & 1 & -\tfrac12 & 0 \\ 0 & -\tfrac12 & 1 & -\tfrac12 \\ -1 & 0 & 0 & 1 \end{array}\right]\ \left[\begin{array}{c} E_{01} \\ E_{12} \\ E_{21} \\ E_{10} \end{array}\right] = \left[\begin{array}{c} 1 \\ 1 \\ 1 \\ 1\end{array}\right], and inversion gives [ E 01 E 12 E 21 E 10 ] = [ 1 1 2 2 1 1 2 1 2 2 1 1 2 1 2 2 1 1 1 2 2 1 1 1 2 ] [ 1 1 1 1 ] = [ 5 4 6 6 ] . \left[\begin{array}{c} E_{01} \\ E_{12} \\ E_{21} \\ E_{10} \end{array}\right] = \left[\begin{array}{cccc} 1\tfrac12 & 2 & 1 & \tfrac12 \\ \tfrac12 & 2 & 1 & \tfrac12 \\ 1 & 2 & 2 & 1 \\ 1\tfrac12 & 2 & 1 & 1\tfrac12 \end{array}\right]\ \left[\begin{array}{c} 1 \\ 1 \\ 1 \\ 1\end{array}\right] = \left[\begin{array}{c} \boxed{5} \\ 4 \\ 6 \\ 6\end{array}\right]. This is the expected number of steps it takes from each of the four types of situations.

After the first move the ant will be in situation 01 01 , for which the expected number of steps is 5 (see box in last vector); therefore the answer is 5 + 1 = 6 5 + 1 = \boxed{6} .

Arjen Vreugdenhil - 3 years, 9 months ago

Log in to reply

Well yes, but these equations are elementary to solve by hand, and the effort in inverting a 4 × 4 4\times4 matrix is considerable.

Mark Hennings - 3 years, 9 months ago

Log in to reply

The effort involved in using Matlab to invert a 4-by-4 matrix (or to solve the system) is even less than the effort of solving any 4-equation system by hand.

Richard Desper - 3 years, 9 months ago

Log in to reply

@Richard Desper You are confirming my point. A computer algebra system would not solve this problem by inverting a 4 × 4 4\times4 matrix. Gaussian elimination is much faster.

Mark Hennings - 3 years, 9 months ago

Log in to reply

@Mark Hennings Inverting a matrix is almost identical to Gaussian elimination. You'd just add a few more columns...

Of course, @Mark Hennings is right about the amount of work. Inverting the matrix is useful if each type of move is assigned a variable "cost", and we need to calculate the expected cost. Then we only need to alter the vector [ 1 1 1 1 ] [1\ 1\ 1\ 1] to generate the answer.

Arjen Vreugdenhil - 3 years, 9 months ago

Log in to reply

@Arjen Vreugdenhil Inverting a (large) matrix is much more than Gaussian elimination! To solve an n × n n\times n set of simultaneous equations by Gaussian elimination takes O ( n 3 ) O(n^3) operations. To calculate the determinant of an n × n n\times n matrix takes O ( n ! ) O(n!) operations, which is much more!

Mark Hennings - 3 years, 9 months ago

Log in to reply

@Mark Hennings I inverted the matrix by Gaussian operations, without needing the determinant. The complexity is O ( n 3 ) O(n^3) :

[ 1 1 0 0 1 0 0 0 0 1 1 2 0 0 1 0 0 0 1 2 1 1 2 0 0 1 0 1 0 0 1 0 0 0 1 ] [ 1 1 0 0 1 0 0 0 0 1 1 2 0 0 1 0 0 0 1 2 1 1 2 0 0 1 0 0 1 0 1 1 0 0 1 ] [ 1 1 0 0 1 0 0 0 0 1 1 2 0 0 1 0 0 0 0 3 4 1 2 0 1 2 1 0 0 0 1 2 1 1 1 0 1 ] [ 1 1 0 0 1 0 0 0 0 1 1 2 0 0 1 0 0 0 0 1 2 3 0 2 3 1 1 3 0 0 0 0 2 3 1 1 1 3 2 3 1 ] [ 1 1 0 0 1 0 0 0 0 1 1 2 0 0 2 0 0 0 0 1 0 1 2 2 1 0 0 0 1 1 1 2 2 1 1 1 2 ] [ 1 1 0 0 1 0 0 0 0 1 0 0 1 2 2 1 1 2 0 0 1 0 1 2 2 1 0 0 0 1 1 1 2 2 1 1 1 2 ] [ 1 0 0 0 1 1 2 2 1 1 2 0 1 0 0 1 2 2 1 1 2 0 0 1 0 1 2 2 1 0 0 0 1 1 1 2 2 1 1 1 2 ] . \left[\begin{array}{cccc|cccc} 1 & -1 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 1 & -\tfrac12 & 0 & 0 & 1 & 0 & 0 \\ 0 & -\tfrac12 & -1 & -\tfrac12 & 0 & 0 & 1 & 0 \\ -1 & 0 & 0 & 1 & 0 & 0 & 0 & 1 \end{array}\right] \sim \left[\begin{array}{cccc|cccc} 1 & -1 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 1 & -\tfrac12 & 0 & 0 & 1 & 0 & 0 \\ 0 & -\tfrac12 & -1 & -\tfrac12 & 0 & 0 & 1 & 0 \\ 0 & -1 & 0 & 1 & 1 & 0 & 0 & 1 \end{array}\right] \\ \sim \left[\begin{array}{cccc|cccc} 1 & -1 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 1 & -\tfrac12 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & \tfrac34 & -\tfrac12 & 0 & \tfrac12 & 1 & 0 \\ 0 & 0 & -\tfrac12 & 1 & 1 & 1 & 0 & 1 \end{array}\right] \sim \left[\begin{array}{cccc|cccc} 1 & -1 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 1 & -\tfrac12 & 0 & 0 & 1 & 0 & 0 \\ 0 & 0 & 1 & -\tfrac23 & 0 & \tfrac23 & 1\tfrac13 & 0 \\ 0 & 0 & 0 & \tfrac23 & 1 & 1\tfrac13 & \tfrac23 & 1 \end{array}\right] \\ \sim \left[\begin{array}{cccc|cccc} 1 & -1 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 1 & -\tfrac12 & 0 & 0 & 2 & 0 & 0 \\ 0 & 0 & 1 & 0 & 1 & 2 & 2 & 1 \\ 0 & 0 & 0 & 1 & 1\tfrac12 & 2 & 1 & 1\tfrac12 \end{array}\right] \sim \left[\begin{array}{cccc|cccc} 1 & -1 & 0 & 0 & 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & \tfrac12 & 2 & 1 & \tfrac12 \\ 0 & 0 & 1 & 0 & 1 & 2 & 2 & 1 \\ 0 & 0 & 0 & 1 & 1\tfrac12 & 2 & 1 & 1\tfrac12 \end{array}\right] \\ \sim \left[\begin{array}{cccc|cccc} 1 & 0 & 0 & 0 & 1\tfrac12 & 2 & 1 & \tfrac12 \\ 0 & 1 & 0 & 0 & \tfrac12 & 2 & 1 & \tfrac12 \\ 0 & 0 & 1 & 0 & 1 & 2 & 2 & 1 \\ 0 & 0 & 0 & 1 & 1\tfrac12 & 2 & 1 & 1\tfrac12 \end{array}\right].

Of course, to answer the problem it is more efficient to place the desired variable E 01 E_{01} in the bottom row/last column. That way, we only need to swipe down the matrix and skip the back substitution.

Arjen Vreugdenhil - 3 years, 9 months ago

Log in to reply

@Arjen Vreugdenhil So now you guys have me looking up the relative speed of matrix inversion versus using a linear solver. It's not quite as cut-and-dry as one might think. As Arjen notes, you don't have to solve for the determinant to invert a matrix. Indeed, one can use the linsol approach to invert a matrix (and that's how we were taught to invert matrices in undergrad linear algebra back in the day). But using a linsol approach to invert a matrix rather than simply using it to solve the system directly is clearly going to be sub-optimal. (A "few more columns" will become "many more columns" as the size of the problem increases.)
There's an interesting discussion of this issue at https://mathoverflow.net/questions/225560/complexity-of-linear-solvers-vs-matrix-inversion

Take-home points: inverting a matrix may be faster than people generally understand it to be. But using a linear solver is certainly faster for a situation like this where target is a 1-dimensional vector (as opposed to a matrix with several columns).

Richard Desper - 3 years, 9 months ago

@Mark Hennings FWIW, I''m not really confirming your point. Matlab will solve this problem by inverting a 4x4 matrix if I tell it to do that. :) My point wasn't about the relative speed of various algorithms. It was about the total speed of algorithm + human user. Using linsol(M,v) is about three times faster than inv(M)*v for this problem but we're talking about the difference between .00003 and .00009 seconds here. The computational time is dwarfed by the time required to input the commands (not to mention inputting the data!)
I do take your larger point that linsol is clearly faster for larger systems of linear equations.

Richard Desper - 3 years, 9 months ago

I can't figure out a path the ant can take that requires an even number of moves to reach the wheat, every path that I can walk the ant down to the wheat with requires an odd amount of choices, usually 5 or 7 but certainly never 6.

Alex Eyman - 3 years, 9 months ago

Log in to reply

That is correct. However, the expectation value of the number of paths is defined as a (weighed) average of the possible values. The average of 5, 7, and some other odd values may be even.

(By the way, the most likely outcome is 3 moves, with probability 1 2 \tfrac12 . Further down the page you can find my analysis of the probability distribution, including a histogram.)

Arjen Vreugdenhil - 3 years, 9 months ago

Log in to reply

Please forgive me for my ignorance, I have never taken a statistics course (probably shouldn't be doing this then but oh well)

So the question asks for the expected value of moves required, expected meaning to me MOST PROBABLE, if it is severely unlikely to require an even number of moves (much less specifically 6) then why would that be an expected value? Although I do understand the concept of taking the average of most likely solutions but if in taking the average you derive an impossible solution then doesn't that solution contradict the concept of an "expected" outcome?

Please don't misunderstand my question for aggression, it really isn't, I am just trying to understand where my flawed logic is so I can do better going forward. :)

Alex Eyman - 3 years, 9 months ago

Log in to reply

@Alex Eyman I am happy to explain the mathematical jargon :). The "most probable" value is called modus in statistics. In this case, the modus of the distribution is 3.

As others have pointed out, the "expected" size of a US family is 2.6 children, yet no one ever has 2.6 children. The expected outcome of rolling a die is 3.5, even though you cannot actually roll that number. The expected number of spades in a bridge hand of 13 cards is 3.25, even though the actual value is always an integer. That's how it works...

The formal definition of expected value is E X = all outcomes x P ( X = x ) x ; \mathbb E X = \sum_{\text{all outcomes}\ x} \mathbb P(X = x)\cdot x; in this case, since only positive odd outcomes are possible, E X = P ( X = 3 ) 3 + P ( X = 5 ) 5 + P ( X = 7 ) 7 + . \mathbb E X = \mathbb P(X = 3)\cdot 3 + \mathbb P(X = 5)\cdot 5 + \mathbb P(X = 7)\cdot 7 + \dots.

Mark's solution shows a nice way to find the expectation value without calculating the probabilities. He observes, for instance, that from the starting point the expected number of moves is one more than the expected number of moves from the next point. In general, E X P = 1 + Q P ( P Q ) E X Q , \mathbb E X_P = 1 + \sum_Q \mathbb P(P\to Q)\cdot \mathbb E X_Q, where E X P \mathbb E X_P stands for "expected number of moves when in state P P ", and P ( P Q ) \mathbb P(P\to Q) stands for "probability that state P P leads to state Q Q ."

Arjen Vreugdenhil - 3 years, 9 months ago

Log in to reply

@Arjen Vreugdenhil That actually makes a lot of sense and I am really happy you were willing to explain that to me, I can definitely see where my logic was flawed or rather how my misunderstanding of the phrasing lead me to an incorrect conclusion.

I hope your replies help others as much as they helped me, thanks again!

Alex Eyman - 3 years, 9 months ago

I do not get 6 by counting . It is 21 if the order of the paths chosen matters. It is 7 if the ordering is not considered. Any ways it is not 6

Ariijit Dey - 3 years, 9 months ago

Log in to reply

You are reading the question incorrectly, I think.

Remarkably, there are six different paths of minimum length from the ant to the wheat. Different question, same answer!

Arjen Vreugdenhil - 3 years, 9 months ago

you can't just do this using the number of paths lol you could literally go in rounds between type 1 and type 2 vertices. to find expectation you need to factor in the probability of the paths as well, as well as the path length

Wuu Yyiizzhhoouu - 3 years, 9 months ago

@Mark Hennings I can't get it how you are deriving those equation,please explain me.

Bijay Shah - 3 years, 9 months ago

Log in to reply

I am applying conditional expectation formulae. Suppose we are at a type 1 1 vertex, having reached it from a type 2 2 vertex. With probability 1 2 \tfrac12 each, we could move to either a type 0 0 vertex or to a type 2 2 vertex. Then E 21 = E [ Number of steps from 1-type vertex, having just left 2-type vertex ] = 1 2 E [ Number of steps from 1-type vertex, having just left 2-type vertex, if first step is to a 0-type vertex ] + 1 2 E [ Number of steps from 1-type vertex, having just left 2-type vertex, if first step is to a 2-type vertex ] = 1 2 ( 1 + E 10 ) + 1 2 ( 1 + E 12 ) = 1 + 1 2 E 10 + 1 2 E 12 \begin{aligned} E_{21} \; = &E[\text{Number of steps from 1-type vertex, having just left 2-type vertex}] \\ \; = & \tfrac12 E[\text{Number of steps from 1-type vertex, having just left 2-type vertex, if first step is to a 0-type vertex}] \\ \; & + \tfrac12E[\text{Number of steps from 1-type vertex, having just left 2-type vertex, if first step is to a 2-type vertex}] \\ \; = & \tfrac12(1 + E_{10}) +\tfrac12(1 + E_{12}) \; = \; 1 + \tfrac12E_{10} + \tfrac12E_{12} \end{aligned} The other equations are proved similarly.

Mark Hennings - 3 years, 9 months ago

Log in to reply

I've been scratching my head staring at this for the last half-hour. Is the probability of moving from a type 1 vertex to a type 2 vertex not 2/3? And similarly is the probability of moving from a type 1 vertex to a type 0 vertex not 1/3?

Fraser Ridge - 3 years, 9 months ago

Am I missing something here, possibly in the clause "selects an adjacent edge uniformly at random"? I thought the question was how many possible paths can the ant take if never visits a vertex twice. My answer thus was 12.

Adnan Ahmad - 3 years, 9 months ago

Log in to reply

nah it can go back to a vertex it visited previous, just not the immediate previous move

Wuu Yyiizzhhoouu - 3 years, 9 months ago

@Mark Hennings Could you multiply 3 2 1 (as in the ant could choose from one of three paths initially, then one of two, and finally only one path) or will this method fail in some/most cases; if so, why?

Thanks!

Samantha Owusu-Antwi - 3 years, 9 months ago

Log in to reply

What you are saying is that there are 6 6 ways of getting to the wheat without backtracking . This does not have any immediate connection with the expected number number of moves.

Mark Hennings - 3 years, 9 months ago

If it takes the ant an even number of moves to reach the vertex adjecent to the wheat, how can the solution be an even number as well?

Lu Mat - 3 years, 9 months ago

Log in to reply

The expected jorney length is even. That does not mean the actual journey length has to be even. The average family in the US currently has 2.6 2.6 children. This is achieved without surgery.

Mark Hennings - 3 years, 9 months ago

The "expected" number of moves is by definition an average over all possible numbers of moves. The average of a bunch of odd numbers may well be even.

Arjen Vreugdenhil - 3 years, 9 months ago

Log in to reply

Thanks. I get that, but how much sense does it make to 'expect'' what's actually impossible? :)

Lu Mat - 3 years, 9 months ago

Log in to reply

@Lu Mat If you roll a regular die and receive as many dollars as the number of the die, how much money do you expect to win? The answer is $3.50, even though you will never actually get that amount...

Arjen Vreugdenhil - 3 years, 9 months ago

Log in to reply

@Arjen Vreugdenhil exactly what i was thinking: only possible solutions are 3,5 and 7 so 5 is answer? I like math but you need to place logic in 1. place tbh

Marko Novosel - 3 years, 8 months ago

Log in to reply

@Marko Novosel It is also possible that the ant takes 9, 11, 13, 15, ... moves. He is allowed to revisit old locations! And: your reasoning would work if 3, 5, 7 are equally likely; but they aren't. In fact, 3 has a probability of 50%, 5 a probability of about 12%, and 7 a probability of 15%, etc.

Arjen Vreugdenhil - 3 years, 8 months ago

@Lu Mat If the primary schools in the US planned for 2 2 children per family, they would not have enough school places. If they planned for 3 3 per family, they would be overspending. If they planned for 26 26 children for every 10 10 families, they would get it about right...

Mark Hennings - 3 years, 9 months ago

Log in to reply

@Mark Hennings Thanks, those are all fair points and I appreciate that we are not using 'expected' in its literal sense here. Nevertheless, since we were not talking about a terrarium here, only about one concrete little fellow, 'expecting' him to do the physically impossible seemed a bit too optimistic. :)

Lu Mat - 3 years, 9 months ago

Log in to reply

@Lu Mat Expectation is a precisely defined mathematical concept, and "the impossible" occurs in the most concrete situations. Toss a fair coin. The expected number of Heads is 1 / 2 1/2 , but you do not expect to get half a Head. You do expect to get Heads (roughly) half the time, though, if you keep on tossing the coin.

Mark Hennings - 3 years, 9 months ago

Log in to reply

@Mark Hennings Roger that, thanks.

Lu Mat - 3 years, 9 months ago

Log in to reply

@Lu Mat Your question makes sense if you interpret the word 'expected' in plain English, but "Expected Value" is a precisely defined mathematical term that is based on the arithmetic mean. in ordinary English with one trial, it's understandable that someone might interpret the question as asking for the mode, which is the most likely outcome.

Sean McCloskey - 3 years, 9 months ago

well... math is fun and all that but.. isnt it impossible for ant to reach wheat in any even number of moves? I dont understand english that well so maybe i understood ''problem'' wrong....

Marko Novosel - 3 years, 8 months ago

Log in to reply

Maybe you should read this wiki: expected value - definition

Agnishom Chattopadhyay - 3 years, 8 months ago

HAHAHA mathematicians are stupid!!! The "expected value" is impossible! There is no way the ant can get there in 6 moves!

nunya beezwax - 2 years, 5 months ago

See my solution below for an explicit derivation of the probability distribution.

The "expected value" is 6 moves, just as the "expected value" of rolling a regular die is 3.5.

Arjen Vreugdenhil - 2 years, 5 months ago
Kevin Bourrillion
Aug 28, 2017

Relevant wiki: Linearity of Expectation

Mark's solution is crazy elegant, but I'll jot mine down anyway.

Using his terminology,

  • The first two moves always take the ant to a type 2 vertex.
  • Then, flip a coin. If heads, the ant wins in one more move. If tails, the ant wastes some time: it takes either 2 or 4 moves (equally probable, so on average, 3 moves) to return to a type 2 vertex again.

Since the expected number of coin flips it takes to get the first "heads" is well known to be 2, I assumed we would have 2 initial moves + 3 "wasted" moves + 1 "winning" move = 6.

It's not quite that simple, since the ant could waste 2 or 4 moves more than just once. You need to make your answer recursive. If E E is the expected number of steps from a type 2 2 vertex, then E = 1 2 + 1 4 ( 2 + E ) + 1 4 ( 4 + E ) = 2 + 1 2 E E \; = \; \tfrac12 + \tfrac14(2+E) +\tfrac14(4+E) \; = \; 2 + \tfrac12E and hence E = 4 E=4 , so that the total expected number of steps is 2 + E = 6 2+E=6 .

Mark Hennings - 3 years, 9 months ago

Log in to reply

Ya marks right here again. The way you did it you would end up with an AVERAGE of 4.5 not 6 since, at least the way i'm reading your answer, you're assuming that if you make it to a type 2 vertex a second time you always finish.

If you get heads the first time, you'll have completed it in 3 moves. E=(1/2) 3 = 1.5 since this will occur 50% of the time. If you got tails, you're right that on average it takes 3 moves to end up at a type 2 vertex (either 2 or 4 moves) but if you assume that you're next move always finishes, you end up with either 5 or 7 moves to finish, or an average of 6. But remember that this is not actually your final answer. This average of 6 only occurs 50% of the time as well (just like the first case of getting a heads and going straight to the wheat in 3 moves) so our actual expected value would be 0.5 3 + 0.5*6 = 4.5 which is incorrect.

John Smith - 3 years, 9 months ago

Yeah, I did it this same way.

Mark Hennings, Kevin explained with this: "Since the expected number of coin flips it takes to get the first "heads" is well known to be 2".

Peter Byers - 3 years, 9 months ago

Log in to reply

Yes, this is true. The number of moves to get to the wheat is the random variable M = 2 + ( X 1 ) N + 1 = 3 + ( X 1 ) N M \;=\; 2 + (X-1)N + 1 \; = \; 3 + (X-1)N where X G e o ( 1 2 ) X \sim \mathrm{Geo}(\tfrac12) and N N takes the values 2 , 4 2,4 with probabilities 1 2 \tfrac12 each (and X , N X,N are independent). Thus E [ M ] = 3 + ( E [ X ] 1 ) E [ N ] = 3 + ( 2 1 ) 3 = 6 \mathbb{E}[M] \; = \; 3 + \big(\mathbb{E}[X] - 1\big)\mathbb{E}[N] \; = \; 3 + (2-1)3 \; = \; 6 I guess my problem is with @Mr X 's formula. The solution is not equivalent to 3 + 3 n = 1 2 n 3 + 3\sum_{n=1}^\infty 2^{-n} Instead it is equivalent to 3 + 3 ( n = 1 n 2 n 1 ) 3 + 3\left(\sum_{n=1}^\infty n2^{-n} - 1\right)

Mark Hennings - 3 years, 9 months ago

Log in to reply

Both formulas are correct. It depends how you see things, in your formula you calculate the probabilities of having n cycles of waste. In my formula I calculate the increments of the average each time we have on more waste cycle.

Mr X - 3 years, 9 months ago

Log in to reply

@Mr X Well OK, you are calculating E [ X ] 1 = n = 1 n P [ X = n ] 1 = n = 1 P [ X n ] 1 = n = 2 P [ X n ] = n = 1 2 n \mathbb{E}[X] - 1 \; = \; \sum_{n=1}^\infty n\mathbb{P}[X=n] - 1 \; = \; \sum_{n=1}^\infty \mathbb{P}[X \ge n] - 1 \; = \; \sum_{n=2}^\infty \mathbb{P}[X \ge n] \; = \; \sum_{n=1}^\infty 2^{-n} Your comment that "there may be a waste of 3 3 steps with probability 2 n 2^{-n} " does not immediately say the same as " 3 3 steps are wasted at least n n times with probability 2 n 2^{-n} " to me...

Mark Hennings - 3 years, 9 months ago

Log in to reply

@Mark Hennings My phrase is this one "There may be a waste of 3 steps with probabiliti es 1 2 n \frac{1}{2^n} " I don't know if it makes difference for you to use plural or singular of probability. In fact, I got to that formula just by making an equivalent Markov model of the problem then simplifying the model to 3 states

I agree with you that my phrase alone is ambiguous but with the formula next to it, it is at least more clear. isn't it?

Mr X - 3 years, 9 months ago

Log in to reply

@Mr X I am afraid not. There is only one way that a(n expected ) waste of 3 3 occurs, and this happens with probability 1 / 4 1/4 . It is true that an expected waste of 3 3 occurs at least n n times with probability 2 n 2^{-n} for any integer n n , and that is what you are adding up...

The formula relating E [ X ] \mathbb{E}[X] to the probabilities P [ X n ] \mathbb{P}[X\ge n] is standard, but not very familiar among Brilliant users, it seems. Every time I use it, I get questions about it... Probably best for to be more specific...

Mark Hennings - 3 years, 9 months ago

This solution is equivalent to 3 + 3 1 1 2 n 3+3 \sum_1^{\infty} \frac{1}{2^n} The first 2 steps and the last one are the same always. There may be a waste of 3 steps with probabilities 1 2 n \frac{1}{2^n}

Mr X - 3 years, 9 months ago

Log in to reply

That last formula is nice and simple, and intuitive, too. The part after the second '3' just reduces to 1, so one is left with 6.

Nicholas Palevsky - 3 years, 9 months ago

What's wrong with 3x2x1? From any starting point you have 3, then two from any point you'd go to next, then one.

Dayo Fayanju - 3 years, 9 months ago

Log in to reply

What you are saying is that there are 6 6 ways of getting to the wheat without backtracking . This does not have any immediate connection with the expected number number of moves.

Mark Hennings - 3 years, 9 months ago
Arjen Vreugdenhil
Aug 30, 2017

Relevant wiki: Expected Value - Definition

In the discussion under Mark's solution, it was mentioned that we expect an odd value for the number of moves, yet the expectation value is 6. To work this out in more detail, I will determine the probability distribution of the number of steps. This is the long way around to the final answer; Mark shows the fast way!

Let T be the starting point, U one of the three vertices next to it, V one of the three vertices next to the endpoint, and W the endpoint. Let P ( A B , n ) P(AB, n) stand for the probability of reaching the endpoint in n n moves, starting at a point op type B after passing through a point of type A. Then P ( V W , 0 ) = 1 ; P ( U V , n ) = 1 2 P ( V W , n 1 ) + 1 2 P ( V U , n 1 ) ; P ( V U , n ) = 1 2 P ( U V , n 1 ) + 1 2 P ( U T , n 1 ) ; P ( T U , n ) = P ( U V , n 1 ) ; P ( T , n ) = P ( U T , n ) = P ( T U , n 1 ) . P(VW,0) = 1; \\ P(UV,n) = \frac12 P(VW,n-1) + \frac12 P(VU,n-1); \\ P(VU,n) = \frac12 P(UV,n-1) + \frac12 P(UT,n-1); \\ P(TU,n) = P(UV,n-1); \\ P(\emptyset T,n) = P(UT,n) = P(TU,n-1). Here, n > 0 n > 0 , and all expressions for P ( ? ? , ? ) P(??,?) not listed here will be equal to zero.

Define A n = P ( U V , 2 n 1 ) A_n = P(UV,2n-1) . Then clearly A 0 = 0 A_0 = 0 and A 1 = P ( U V , 1 ) = 1 2 P ( V W , 0 ) = 1 2 A_1 = P(UV,1) = \frac12 P(VW,0) = \tfrac12 . We write a recursion for n 2 n \geq 2 : A n = P ( U V , 2 n 1 ) = 1 2 P ( V W , 2 n 2 ) + 1 2 P ( V U , 2 n 2 ) = 0 + 1 2 ( 1 2 P ( U V , 2 n 3 ) + 1 2 P ( U T , 2 n 3 ) = 1 4 P ( U V , 2 n 3 ) + 1 4 P ( T U , 2 n 4 ) = 1 4 P ( U V , 2 n 3 ) + 1 4 P ( U V , 2 n 5 ) ; A n = 1 4 A n 1 + 1 4 A n 2 . A_n = P(UV,2n-1) = \frac12 P(VW,2n-2) + \frac12 P(VU,2n-2) \\ = 0 + \frac12 (\frac 12 P(UV,2n-3) + \frac 12 P(UT,2n-3) \\ = \frac14 P(UV,2n-3) + \frac 14 P(TU,2n-4) \\ = \frac14 P(UV,2n-3) + \frac 14 P(UV,2n-5); \\ A_n = \frac14A_{n-1} + \frac14A_{n-2}.

The standard method for solving this Fibonacci-like recurrence relation is by substituting A n = α p n A_n = \alpha\ p^n ; we have p 2 1 4 p 1 4 = 0 p = 1 8 ( 1 ± 17 ) . p^2 - \frac14 p - \tfrac14 = 0\ \ \ \ \ \therefore\ \ \ \ \ p = \frac18(1 \pm \sqrt {17}). Thus a general solution of the recurrence relation is of the form A n = 1 8 n ( α ( 1 + 17 ) n + β ( 1 17 ) n ) ; A_n = \frac 1 {8^n}\left(\alpha(1 + \sqrt {17})^n + \beta(1 - \sqrt{17})^n\right); but since A 0 = 0 A_0 = 0 we know that β = α \beta = -\alpha , and A 1 = 1 2 A_1 = \tfrac12 shows that α = 2 17 \alpha = 2\sqrt{17} . Thus A n = 2 17 1 8 n ( ( 1 + 17 ) n ( 1 17 ) n ) . A_n = \frac 2 {\sqrt{17}} \frac 1 {8^n} \left((1 + \sqrt{17})^n - (1 - \sqrt{17})^n\right). This may be evaluated with a calculator as A n = 0.48507 ( 0.6403 9 n ( 0.39039 ) n ) , A_n = 0.48507\cdot (0.64039^n - (-0.39039)^n), or by hand as A n = k = 0 n / 2 ( n 2 k + 1 ) 1 7 k 2 3 n 2 . A_n = \frac{\sum_{k=0}^{\lfloor n/2 \rfloor} \binom{n}{2k+1}\ 17^k}{2^{3n-2}}.

Since A n A_n is the probability of reaching the endpoint in 2 n 1 2n-1 moves from point V, it is also the probability of reaching the endpoint in 2 n + 1 2n+1 moves from the starting point. To summarize, we find the following distribution:

n moves probability 0 1 0 0.000 % 1 3 1 2 50.000 % 2 5 1 8 12.500 % 3 7 5 32 15.625 % 4 9 9 128 7.031 % 5 11 29 512 5.664 % 6 13 65 2048 3.174 % 7 15 181 8192 2.209 % \begin{array}{cccr} \hline n & \text{moves} & \text{probability} & \\ \hline 0 & 1 & 0 & 0.000\% \\ 1 & 3 & \dfrac 12 & 50.000\% \\ 2 & 5 & \dfrac 18 & 12.500\% \\ 3 & 7 & \dfrac 5{32} & 15.625\% \\ 4 & 9 & \dfrac 9{128} & 7.031\% \\ 5 & 11 & \dfrac {29}{512} & 5.664\% \\ 6 & 13 & \dfrac {65}{2048} & 3.174\% \\ 7 & 15 & \dfrac {181}{8192} & 2.209\% \\ \hline \end{array}

The expected number of moves may be evaluated as E = n = 0 ( 2 n + 1 ) A n ; E = \sum_{n = 0}^\infty (2n+1)A_n; one of the many ways of doing this is E = 1 + 2 0.48507 ( 0.64039 ( 1 0.64039 ) 2 0.39039 ( 1 ( 0.39039 ) ) 2 ) = 6 . E = 1 + 2\cdot 0.48507\cdot \left(\frac{0.64039}{(1-0.64039)^2} - \frac{-0.39039}{(1-(-0.39039))^2}\right) = \boxed{6}.

I've just finished my first reading of your solution. Very interesting. Thank you

Mr X - 3 years, 9 months ago

It doesn't seem possible to get there in 6 moves given the constraint of not returning to the vertex the ant just came from

John Stein - 3 years, 9 months ago

Log in to reply

That is correct: it always takes an odd number of moves. See the table. However, the average number of moves, upon repeating this stochastic experiment many times, will tend to 6.

Arjen Vreugdenhil - 3 years, 9 months ago

Actually, while reading i got bored so i jumped to last. I typed your last expression in my calculator and got the result as 6.0004526 how is this possible to move in decimal ways?!!

GURKIRAT SINGH CHAUHAN - 3 years, 7 months ago

Log in to reply

The difference is only due to rounding. Replace { 0.48507 = 2 17 17 ; 0.64039 = 1 8 ( 1 + 17 ) ; 0.39039 = 1 8 ( 1 17 ) . \begin{cases} 0.48507 = \tfrac2{17}\sqrt{17}; \\ 0.64039 = \tfrac18(1+\sqrt{17}); \\ -0.39039 = \tfrac18(1-\sqrt{17}). \end{cases}

By the way, the e x p e c t e d expected number of steps can be a decimal number. For instance, when you roll a die, the expected outcome is 3 1 2 3\tfrac12 , even though you can never actually roll fractional values. The same here: the ant must necessarily crawl an odd number of ways, yet the expected number is 6.

Arjen Vreugdenhil - 3 years, 7 months ago
Oliver Piattella
Sep 3, 2017

The expectation value is given by

n = n n P ( n ) \langle n\rangle = \sum_{n}nP(n)

where P ( n ) P(n) is the probability of getting to the wheat in n n moves. Now, we can write this as:

P ( n ) = X ( n ) 1 3 2 n 1 P(n) = X(n)\frac{1}{3\cdot 2^{n - 1}}

since all the paths are equally likely. The 3 appears because the first move can be made in three possible ways. X ( n ) X(n) is the number of paths of n n steps, say n n -paths, which end to the wheat. We calculate this now. Let O O be the starting point, X X the final point with the wheat, 1 , 2 , 3 1,2,3 the points at one step from O O and A , B , C A,B,C the points at one step from X X .

We have the following diagram for the first two steps:

O 3 ( 1 , 2 , 3 ) 2 ( A , B , C ) O \to_{3} (1,2,3) \to_{2} (A,B,C)

with 6 possibilities. Then, either we end in X X in 3 moves, which is the minimum possible number of moves, or we get back to 1 , 2 , 3 1,2,3 . From here, either we get back to ( A , B , C ) (A,B,C) or we pass again through the starting point. We can thus think of two possible loops, one which do not pass through O O and which we call O ˉ \bar{O} -loop and another which does pass through O O and which we call O O -loop. The O ˉ \bar{O} -loop is:

( 1 , 2 , 3 ) 1 ( A , B , C ) 1 ( 1 , 2 , 3 ) (1,2,3) \to_{1} (A,B,C) \to_{1} (1,2,3)

It adds two more steps and can be done in only one way, otherwise it ends in X X . The O O -loop is:

( 1 , 2 , 3 ) 1 O 2 ( 1 , 2 , 3 ) 2 ( A , B , C ) 1 ( 1 , 2 , 3 ) (1,2,3) \to_{1} O \to_{2} (1,2,3) \to_{2} (A,B,C) \to_{1} (1,2,3)

It adds 4 more steps and can be done in 4 ways. Missing the wheat in three moves, we can trigger the loops. The two loops add either 2 or 4 steps to the initial 3, therefore the wheat can be reached only in an odd number of steps. Now:

X ( 3 + 4 n ) = 6 i = 0 n O ˉ 2 n 2 i O i ( 2 n i ) ! ( 2 n 2 i ) ! i ! X ( 5 + 4 n ) = 6 i = 0 n O ˉ 2 n + 1 2 i O i ( 2 n + 1 i ) ! ( 2 n + 1 2 i ) ! i ! X(3 + 4n) = 6\sum_{i=0}^{n}\bar{O}^{2n-2i}O^i\frac{(2n-i)!}{(2n-2i)!i!}\\ X(5 + 4n) = 6\sum_{i=0}^{n}\bar{O}^{2n+1-2i}O^i\frac{(2n+1-i)!}{(2n+1-2i)!i!}

For 3 + 4 n 3 + 4n steps, we need from 2 n 2n O ˉ \bar{O} -loops to n n O O -loops, with all the possible combinations taking into account that each time we remove two O ˉ \bar{O} -loops we can add an O O -loop. The same for 5 + 4 n 5+4n , but here a O ˉ \bar{O} -loop always remains. The factorials take into account all possible combinations of loops (they are binomial coefficients indeed).

Including the possibilities associated for each kind of loop we have:

X ( 3 + 4 n ) = 6 i = 0 n 4 i ( 2 n i ) ! ( 2 n 2 i ) ! i ! X ( 5 + 4 n ) = 6 i = 0 n 4 i ( 2 n + 1 i ) ! ( 2 n + 1 2 i ) ! i ! X(3 + 4n) = 6\sum_{i=0}^{n}4^i\frac{(2n-i)!}{(2n-2i)!i!}\\ X(5 + 4n) = 6\sum_{i=0}^{n}4^i\frac{(2n+1-i)!}{(2n+1-2i)!i!}

These can be summed (I used a software) to give:

X ( 3 + 4 n ) = 3 2 1 n ( 4 ( 17 + 17 ) ( 9 17 ) n + ( 13 17 + 85 ) ( 17 + 9 ) n ) 17 ( 17 + 9 ) X(3+4n) = \frac{3\ 2^{1-n} \left(4 \left(\sqrt{17}+17\right) \left(9-\sqrt{17}\right)^n+\left(13 \sqrt{17}+85\right) \left(\sqrt{17}+9\right)^n\right)}{17 \left(\sqrt{17}+9\right)}

and

X ( 5 + 4 n ) = 3 2 1 n ( 32 17 ( 9 17 ) n ( 49 17 + 153 ) ( 17 + 9 ) n ) 17 ( 17 + 9 ) X(5+4n) = -\frac{3\ 2^{1-n} \left(32 \sqrt{17} \left(9-\sqrt{17}\right)^n-\left(49 \sqrt{17}+153\right) \left(\sqrt{17}+9\right)^n\right)}{17 \left(\sqrt{17}+9\right)}

Substituting into the definition of n \langle n\rangle we get (again, I used a software)

n = 6 \boxed{\langle n\rangle = 6}

I get a different answer. The wheat will be reached 50% of the time in 3 steps, 25% in 5 steps, and 25% in 7 steps. The expectation of these three cases is 4.5. Shouldn't that be the answer? (0.50 * 3 + 0.25 * 5 + 0.25 * 7 = 4.5)

bob bob - 3 years, 9 months ago
Chris Trotter
Sep 1, 2017

I had 3 guesses. The answer had to be between 3 and 7. 6 was one of my options. Crushed it.

Jerry Barrington
Sep 1, 2017

I used a state transition model.

Label 5 states as columns of a spreadsheet: Top (the start location), Down A (have just moved from Top), Down B (have just moved down from A), Up A (have just moved up from B), and Bottom (the wheat). Give Top a starting value of 1, all others 0. In the next row, fill in the transition probabilities: Top to Down A 100%, Down A to Down B 100%, Down B to Up A 50%, etc. Replicate that row several times. Sum (the move number times chance to enter Bottom), and it obviously converges to 6.

I get a different answer. The wheat will be reached 50% of the time in 3 steps, 25% in 5 steps, and 25% in 7 steps. The expectation of these three cases is 4.5. Shouldn't that be the answer? (0.50 * 3 + 0.25 * 5 + 0.25 * 7 = 4.5)

bob bob - 3 years, 9 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...