← Guides Markov Chain Drift

Core 12 min read Open the module

Drift as a Markov chain

The exact probability of every allele count, generation by generation, with no random numbers at all.

Read first: Genetic drift

States and transitions

The Drift module draws random populations and shows what happened to them. The Markov module computes what is expected to happen. It tracks the probability of every possible state of one population, and the result is the same on every run.

The state is i, the number of copies of allele A among the 2N gene copies. There are 2N + 1 states, 0 to 2N. The transition probability from state i to state j is the Wright-Fisher binomial: P(j | i) = C(2N, j) (i/2N)^j (1 − i/2N)^(2N − j). States 0 and 2N are absorbing: P(0 | 0) = 1 and P(2N | 2N) = 1.

A worked case: N = 10, so there are 20 gene copies and 21 states. A population in state 10 has p = 0.5. The next state is a draw from Binomial(20, 0.5). The most likely next state is 10, with probability C(20, 10) × 0.5²⁰ = 0.176. The probability of reaching state 0 or 20 in one step is 0.5²⁰, about one in a million.

One generation

Figure 1. The distribution after 1 generation for N = 10, starting at state 10. It is the Binomial(20, 0.5) shape, with a peak of 0.176 at state 10. The bars at states 0 and 20 are too small to see.

Spreading and absorption

The module starts with all the probability on one state, v₀(i₀) = 1. Each generation it multiplies the probability vector by the transition matrix: v(t+1)(j) = Σ over i of v(t)(i) P(j | i). The chart shows the vector after the number of generations you choose.

After 10 generations the distribution is wide. Each end bar holds 0.093, and 0.815 is still in the interior states 1 to 19. After 50 generations each end holds 0.446, so 0.892 of the probability is absorbed and 0.108 is still segregating. The interior is almost flat: about 0.006 at state 10 and 0.005 at states 1 and 19. By generation 200 each end holds 0.500 and the interior holds less than 0.0001.

The shape of the end result is fixed by symmetry. The mean allele count never changes, because drift has no direction, so the probability of reaching state 2N equals i₀/2N. Starting at p = 0.5 the two ends both end at 0.500.

Fifty generations

Figure 2. The distribution after 50 generations for N = 10, starting at state 10. Each absorbing end holds 0.446, a total of 0.892. The remaining 0.108 is spread almost evenly over the 19 interior states.

Exercise

Start near an edge

Set Ne 10, State 2, Gen 100 and press Run. Read the bars at states 0 and 20.

What to expect. State 0 holds 0.899 and state 20 holds 0.099, close to the 0.90 and 0.10 given by i₀/2N. The remaining 0.003 is still segregating.

Open the walkthrough step →

Bigger populations drain slower

Population size sets the speed. With N = 20, starting at state 20 (p = 0.5), 0.594 of the probability is absorbed after 50 generations, 0.297 at each end. Only 0.406 remains in the interior. For N = 10 at the same time, 0.108 remained. A population of 10 reaches 0.591 absorbed at generation 24, so doubling N roughly doubles the time.

With N = 200 and 100 generations, only 0.013 has been absorbed. The other 0.987 is spread over 399 interior states, an average of 0.0025 per state. The two end bars (0.006 each) are the tallest bars.

Compare this with the Drift module. Ten random populations show fixed and lost counts that change with each run. The Markov chain gives the exact fractions that the average of many random populations approaches. It also costs more: the matrix has (2N + 1)² entries, so N is limited to 200 in the module.

Exercise

Double the population

Set Ne 20, State 20, Gen 50 and run it. Then set Ne 10, State 10, Gen 50 and run it again.

What to expect. At Ne 20 about 0.59 is absorbed (0.297 at each end). At Ne 10 about 0.89 is absorbed (0.446 at each end). Doubling N roughly doubles the time to absorb a given share: 0.59 at generation 24 for Ne 10, at generation 50 for Ne 20.

Open the walkthrough step →

Summary

  • The state is the count i of allele A among 2N copies, and each generation draws the next count from Binomial(2N, i/2N).
  • The module multiplies the probability vector by the transition matrix, so it shows exact probabilities, not a random sample.
  • States 0 and 2N are absorbing; for N = 10 from state 10, 0.892 is absorbed after 50 generations and 1.000 after 200.
  • The probability of fixation of A equals the starting frequency i₀/2N: 0.099 from state 2 at N = 10.
  • Absorption is slower in bigger populations: 0.594 absorbed at N = 20 and 0.013 at N = 200 for the same time scale.