I am learning PyMC3 for Bayesian modeling. You can create a model and sample with:
import pandas as pd
import pymc3 as pm
# obs is a DataFrame with a single column, containing
# the observed values for variable height
obs = pd.DataFrame(...)
# we create a pymc3 model
with pm.Model() as m:
mu = pm.Normal('mu', mu=178, sd=20)
sigma = pm.Uniform('sigma', lower=0, upper=50)
height = pm.Normal('height', mu=mu, sd=sigma, observed=obs)
trace = pm.sample(1000, tune=1000)
pm.traceplot(trace)
When I check the trace
(in this case 1000 samples from the posterior probability), I notice that 2 chains are created:
>>> trace.nchains
2
I read the tutorial on PyMC3 and looked through the API but it is unclear to me what a chain represents (in this case I asked for 1000 samples from the posterior but I got 2 chains, each one with 1000 samples from the posterior).
Are the chains different runs of the sampler with the same parameters or do they have some other meaning/purpose?