Markov Chain Monte Carlo (MCMC)

Markov Chain Monte Carlo (MCMC) is a class of computer algorithms designed to draw samples from complex, high-dimensional probability distributions. In artificial intelligence and machine learning, MCMC is heavily utilized for probabilistic reasoning, particularly in Bayesian Inference, where calculating the posterior distribution analytically is often mathematically intractable.

Core Concept

MCMC combines two statistical concepts:

  1. Monte Carlo Integration: Using random sampling to estimate numerical properties of a probability distribution (e.g., mean, variance).
  2. Markov Chains: A sequence of random variables where the state of the next step depends solely on the current state (possessing the memoryless Markov property).

By constructing a Markov chain whose stationary distribution is exactly the target probability distribution, running the chain for a sufficiently long time ensures that the generated states converge to samples from the target distribution.

Key Features

  • Stationary Distribution: The unique probability distribution that the Markov chain eventually converges to, which is engineered to be the target distribution.
  • Burn-in Period: The initial sequence of samples discarded because the chain has not yet converged from its starting state to the target distribution’s high-probability regions.
  • Autocorrelation: Consecutive samples in MCMC are inherently dependent. High autocorrelation reduces sample efficiency, meaning more samples are required to obtain accurate estimates.
  • Convergence Diagnostics: Tools to check if the chain has converged, including:
    • Trace Plots: Visualizations of the parameters over iterations.
    • Gelman-Rubin Statistic (): A comparison of variance within and across multiple chains; values close to indicate convergence.
    • Effective Sample Size (ESS): The number of independent samples that contain the equivalent information of the correlated MCMC samples.

Common Algorithms

  • Metropolis-Hastings Algorithm: The classic MCMC algorithm. It proposes a new state from a proposal distribution and accepts or rejects it based on a probability ratio.
  • Gibbs Sampling: A special case of Metropolis-Hastings where variables are updated iteratively, one at a time, by sampling from their full conditional distributions.
  • Hamiltonian Monte Carlo (HMC): An advanced algorithm that uses gradient information to make more informed, distant proposals, reducing autocorrelation and improving high-dimensional sampling efficiency.
  • Variational Inference: A deterministic alternative to MCMC that frames inference as an optimization problem, typically trading exactness for speed.
  • Probabilistic Graphical Models: Graphical frameworks (like Bayesian networks or Markov random fields) where MCMC is used to perform inference on complex structures.
  • Bayesian Neural Networks: Neural networks where MCMC is used to sample weight configurations to represent epistemic uncertainty.