That works:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
Multiprocess sampling (4 chains in 4 jobs)
NUTS: [mu]
Sampling 4 chains: 100%|██████████████████████████████████████████████████████| 4000/4000 [00:02<00:00, 1213.70draws/s]
The acceptance probability does not match the target. It is 0.8865605470216715, but should be close to 0.8. Try to increase the number of tuning steps.
The acceptance probability does not match the target. It is 0.8836544226015702, but should be close to 0.8. Try to increase the number of tuning steps.
Possibly related: I was trying to compare the NUTS and HamiltonianMC sampling from here with the following code:
def jointplot(ary):
"""Helper to plot everything consistently"""
sns.jointplot(*ary.T, alpha=0.1, stat_func=None, xlim=(-1.2, 1.2), ylim=(-1.2, 1.2))
def tt_donut_pdf(scale):
"""Compare to `donut_pdf`"""
def logp(x):
return -tt.square((1 - x.norm(2)) / scale)
return logp
@sampled
def donut(scale=0.1, **observed):
"""Gets samples from the donut pdf, and allows adjusting the scale of the donut at sample time."""
pm.DensityDist('donut', logp=tt_donut_pdf(scale), shape=2, testval=[0, 1])
with donut(scale=0.1):
hamiltonianmc_sample1 = pm.sample(draws=100, init=None, step=pm.HamiltonianMC())
nuts_sample1 = pm.sample(draws=100, init=None, step=pm.NUTS())
jointplot(hamiltonianmc_sample1.get_values('donut'))
jointplot(nuts_sample1.get_values('donut'))
But I get this error:
AttributeError: Can't pickle local object 'tt_donut_pdf.<locals>.logp'
Are these two problems possibly related? Thanks!