Chapter 31
What Comes After 840? The Answer May Surprise You
If points are generated at random places on the perimeter of a circle, what is the probability that you can pick a diameter such that all of those points lie on only one side of the newly halved circle?
The Riddler, FiveThirtyEight(original post)
Solution
All points lie within some half of the circle exactly when there is an empty semicircle, equivalently when one of the points can serve as the clockwise “leader” with every other point inside the half-circle that starts at it and runs clockwise.
Fix one point and ask whether the other all fall in the semicircle clockwise from it. Each of them lands there independently with probability , so this happens with probability . There can be at most one such leader, because two different leaders would need each other inside their own forward semicircles, which is impossible. So the leader events are disjoint, and the probability that some point leads is their sum: For this is (two points always share a semicircle); for it is .
The computation
Drop points at random angles and sort them. They fit in a half-circle exactly when some gap between neighbouring points (around the loop) is at least . Measuring the frequency for several matches .
import numpy as np
rng = np.random.default_rng(0)
runs = 400_000
for N in range(2, 11):
hit = 0
for _ in range(runs):
a = np.sort(rng.uniform(0, 2*np.pi, N))
gaps = np.diff(a, append=a[0] + 2*np.pi) # gaps around the circle
hit += gaps.max() >= np.pi # an empty half-circle
print(N, hit / runs, N / 2**(N - 1)) # estimate vs N/2^(N-1)