Bugs on a Bar
100 bugs are placed uniformly at random on a 1-meter bar. Each bug independently picks a direction (left or right, 50/50) and starts walking at 1 m/min. When two bugs collide, they instantly reverse directions. A bug falls off the bar when it reaches either end.
What is the expected time until all bugs have fallen off the bar?
Hints
- What happens if two bugs pass through each other instead of bouncing? Can you tell the difference?
- If each bug walks independently to an edge, its fall-off time turns out to be $\text{Uniform}(0,1)$. The clearing time is then the maximum of 100 such variables.
- The CDF of $\max(T_1, \ldots, T_n)$ for i.i.d. $U(0,1)$ variables is $t^n$. Integrate $1 - t^n$ from 0 to 1 to get $E[M] = n/(n+1)$.
Worked Solution
How to Think About It: This is the classic "ants on a stick" puzzle, and the whole thing hinges on one beautiful observation. When two identical bugs collide and reverse, the outcome is indistinguishable from the two bugs passing straight through each other. Think about it: before the collision you have a bug moving left and a bug moving right at the same speed. After the "collision" (reversal), you still have a bug moving left and a bug moving right at the same speed. Since the bugs are identical, relabeling them changes nothing. This means you can pretend each bug walks in a straight line to the edge, completely ignoring all other bugs. The time until the bar is clear is just the maximum of 100 independent fall-off times.
Quick Estimate: Each bug is at position $x \sim \text{Uniform}(0,1)$ and picks left or right with equal probability. Its time to fall off is $x$ (if it walks left) or $1-x$ (if it walks right). Either way, the time is $\max(x, 1-x)$ or $\min(x, 1-x)$, each with probability $1/2$. But actually, regardless of direction, the fall-off time $T$ satisfies $T = x$ or $T = 1-x$, each with probability $1/2$. By symmetry, $T$ has the same distribution as $U$ where $U$ is uniform on $(0,1)$: for $0 < t < 1/2$, the bug falls off in time $t$ only if it is within distance $t$ of the edge it walks toward, giving $P(T \leq t) = 2t \cdot (1/2) + 2t \cdot (1/2)$... let us just compute the CDF directly.
Actually, let us be more careful. A single bug's fall-off time $T_i$: bug at position $x$, goes left (time $= x$) with probability $1/2$, goes right (time $= 1-x$) with probability $1/2$. Marginalizing over $x \sim U(0,1)$:
$$P(T_i \leq t) = \frac{1}{2}P(x \leq t) + \frac{1}{2}P(1-x \leq t) = \frac{1}{2} \cdot t + \frac{1}{2} \cdot t = t$$
for $0 \leq t \leq 1$. So each $T_i \sim \text{Uniform}(0,1)$! The time until the bar is clear is $M = \max(T_1, \ldots, T_{100})$, and since bugs are independent (by the pass-through trick), $P(M \leq t) = t^{100}$. The expected value is:
$$E[M] = \int_0^1 1 - t^{100} \, dt = 1 - \frac{1}{101} = \frac{100}{101}$$
So the bar clears in about $100/101 \approx 0.990$ minutes. This makes sense: with 100 bugs, it is almost certain that at least one bug lands near the middle and walks toward the far edge, so the time is close to 1 minute but not quite.
Approach: Use the pass-through equivalence to reduce to the maximum of 100 i.i.d. Uniform$(0,1)$ random variables.
Formal Solution:
*Step 1 -- Pass-through equivalence.* When two identical particles collide and reverse at equal speeds, the trajectories of the "particles" (ignoring labels) are identical to trajectories where particles pass through each other. Since bugs are indistinguishable, each bug effectively walks in a straight line to an edge.
*Step 2 -- Distribution of a single bug's time.* Bug $i$ is at position $X_i \sim U(0,1)$ and independently chooses direction $D_i \in \{L, R\}$ with equal probability. Its fall-off time is:
$$T_i = X_i \cdot \mathbf{1}_{D_i = L} + (1 - X_i) \cdot \mathbf{1}_{D_i = R}$$
For $0 \leq t \leq 1$:
$$P(T_i \leq t) = P(D_i = L)P(X_i \leq t) + P(D_i = R)P(1 - X_i \leq t) = \frac{t}{2} + \frac{t}{2} = t$$
So $T_i \sim U(0,1)$.
*Step 3 -- Maximum of independent uniforms.* The total clearing time is $M = \max_{1 \leq i \leq 100} T_i$. By independence:
$$P(M \leq t) = \prod_{i=1}^{100} P(T_i \leq t) = t^{100}$$
The density is $f_M(t) = 100 t^{99}$, and the expected value is:
$$E[M] = \int_0^1 t \cdot 100 t^{99} \, dt = 100 \int_0^1 t^{100} \, dt = \frac{100}{101}$$
Alternatively, using the survival function:
$$E[M] = \int_0^1 (1 - t^{100}) \, dt = 1 - \frac{1}{101} = \frac{100}{101}$$
Answer: The expected time until all bugs have fallen off is $\dfrac{100}{101}$ minutes, which is approximately $0.990$ minutes (about 59.4 seconds). More generally, for $n$ bugs the answer is $\dfrac{n}{n+1}$ minutes.
Intuition
The entire problem collapses once you see the pass-through trick. Two identical particles bouncing off each other at equal speeds produce the exact same set of trajectories as two particles phasing through each other -- you just swap the labels. This trick appears everywhere in combinatorics and physics (it is sometimes called the "ants on a pole" lemma). Once collisions are irrelevant, each bug is an independent random walker, and the problem reduces to the expected maximum of i.i.d. uniforms -- a standard order-statistics calculation.
The broader lesson is about recognizing when complexity is illusory. The collision dynamics look like they create complicated dependencies between all 100 bugs, but the symmetry of identical particles wipes that out completely. In quant work, this pattern shows up whenever you can find an invariant or relabeling that simplifies a seemingly coupled system into independent components -- for example, decomposing a correlated portfolio into independent principal components, or recognizing that a complex exotic option has the same payoff as a simpler combination of vanillas.