Chapter 74
Can You Cut The Perfect Pancake?
Riddler Classic
In a huge electorate, every voter independently picks candidate or with probability . On election night the who voted in person are counted; the remaining (mail) are counted later. What is the probability that whoever trailed on election night ends up winning?
Solution
Measure each candidate’s lead as a margin (votes for minus votes for ). With a vast electorate the night margin (from of voters) and the mail margin (from ) are independent, each a zero-mean normal with variance proportional to its share: , in units of the total vote count. The final margin is , with variance .
The night-trailer wins exactly when and have opposite signs. The pair is jointly normal with correlation For a zero-mean bivariate normal the chance of opposite signs is , so A late lead change happens about one race in seven: the mail fifth of the vote can overturn the night result, but only when election night was already close.
The computation
Simulate a large electorate: split the vote into the in-person and mail , draw each as a fair binomial, and count how often the night margin and the full margin disagree in sign.
import numpy as np
rng = np.random.default_rng(0)
N, runs = 10_000_000, 2_000_000
nd, nm = int(0.8 * N), int(0.2 * N)
day = rng.binomial(nd, 0.5, runs) - nd / 2 # A's election-night margin
mail = rng.binomial(nm, 0.5, runs) - nm / 2 # A's mail margin
flip = np.mean(np.sign(day) != np.sign(day + mail))
print(flip, 0.5 - np.arctan(2) / np.pi) # ~0.1476