Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 64

Can You Catch The Cricket?

Riddler Express

A cricket makes two 11-foot hops, each in an independent uniformly random direction. Of all possible distances from its start, which is the most probable (the peak of the distribution), not the average?

Solution

Let θ\theta be the angle between the two hops. By the law of cosines the distance from start to finish is X=22cosθX = \sqrt{2 - 2\cos\theta}, ranging from 00 (hops cancel) to 22 (hops align). With θ\theta uniform on [0,π][0, \pi], the cumulative distribution is F(x)=Pr(Xx)=Pr ⁣(cosθ2x22)=1πarccos ⁣(2x22),F(x) = \Pr(X \le x) = \Pr\!\Big(\cos\theta \ge \tfrac{2 - x^2}{2}\Big) = \frac1\pi \arccos\!\Big(\frac{2 - x^2}{2}\Big), and differentiating gives the density f(x)=2π4x2,0x<2.f(x) = \frac{2}{\pi\sqrt{4 - x^2}}, \qquad 0 \le x < 2. This grows without bound as x2x \to 2: the density piles up at the far end, because near x=2x = 2 a wide range of angles θ\theta all give nearly the same near-maximal distance. So the peak sits at the largest distance, 2 feet.\boxed{2 \text{ feet}}.

The computation

Simulate two random unit hops, histogram the end-to-start distances, and report the busiest bin.

import numpy as np
rng = np.random.default_rng(0)
N = 5_000_000
a, b = rng.uniform(0, 2*np.pi, N), rng.uniform(0, 2*np.pi, N)
d = np.hypot(np.cos(a) - np.cos(b), np.sin(a) - np.sin(b))
h, edges = np.histogram(d, bins=200, range=(0, 2))
print((edges[h.argmax()] + edges[h.argmax() + 1]) / 2)   # ~1.99 -> 2

Riddler Classic

Two identical dice, each numbered 11 to 66, are weighted so that the eleven possible sums 22 through 1212 are as close to equally likely as possible. Choosing the weighting that minimises the variance of those eleven probabilities, what should the probabilities of the six faces be?

Solution

Let p1,,p6p_1, \dots, p_6 be one die’s face probabilities, summing to 11. Since the dice are identical and independent, each sum’s probability is a convolution, for example Pr(2)=p12,Pr(3)=2p1p2,Pr(4)=p22+2p1p3, ,\Pr(2) = p_1^2,\quad \Pr(3) = 2p_1 p_2,\quad \Pr(4) = p_2^2 + 2p_1 p_3,\ \dots, and we minimise 111s=212(Pr(s)111)2\frac{1}{11}\sum_{s=2}^{12}\big(\Pr(s) - \tfrac1{11}\big)^2. The objective is symmetric under relabelling a face kk as 7k7 - k, so the optimum is symmetric, pk=p7kp_k = p_{7-k}, and the minimiser pushes weight toward the extreme faces to lift the otherwise-rare sums 22 and 1212: p1=p60.244,p2=p50.137,p3=p40.119,\boxed{p_1 = p_6 \approx 0.244,\quad p_2 = p_5 \approx 0.137,\quad p_3 = p_4 \approx 0.119,} giving a minimum variance of about 0.001220.00122, far flatter than fair dice. (If the two dice were allowed to differ, one could do better still, but the puzzle fixes them identical.)

The computation

Minimise the variance of the eleven sum-probabilities over the six face weights, constrained to sum to 11.

import numpy as np
from scipy.optimize import minimize
def variance(p):
    s = {}
    for i in range(6):
        for j in range(6):
            s[i + j] = s.get(i + j, 0) + p[i] * p[j]
    return sum((v - 1 / 11)**2 for v in s.values()) / 11
con = [{'type': 'eq', 'fun': lambda p: sum(p) - 1}]
best = min((minimize(variance, np.random.dirichlet(np.ones(6)),
            bounds=[(0, 1)]*6, constraints=con) for _ in range(40)),
           key=lambda r: r.fun)
print(round(best.fun, 6), np.round(best.x, 3))    # 0.001217, [.244 .137 ..]