Metropolis-Hastings algorithm - Wikipedia
In statistics and statistical physics, the Metropolis-Hastings algorithm is a Markov chain Monte Carlo (MCMC) method for obtaining a sequence of random samples from a probability distribution from which direct sampling is difficult. This sequence can be used to approximate the distribution (e.g. to generate a histogram) or to compute an integral (e.g.
https://en.wikipedia.org/wiki/Metropolis%E2%80%93Hastings_algorithm