← Return to Apps
Loading Python environment...
This may take a few seconds on first load.
About This App
The Metropolis-Hastings algorithm is a Markov Chain Monte Carlo (MCMC) method for obtaining a sequence of random samples from a probability distribution for which direct sampling is difficult.
How It Works
The algorithm generates samples by constructing a Markov chain that has the desired distribution as its equilibrium distribution. At each step:
- Propose a new state \(x'\) from the current state \(x\) using a proposal distribution \(q(x' | x)\)
- Calculate the acceptance ratio: \[\alpha = \min\left(1, \frac{p(x') q(x|x')}{p(x) q(x'|x)}\right)\]
- Accept the new state with probability \(\alpha\), otherwise stay at the current state
Where \(p(x)\) is the target probability distribution we want to sample from.
This simple procedure allows us to sample from complex, high-dimensional distributions that would be intractable to sample from directly - making it a cornerstone of modern Bayesian statistics and computational physics.
Back to top