Note
Click here to download the full example code
Dividing Chains¶
It's common with algorithms like MH and other random walkers to have multiple walkers each providing their own chains. Typically, you want to verify each walker is burnt in, and then you put all of their samples into one chain.
But, if your final samples are made up for four walkers each contributing 10k samples, you may want to inspect each walker's surface individually.
In this toy example, all the chains are from the same random generator, so they're on top of each other. Except MCMC chains to not be as perfect.
Out:
/home/runner/work/ChainConsumer/ChainConsumer/.venv/lib/python3.10/site-packages/numpy/_core/fromnumeric.py:57: FutureWarning: 'DataFrame.swapaxes' is deprecated and will be removed in a future version. Please use 'DataFrame.transpose' instead.
return bound(*args, **kwds)
from chainconsumer import Chain, ChainConsumer, PlotConfig, make_sample
df = make_sample(num_dimensions=2, seed=3, num_points=40000)
c = ChainConsumer()
combined = Chain(samples=df, name="Model", walkers=4)
for chain in combined.divide():
c.add_chain(chain)
c.set_plot_config(PlotConfig(flip=True))
fig = c.plotter.plot()
Total running time of the script: ( 0 minutes 0.381 seconds)
Download Python source code: plot_3_divide_chains.py