New Algorithm!

by JS

I’ve added a new algorithm to my continuing series of Python implementations. A rather simple Metropolis-Hastings algorithm is ready for you perusal. All implementations in the series are now linked in the sidebar. Happy hacking!

I’ve also updated the site license. You are now free to copy and share anything written by me on this site (including the example code) provided you abide by the Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.

Now for some figures. A histogram of the resulting sample sequence (starting from x = 10 and running for 2400 steps):

A time series plot of the resulting samples:

As McKay points out, the random walk behavior is undesirable and requires that a large number of samples be taken for such a small state space.

UPDATE: My plots and code have an error. I don’t actually reject the rejected samples. I suspect this is why the left and right most buckets have more samples than they should.