Metropolis Algorithm
The Metropolis algorithm generates a Markov chain targeting a density
For a normal random walk with stepsize
Starting from
Adjust the current value
The proposal is accepted with probability
Trace plot and histogram
Move iterations to reveal the chain. Change stepsize to generate a new chain with a different proposal standard deviation. The left panel shows the trace in orange and rejected proposals as small light-gray dots. At a rejection, the chain stays at its previous value; the gray dot shows the value it tried instead. Hover over a gray dot for details. Proposals outside the shared vertical range are clipped. The right panel compares the chain's histogram (orange, after 20 iterations) with the target density (blue) and the proposal density centered at the current value (green). Both panels share the same vertical scale.