Books · The Fiddler: Solutions
Chapter 70
Can You Hop to the Lily Pad?
A frog starts on pad among four pads. Pad is a permanent home; pad is a permanent trap. From pad it jumps to or , each with probability ; from pad it jumps to with probability or to with probability . What is the probability it ends up home on pad ?
The Fiddler, Zach Wissner-Gross, January 24, 2025(original post)
Solution
Let be the probability of reaching pad from pad . Then and (a jump to pad loses). Substituting,
The computation
Hop the actual frog: start a large batch on pad and let each one jump under the stated rules until it is absorbed at pad (home) or pad (trap); the home fraction lands on .
import numpy as np
rng = np.random.default_rng(0)
pad = np.full(2_000_000, 2)
while np.isin(pad, (2, 3)).any():
at2, at3 = pad == 2, pad == 3
pad[at2] = np.where(rng.random(at2.sum()) < 0.5, 1, 3) # 2 -> 1 or 3
pad[at3] = np.where(rng.random(at3.sum()) < 1 / 3, 2, 4) # 3 -> 2 or 4
print((pad == 1).mean()) # ~0.6 (= 3/5)
Extra Credit
Now the pond has pads forever, and from pad the frog jumps down to with probability and up to with probability . Starting on pad , what is the probability it ever reaches pad ?
Solution
With , the balance and give , so The upward drift () makes the walk transient, so , forcing and (The official extra-credit value is paywalled; this closed form is my own.)
The computation
Walk the infinite-pond frog directly: from pad step down with probability , else up, and record whether it ever touches pad before drifting off (capped at a high pad). The reached fraction matches .
import numpy as np
rng = np.random.default_rng(0)
k = np.full(2_000_000, 2); reached = np.zeros_like(k, bool); alive = np.ones_like(k, bool)
for _ in range(4000):
reached |= alive & (k == 1); alive &= k != 1
i = alive
step = np.where(rng.random(i.sum()) < 1.0 / k[i], -1, 1)
k[i] += step; alive &= k <= 3000
if not alive.any(): break
print(reached.mean(), 1 - 1 / np.e) # 0.6324 0.63212