To run them sequentially, you can use a similar approach to your PyMC 2 example. The main difference is that each sample
call returns a multipurpose trace instance (containing only one chain in this case). merge_traces
will take a list of multipurpose instances and create a single instance with all the chains.
#!/usr/bin/env python3 import pymc as pm import numpy as np from pymc.backends.base import merge_traces xobs = 4 + np.random.randn(20) model = pm.Model() with model: mu = pm.Normal('mu', mu=0, sd=20) x = pm.Normal('x', mu=mu, sd=1., observed=xobs) step = pm.NUTS() with model: trace = merge_traces([pm.sample(1000, step, chain=i) for i in range(2)])
source share