Understanding the MCMC chains.
gully
February 2016

In this Notebook we pretty much just look at the Autocorrelation function, and try some experiments, most of which fizzled out.
See the other notebooks for more conclusive work.


In [8]:
import h5py

f = h5py.File('../data/mc.hdf5', mode='r')

list(f.keys())


Out[8]:
['samples']

In [9]:
d = f['samples']

In [10]:
list(d.attrs)


Out[10]:
['acceptance', 'commit']

In [11]:
d.attrs['acceptance']


Out[11]:
'0.84058'

So the acceptance fraction is about 84%, which seems too high. It should be closer to 23%. So we should increase the typical step size.

emcee


In [105]:
%matplotlib inline
import matplotlib.pyplot as plt
import seaborn as sns
%config InlineBackend.figure_format = 'svg'

In [16]:
import emcee

In [102]:
ac = emcee.autocorr

In [49]:
x = d[:,0]
x.shape


Out[49]:
(50000,)

In [127]:
acf = ac.function(d[:,5])

In [128]:
plt.plot(acf)


Out[128]:
[<matplotlib.lines.Line2D at 0x11be77f98>]

The autocorrelation function for one of the parameters. Neat!

The end.