Returns, Leads and the Arc Sine Law
Toss a fair coin 1000 times and track who is ahead, Heads or Tails. Intuition says the lead should change hands often and each side should be ahead about half the time. The truth is the opposite: the most likely outcome is that one side leads almost the whole game. This is the arc sine law, one of the most counter-intuitive results in probability.
Time in the lead
Let be the simple random walk (heads minus tails after tosses), and say Heads leads during step if the path segment from to lies above 0. Let be the number of steps in during which Heads leads. Then is always even, and
This distribution is U-shaped: the extreme values and are the most likely, and an even split is the least likely. As , the fraction of time in the lead, , has the arc sine density
from math import comb, asin, sqrt, pi
def u(m2):
m = m2 // 2
return comb(2 * m, m) / 4 ** m
n2 = 20
probs = [u(2 * k) * u(n2 - 2 * k) for k in range(n2 // 2 + 1)]
for k, p in enumerate(probs):
print(f"Heads leads {2 * k:2d} of 20 steps: {p:.4f} " + "#" * int(p * 200))
print("total:", round(sum(probs), 10))
F = lambda x: 2 / pi * asin(sqrt(x))
print("limit: P(leading less than 10% of the time) =", round(F(0.1), 4))Heads leads 0 of 20 steps: 0.1762 ###################################
Heads leads 2 of 20 steps: 0.0927 ##################
Heads leads 4 of 20 steps: 0.0736 ##############
Heads leads 6 of 20 steps: 0.0655 #############
Heads leads 8 of 20 steps: 0.0617 ############
Heads leads 10 of 20 steps: 0.0606 ############
Heads leads 12 of 20 steps: 0.0617 ############
Heads leads 14 of 20 steps: 0.0655 #############
Heads leads 16 of 20 steps: 0.0736 ##############
Heads leads 18 of 20 steps: 0.0927 ##################
Heads leads 20 of 20 steps: 0.1762 ###################################
total: 1.0
limit: P(leading less than 10% of the time) = 0.2048
So in a long game there is a 20% chance that one particular side is ahead less than 10% of the time, and a 40% chance that one of the two sides is.
A simulation
import numpy as np
rng = np.random.default_rng(1)
n, games = 1000, 5000
steps = rng.integers(0, 2, size=(games, n), dtype=np.int8) * 2 - 1
S = np.concatenate([np.zeros((games, 1), dtype=np.int16), steps.cumsum(axis=1, dtype=np.int16)], axis=1)
leading = ((S[:, :-1] + S[:, 1:]) > 0).sum(axis=1) / n # segment above zero
bins = np.histogram(leading, bins=10, range=(0, 1))[0] / games
for i, b in enumerate(bins):
print(f"fraction of time Heads leads in [{i / 10:.1f}, {(i + 1) / 10:.1f}): {b:.3f} " + "#" * int(b * 150))fraction of time Heads leads in [0.0, 0.1): 0.201 ##############################
fraction of time Heads leads in [0.1, 0.2): 0.096 ##############
fraction of time Heads leads in [0.2, 0.3): 0.076 ###########
fraction of time Heads leads in [0.3, 0.4): 0.063 #########
fraction of time Heads leads in [0.4, 0.5): 0.067 ##########
fraction of time Heads leads in [0.5, 0.6): 0.062 #########
fraction of time Heads leads in [0.6, 0.7): 0.064 #########
fraction of time Heads leads in [0.7, 0.8): 0.069 ##########
fraction of time Heads leads in [0.8, 0.9): 0.093 #############
fraction of time Heads leads in [0.9, 1.0): 0.210 ###############################
The histogram is high at both ends and low in the middle, matching the arc sine density.
Why intuition fails
The walk returns to 0 with certainty, but the return times have infinite mean. Once one side gets ahead, the expected time to the next tie is enormous, so long stretches with the same leader are normal. Ties become rarer as the game goes on: the expected number of returns to 0 in steps grows only like .
The last tie
A second arc sine law: let be the time of the last return to 0 before . Then , the same distribution. In a game of 2000 tosses, the probability that the last tie happened in the first 200 tosses (and one side led for the last 1800) is about .
import numpy as np
from math import asin, sqrt, pi
rng = np.random.default_rng(7)
n, games = 2000, 5000
S = (rng.integers(0, 2, size=(games, n), dtype=np.int8) * 2 - 1).cumsum(axis=1, dtype=np.int16)
zero = S == 0
has_zero = zero.any(axis=1)
last = np.where(has_zero, n - np.argmax(zero[:, ::-1], axis=1), 0) # time of the last tie (0 if none)
print("P(last tie in the first 10%) ~", round(float((last <= n // 10).mean()), 4), " arc sine:", round(2 / pi * asin(sqrt(0.1)), 4))P(last tie in the first 10%) ~ 0.2122 arc sine: 0.2048
In software
The arc sine law warns against reading meaning into long streaks: a trading strategy that has led a benchmark for most of a year, or a variant that has "consistently" led an A/B test, may be pure chance. Sequential testing methods exist precisely because peeking at a running comparison and stopping when one side leads inflates false positives.
Exercises
Exercise 1: Small case
For 4 tosses, list the probabilities that Heads leads 0, 2 or 4 of the steps.
Answer
, , .
Solution
, , . , , .
Exercise 2: Arc sine probabilities
In the limit, what is the probability that Heads leads more than 90% of the time? Between 40% and 60%?
Answer
About 0.205; about 0.128.
Solution
by symmetry. .
Exercise 3: Brute force for small (code)
Enumerate all paths of 10 steps and count, for each , the paths in which Heads leads during exactly steps. Compare with .
Answer
The counts divided by 1024 match the formula for every even ; odd never occur.
Solution
from itertools import product
from collections import Counter
from math import comb
u = lambda m: comb(m, m // 2) / 2 ** m
c = Counter()
for steps in product((-1, 1), repeat=10):
s, lead = 0, 0
for x in steps:
prev, s = s, s + x
lead += (prev + s) > 0
c[lead] += 1
print(sorted(c.items()))
print([round(u(k) * u(10 - k) * 1024) for k in range(0, 11, 2)])[(0, 252), (2, 140), (4, 120), (6, 120), (8, 140), (10, 252)]
[252, 140, 120, 120, 140, 252]
Test yourself
In a long fair coin game, which fraction of time in the lead is most likely for Heads?
- About 1/2
- Close to 0 or close to 1
- Exactly 1/2
- About 1/4
Why are long leads common in a fair game?
- The coin is biased
- Returns to 0 are certain but have infinite expected waiting time
- Because of the law of large numbers
- They are not common