Branching Processes
Each individual in a population has a random number of children, independently, with the same distribution. Will the family line survive forever or die out? This model, the Galton–Watson branching process, was invented to study the extinction of surnames. It also describes chain reactions, epidemics, viral sharing and the growth of search trees, and generating functions solve it elegantly.
The model
Start with one individual (generation 0). Each individual has children with probability , independently. Let be the size of generation and the mean number of children. By Wald's identity, , so
The population grows on average if (supercritical), shrinks if (subcritical), and stays level on average if (critical).
Extinction probability
Let be the offspring PGF. Generation sizes have PGFs that are iterates of : (random sums). The extinction probability is the probability that some generation is empty, and it satisfies
because the line dies out exactly when each of the first individual's children starts a line that dies out. The answer is the smallest root of in . If , that root is 1: extinction is certain (except in the trivial case ). If , there is a root , and the line survives forever with probability .
from sympy import symbols, Rational, solve, nsimplify
s = symbols("s")
# offspring: 0, 1, 2 children with probabilities 1/4, 1/4, 1/2 (m = 1.25)
G = Rational(1, 4) + Rational(1, 4) * s + Rational(1, 2) * s ** 2
roots = solve(G - s, s)
print("roots of G(s) = s:", roots, " extinction probability:", min(r for r in roots if 0 <= r <= 1))
# iterate d_{n+1} = G(d_n): probability of extinction by generation n
d = 0.0
Gf = lambda x: 0.25 + 0.25 * x + 0.5 * x * x
for n in range(1, 31):
d = Gf(d)
if n in (1, 2, 5, 10, 30):
print(f"P(extinct by generation {n:2d}) = {d:.5f}")roots of G(s) = s: [1/2, 1] extinction probability: 1/2
P(extinct by generation 1) = 0.25000
P(extinct by generation 2) = 0.34375
P(extinct by generation 5) = 0.44776
P(extinct by generation 10) = 0.48882
P(extinct by generation 30) = 0.49997
The iteration starting from gives the probability of extinction by generation , increasing to the smallest fixed point.
Simulation
import random
rng = random.Random(4)
def offspring():
u = rng.random()
return 0 if u < 0.25 else (1 if u < 0.5 else 2)
def dies_out(max_gen=60, cap=2000):
z = 1
for _ in range(max_gen):
if z == 0:
return True
if z > cap: # so large that extinction is practically impossible
return False
z = sum(offspring() for _ in range(z))
return z == 0
runs = 5000
print("simulated extinction probability:", sum(dies_out() for _ in range(runs)) / runs, " theory 0.5")simulated extinction probability: 0.4972 theory 0.5
The critical case
With , extinction is certain, yet the expected generation size stays 1 forever. The two facts are reconciled by rare huge families: most lines die quickly, a few grow large. The probability of surviving to generation decays only like (Kolmogorov's estimate), where is the offspring variance.
Epidemics and
In an early epidemic, each infected person infects a random number of others, with mean . A branching process predicts that an outbreak started by one case dies out with probability , the root of . With Poisson() offspring, ; for , . So even a fairly contagious disease fizzles out about 20% of the time when introduced once, and reducing below 1 guarantees extinction.
In software
Branching processes model viral content spread (each share triggers a random number of reshares), cascading failures, and the size of search trees in backtracking algorithms. The critical case explains why "every request spawns on average one retry" is dangerous: the expected load is stable, but rare cascades are huge.
Exercises
Exercise 1: Mean generation size
Each individual has 0 or 3 children with probabilities and . What is ?
Answer
.
Solution
and .
Exercise 2: Extinction
For the offspring distribution of Exercise 1, find the extinction probability.
Answer
.
Solution
. Solve : , with roots and . The smallest root in is .
Exercise 3: Epidemic extinction (code)
Solve by iteration for .
Answer
About 0.686, 0.417, 0.203 and 0.060.
Solution
import math
for R0 in [1.2, 1.5, 2, 3]:
d = 0.0
for _ in range(2000):
d = math.exp(R0 * (d - 1))
print(R0, round(d, 3))1.2 0.686
1.5 0.417
2 0.203
3 0.06
Test yourself
If the mean number of offspring is , the probability of eventual extinction is…
- 0.9
- 0.1
- 1
- 0.5
The extinction probability is the smallest root in of…