The Markov Chain Monte Carlo (MCMC) method is designed to sample from a known target distribution. Once we get samples with density , it is easy to get an approximation of E(f(X)) by taking average of f(Xi), i=1,…, N. Besides, the MCMC method can also be applied in optimisation problems.