Skip to content
Vamshi Jandhyala

Books · The Riddler

Chapter 31

What Comes After 840? The Answer May Surprise You

If NN 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 NN 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 N1N-1 all fall in the semicircle clockwise from it. Each of them lands there independently with probability 12\tfrac12, so this happens with probability (12)N1(\tfrac12)^{N-1}. 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 NN leader events are disjoint, and the probability that some point leads is their sum: Pr(all in a half)=N12N1=N2N1.\Pr(\text{all in a half}) = N \cdot \frac{1}{2^{\,N-1}} = \boxed{\dfrac{N}{2^{\,N-1}}}. For N=2N=2 this is 11 (two points always share a semicircle); for N=10N=10 it is 10/512=5/2562%10/512 = 5/256 \approx 2\%.

The computation

Drop NN 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 π\pi. Measuring the frequency for several NN matches N/2N1N/2^{N-1}.

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)