← Wiki Index / Genetics & Evolution / Markov Chain
🧬 Genetics & Evolution

Markov Chain

A Markov chain is a memoryless stochastic process in which the conditional probability distribution of future states depends only on the present state and is independent of the prior trajectory.

A Markov chain is a stochastic process {Xt}t∈T evolving over a countable or continuous state space S that satisfies the Markov property (memorylessness): conditioned on the present state Xt, the probability distribution of any future state Xt+s (for s > 0) is statistically independent of all past states Xu (for u < t). Introduced in 1906 by the Russian mathematician Andrey Andreyevich Markov to prove that the law of large numbers and central limit theorem hold for dependent random variables—famously demonstrated by analyzing the alternation of vowels and consonants in Alexander Pushkin's verse novel Eugene Onegin—Markov chains provide the mathematical foundation for equilibrium statistical mechanics, queuing theory, Bayesian inference via Markov chain Monte Carlo (MCMC), and molecular evolution models in maximum-likelihood phylogenetics.

Depending on the index set T, a Markov chain is classified as a discrete-time Markov chain (DTMC) when transitions occur at integer steps T = {0, 1, 2, ...} governed by a stochastic transition matrix P, or a continuous-time Markov chain (CTMC) when transitions occur at arbitrary real times T = 0, ∞) governed by an infinitesimal rate generator matrix Q. In bioinformatics and genomics, discrete-time chains and Hidden Markov Models (HMMs) power profile [sequence alignment, CpG island detection, and eukaryotic gene prediction, whereas continuous-time Markov chains parameterize nucleotide, amino-acid, and codon substitution models evaluated along evolutionary trees via Felsenstein's tree-pruning algorithm.

Discrete-Time and Continuous-Time Formulations

Discrete-Time Transition Matrices and Chapman-Kolmogorov Equations

For a discrete-time Markov chain {Xn}n≥0 on a finite state space S = {1, 2, ..., A}, the first-order Markov property states that for any sequence of states i0, i1, ..., in−1, i, j ∈ S:

P(Xn+1 = j | Xn = i, Xn−1 = in−1, ..., X0 = i0) = P(Xn+1 = j | Xn = i)

When these one-step transition probabilities are invariant with respect to step index n, the chain is time-homogeneous, and its dynamics are completely specified by the A × A row-stochastic transition matrix P = (Pij), where Pij = P(Xn+1 = j | Xn = i) satisfies non-negativity (Pij ≥ 0 for all i, j) and row conservation (∑j=1A Pij = 1 for every row i). If the initial state distribution at n = 0 is the row vector μ(0) = [μ1(0), ..., μA(0)], the distribution after n steps is obtained by vector-matrix multiplication μ(n) = μ(0) Pn.

Summing over all possible intermediate states k ∈ S at step m between 0 and m + n yields the Chapman-Kolmogorov equations for multi-step transition probabilities Pij(m+n) = P(Xm+n = j | X0 = i):

Pij(m+n) = ∑k=1A Pik(m) Pkj(n) ⟺ P(m+n) = P(m) P(n)

Thus, multi-step transition matrices form a multiplicative semigroup generated by matrix powers Pn.

Continuous-Time Rate Generators (Q) and the Matrix Exponential exp(Qt)

In molecular evolution and chemical kinetics, state transitions occur continuously over branch length or physical time t ∈ [0, ∞). A time-homogeneous continuous-time Markov chain (CTMC) {X(t)}t≥0 is defined by a family of transition probability matrices P(t) satisfying the continuous Chapman-Kolmogorov semigroup identity P(t + s) = P(t)P(s) with P(0) = I. Differentiating P(t) at t = 0 defines the A × A infinitesimal generator (instantaneous rate) matrix Q = P′(0):

  • For off-diagonal pairs i ≠ j, qij ≥ 0 is the instantaneous rate of jumping from state i to state j: Pij(Δt) = qij Δt + o(Δt) as Δt → 0.
  • For diagonal entries, qii = −∑j≠i qij ≤ 0 so that every row of Q sums to zero (∑j=1A qij = 0), and the waiting time in state i before jumping to any other state follows an exponential distribution with rate parameter λi = −qii and density f(t) = λi exp(−λi t).

Differentiating P(t + Δt) = P(t)P(Δt) and P(Δt + t) = P(Δt)P(t) yields Kolmogorov's forward equation dP(t)/dt = P(t)Q and backward equation dP(t)/dt = QP(t), whose unique solution for t ≥ 0 is the matrix exponential:

P(t) = exp(Qt) = ∑m=0∞ (Qt)m / m!

When Q is diagonalizable as Q = U Λ U−1 with eigenvalues λ1, ..., λA, the transition matrix for any branch length t is computed in O(A3) setup operations via spectral decomposition P(t) = U diag(eλ1t, ..., eλAt) U−1.

Markov Chain RegimeTime Index & OperatorRow-Sum Conservation IdentityMulti-Step Evolution LawPrimary Scientific Application
Discrete-Time (DTMC)Integer steps n ∈ {0, 1, 2, ...}; Matrix P∑j=1A Pij = 1 (Pij ≥ 0)P(n) = Pn (matrix power)MCMC sampling, PageRank, Wright-Fisher drift
Continuous-Time (CTMC)Continuous time t ∈ [0, ∞); Generator Q∑j=1A qij = 0 (qii = −∑j≠i qij)P(t) = exp(Qt) (matrix exponential)Nucleotide (GTR) and codon substitution models
Reversible Markov ChainDTMC or CTMC with detailed balanceπi Pij = πj Pji (or πi qij = πj qji)Real eigenvalues; self-adjoint in L2(π)Unrooted phylogenetic Pulley Principle; Metropolis MCMC
Absorbing Markov ChainContains ≥ 1 state with Pii = 1 (qii = 0)Fundamental matrix N = (I − Qtr)−1Absorption probability B = N RAllele fixation/extinction in population genetics
Hidden Markov Model (HMM)Latent DTMC {Zn} + emission P(Xn | Zn)Forward-Backward & Viterbi O(L · A2)Baum-Welch EM parameter estimationProfile sequence search (HMMER) and gene finding

Ergodicity, Stationary Distributions, and Detailed Balance

Irreducibility, Aperiodicity, and the Perron-Frobenius Ergodic Theorem

The long-run asymptotic behavior of a Markov chain depends on the structural connectivity of its transition graph:

  • Irreducibility: A Markov chain is irreducible if every state j ∈ S can be reached from every state i ∈ S in a finite number of steps (for every pair (i, j), there exists n ≥ 1 such that Pij(n) > 0). In an irreducible finite chain, all states belong to a single communicating class and are positive recurrent.
  • Aperiodicity: The period d(i) of state i is the greatest common divisor of all return step counts {n ≥ 1 : Pii(n) > 0}. A state with d(i) = 1 is aperiodic (guaranteed whenever Pii > 0, i.e., a self-loop exists). An irreducible finite Markov chain that is also aperiodic is called ergodic.

By the Perron-Frobenius theorem for primitive non-negative matrices, an ergodic transition matrix P has a simple dominant eigenvalue λ1 = 1, while all remaining eigenvalues satisfy |λk| < 1 for k = 2, ..., A. Consequently, there exists a unique strictly positive stationary probability distribution π = (π1, ..., πA) with ∑i=1A πi = 1 satisfying the global balance equation:

π P = π (for DTMC) or π Q = 0 (for CTMC)

Regardless of the starting state i, the n-step transition probabilities converge geometrically to π at an exponential decay rate governed by the spectral gap γ = 1 − |λ2|: limn→∞ Pij(n) = πj. Moreover, the ergodic theorem guarantees that empirical time averages along a single simulated trajectory converge with probability 1 to ensemble expectations under π, which justifies estimating posterior expectations from a single MCMC run in Bayesian inference.

Detailed Balance (Time-Reversibility) and Biological Applications

A stationary distribution π requires only global balance—that the total probability flux entering state i from all states equals the total probability flux leaving state i (∑j≠i πj Pji = ∑j≠i πi Pij). A stronger condition is detailed balance (time-reversibility), which requires pairwise flux equality between every individual pair of states i and j:

πi Pij = πj Pji (for DTMC) and πi qij = πj qji (for CTMC)

Summing either detailed balance identity over i ∈ S immediately yields ∑i πi Pij = πj ∑i Pji = πj, confirming that any distribution π satisfying detailed balance is automatically the stationary distribution of the chain. Detailed balance implies that D1/2 Q D−1/2 (where D = diag(π1, ..., πA)) is a real symmetric matrix, ensuring strictly real eigenvalues and real orthogonal eigenvectors for stable numerical diagonalization of nucleotide (GTR) and empirical amino-acid substitution matrices.

In computational biology, Markov chains operate across three primary modeling scales:

  1. Phylogenetic Substitution Models: In the 4 × 4 General Time-Reversible (GTR) DNA model and 61 × 61 Goldman-Yang codon substitution models, Q is parameterized as qij = sij πj so that detailed balance holds by construction and branch lengths are normalized to −∑i πi qii = 1 expected substitution per unit t.
  2. Markov Chain Monte Carlo (MCMC): The Metropolis-Hastings acceptance ratio in Bayesian inference explicitly enforces detailed balance π(ψ) P(ψ → ψ′) = π(ψ′) P(ψ′ → ψ) with respect to the posterior distribution π(ψ) = p(ψ | D).
  3. Hidden Markov Models (HMMs): When the underlying Markov chain {Zn} (representing hidden structural states such as Match, Insertion, Deletion in profile sequence alignment, or Exon, Intron, Intergenic in gene prediction) is unobserved and emits observed sequence tokens Xn with emission probabilities ek(x), the Forward-Backward and Viterbi dynamic-programming algorithms infer state paths in O(L · A2) time.

Frequently Asked Questions

What is the difference between global balance and detailed balance in a Markov chain?

Global balance (πP = π) requires that the net probability flow entering any state i from the entire state space equals the total flow leaving state i, which allows net cyclic probability currents (such as 1 → 2 → 3 → 1). Detailed balance (πi Pij = πj Pji) requires that the flow from i to j equals the reverse flow from j to i for every individual pair, eliminating net probability cycles and making a movie of the stationary chain indistinguishable when played forward or backward in time.

How does the second-largest eigenvalue modulus |λ2| control Markov chain mixing time?

When an ergodic transition matrix P is decomposed spectrally, the n-step deviation from stationarity scales as |Pij(n) − πj| ≤ C |λ2|n = C exp(−n ln(1/|λ2|)), where |λ2| < 1 is the second-largest eigenvalue modulus. The quantity γ = 1 − |λ2| is the spectral gap; a small spectral gap (|λ2| close to 1) indicates a bottleneck between weakly connected regions of state space and causes slow mixing in MCMC simulations.

Why are phylogenetic rate matrices Q normalized so that −∑i πi qii = 1?

In a continuous-time Markov substitution model P(t) = exp(Qt), only the product Qt is identifiable from sequence comparisons; scaling Q by a constant c and dividing branch length t by c leaves P(t) unchanged. Normalizing the generator matrix so that the stationary average rate of leaving the current state equals unity (−∑i=1A πi qii = 1) fixes the units of branch length t to be the expected number of substitutions per site.

References

  1. Markov, A. A. (1906). "Extension of the law of large numbers to dependent quantities." Izvestiya Fiziko-Matematicheskogo Obshchestva pri Kazanskom Universitete, Series 2, 15, 135–156. https://doi.org/10.1007/978-1-4612-4240-6_3
  2. Rabiner, L. R. (1989). "A tutorial on hidden Markov models and selected applications in speech recognition." Proceedings of the IEEE, 77(2), 257–286. https://doi.org/10.1109/5.18626
  3. Norris, J. R. (1997). Markov Chains. Cambridge University Press. https://doi.org/10.1017/CBO9780511810633
  4. Durbin, R., Eddy, S. R., Krogh, A., & Mitchison, G. (1998). Biological Sequence Analysis: Probabilistic Models of Proteins and Nucleic Acids. Cambridge University Press. https://doi.org/10.1017/CBO9780511790492
🧬 Support Open Science
Explore interactive science games on LowKey Games or browse scientific apparel & accessories in the CRV Science Shop.
💡 Spot an inaccuracy or have primary literature to expand this article?
Submit a citation or revision note using your shared CRV Science / LowKey Games profile ID.
Suggest Revision