Simple Markov chain Monte Carlo (MCMC) algorithm in python
I present here a simple Markov chain Monte Carlo python implementation to sample
a 2D surface of potential.
First I define a Müller potential from a piece of code I found on
gist.
Which looks like:
The code for MCMC sampling is quite short:
And takes less than 1 minute for 1 000 000 steps of monte carlo:
Now we can plot the distribution obtained onto the surface of the potential
sampled:
And if you increase :
You sample more:
If you want to ask me a question or leave me a message add @bougui505 in your comment.