Metropolis–Hastings algorithm
This algorithm can draw samples from any probability distribution P(x), requiring only that the density can be calculated at x. The algorithm generates a set of states xt which is a Markov chain because each state xt depends only on the previous state xt-1. The algorithm depends on the creation of a proposal density Q(xt,x') which depends on the current state xt and which can generate a new proposed sample x'. For example, the proposal density could be a Gaussian centred on the current state xt
Q(xt) ~ N(xt,σ2I).
This proposal density would generate samples centred around the current state with variance σ2I. So we draw a new proposal state from Q(xt,x') and then calculate a value
a = a1 a2 a1 = P(x') / P(xt a2 = Q(xt;x') / Q(x';xt)