0
$\begingroup$

Two bugs are walking on a line in random fashion and are 10 cm apart from each other. At each time step, each of them has a 1/2 chance to move a centimetre to the left, and the same chance to move a centimetre to the right.

The question is what is the chance that the bugs have either passed through the same point or have met after 7 time steps? They do not have to be at the same place at the same time, but their paths must intersect at some point. They also do not have to meet at exactly the 7th time step, as long as their paths intersect at any point in time before or at the 7th time step.

My initial instict was (1/2)^7 * (1/2)^7 = 1/16384 ≈ 0.00006 but that doesn't factor in the distances. And frankly the number seems a bit lower than I might expect.

2 Answers 2

2

Note: this answer requires that the bugs are at the same place at the same time. OP has clarified that passing through the same point at different times also counts as success, so the chance is higher.

You can fix one bug, say the left one, and have the other stay put with probability $1/2$ and move left or right $2$ cm with probability $1/4$ each. They meet if either

  1. the bug takes five steps left in a row
  2. the bug takes six steps, five left and one stationary, but we cannot count all left first as we got that in 1
  3. the bug takes seven steps, six left and one right, but not the first five left
  4. the bug takes seven steps, five left and two stationary, with the stationary ones among the first six

This gives $$\frac 1{4^5}+5\frac 1{2\cdot 4^5}+5\frac 1{4^7}+{6 \choose 2}\frac 1{2^2\cdot 4^5}=\frac {121}{16384}\approx 0.00739$$

0

The probability that, within $7$ steps, the bugs visit the same location (not necessarily at the same time) is $151/16384$, computed via a procedure I wrote in Maple.

As requested, here is the code ...

bugs

Some explanatory comments . . .

bugs:

  • Bug A is the bug which starts on the left.
  • Bug B is the bug which starts on the right.

inputs:

  • k is the number of steps remaining.
  • a_max is the maximum position (rightmost position) ever visited by bug A.
  • b_min is the minimum position (leftmost position) ever visited by bug B.
  • b the current position of bug B.

output:

  • p1 is the probability that bugs A and B visit the same location (not necessarily at the same time).

logic:

  • if a_max $\ge$ b_min, the bug positions have overlapped so set p1 = 1 and return.
  • else if k $=$ 0, the bug positions have not yet overlapped but there are no steps remaining so set p1 = 0 and return.
  • else return (1/4) times the sum of the probabilities for each of 4 subcases, where the subcases are based on whether each bug will go left or right in the next step.
  • For each subcase, update the input variables, shifting all variables so that bug A's position is reset to 0, and call the procedure recursively.
  • The option remember statement causes Maple to "remember" prior (input,output) pairs from previous calls to the procedure. This allows Maple to return the output immediately (without further recursion) if the output for that input had been previously computed.
  • 0
    Do you believe there's any way to express this mathematically rather than in code?2017-02-09
  • 0
    For a particular case such as 7,10, yes. In general, it seems doubtful.2017-02-09
  • 0
    Do you mind helping me for that particular case (7 and 10)? I'm not very good at math (as you can tell). Thanks for sticking by for so long though.2017-02-09
  • 0
    Actually, even for the (7,10) case, though I'm sure doing it hand is _possible_, it would almost certainly exceed my threshold for by-hand complexity. Sorry.2017-02-09