📚 The CoCalc Library - books, templates and other resources
License: OTHER
Kernel: Python 3
In [1]:
In [2]:
Code 8.1
In [3]:
In [4]:
Out[4]:
Code 8.2
In [5]:
Code 8.3
In [6]:
In [7]:
Out[7]:
logp = -246.89, ||grad|| = 0.297: 100%|██████████| 36/36 [00:00<00:00, 2637.74it/s]
In [8]:
Out[8]:
{'a': array(9.222789236008568),
'bA': array(-1.94694634027834),
'bAR': array(0.39290434596134205),
'bR': array(-0.20265345713381855),
'sigma': array(0.932678798151842),
'sigma_interval__': array(-2.274371278607129)}
Code 8.5
In [9]:
In [10]:
Out[10]:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
100%|██████████| 2000/2000 [00:04<00:00, 443.47it/s]
In [11]:
Out[11]:
Code 8.7
In [12]:
Out[12]:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
100%|██████████| 2000/2000 [00:04<00:00, 486.74it/s]
In [13]:
Out[13]:
Code 8.8
In [14]:
In [15]:
Out[15]:
Code 8.9 and 8.10
In [16]:
Out[16]:
/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/matplotlib/axes/_axes.py:545: UserWarning: No labelled objects found. Use label='...' kwarg on individual plots.
warnings.warn("No labelled objects found. "
Code 8.11
In [17]:
Out[17]:
array(-246.0270687414433)
In [18]:
Out[18]:
502.10596010456385
In [19]:
Out[19]:
/Users/jlao/Documents/Github/pymc3/pymc3/stats.py:220: UserWarning: For one or more samples the posterior variance of the
log predictive densities exceeds 0.4. This could be indication of
WAIC starting to fail see http://arxiv.org/abs/1507.04544 for details
""")
WAIC_r(WAIC=469.18255290884269, WAIC_se=14.84452996430471, p_WAIC=5.0536791377056218)
Code 8.12
In [20]:
Out[20]:
Code 8.13
In [21]:
In [22]:
Out[22]:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
74%|███████▍ | 2957/4000 [00:28<00:40, 26.04it/s] /Users/jlao/Documents/Github/pymc3/pymc3/step_methods/hmc/nuts.py:460: UserWarning: Chain 1 reached the maximum tree depth. Increase max_treedepth, increase target_accept or reparameterize.
'reparameterize.' % self._chain_id)
/Users/jlao/Documents/Github/pymc3/pymc3/step_methods/hmc/nuts.py:452: UserWarning: The acceptance probability in chain 1 does not match the target. It is 0.903283426786, but should be close to 0.8. Try to increase the number of tuning steps.
% (self._chain_id, mean_accept, target_accept))
/Users/jlao/Documents/Github/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 1 contains 68 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|█████████▉| 3998/4000 [00:53<00:00, 364.78it/s]/Users/jlao/Documents/Github/pymc3/pymc3/step_methods/hmc/nuts.py:460: UserWarning: Chain 0 reached the maximum tree depth. Increase max_treedepth, increase target_accept or reparameterize.
'reparameterize.' % self._chain_id)
/Users/jlao/Documents/Github/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 0 contains 224 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|██████████| 4000/4000 [00:53<00:00, 74.63it/s]
In [23]:
Out[23]:
In [24]:
Out[24]:
{'alpha': 12.0, 'sigma': 844.0}
Code 8.14
In [25]:
Out[25]:
Code 8.15
In [26]:
In [27]:
Out[27]:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
89%|████████▉ | 1783/2000 [00:01<00:00, 1092.81it/s]/Users/jlao/Documents/Github/pymc3/pymc3/step_methods/hmc/nuts.py:452: UserWarning: The acceptance probability in chain 1 does not match the target. It is 0.561464358582, but should be close to 0.8. Try to increase the number of tuning steps.
% (self._chain_id, mean_accept, target_accept))
/Users/jlao/Documents/Github/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 1 contains 11 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|██████████| 2000/2000 [00:02<00:00, 980.17it/s]
In [28]:
Out[28]:
In [29]:
Out[29]:
Code 8.16
In [30]:
In [31]:
Out[31]:
Code 8.17
In [32]:
Code 8.18
In [33]:
In [34]:
Out[34]:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
50%|█████ | 1008/2000 [01:40<02:05, 7.91it/s]/Users/jlao/Documents/Github/pymc3/pymc3/step_methods/hmc/nuts.py:452: UserWarning: The acceptance probability in chain 1 does not match the target. It is 0.190739140179, but should be close to 0.8. Try to increase the number of tuning steps.
% (self._chain_id, mean_accept, target_accept))
/Users/jlao/Documents/Github/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 1 contains 89 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|██████████| 2000/2000 [03:37<00:00, 7.52it/s]/Users/jlao/Documents/Github/pymc3/pymc3/step_methods/hmc/nuts.py:460: UserWarning: Chain 0 reached the maximum tree depth. Increase max_treedepth, increase target_accept or reparameterize.
'reparameterize.' % self._chain_id)
In [35]:
Out[35]:
In [36]:
Out[36]:
Code 8.19
In [37]:
In [38]:
Out[38]:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
100%|██████████| 2000/2000 [00:58<00:00, 17.95it/s]/Users/jlao/Documents/Github/pymc3/pymc3/step_methods/hmc/nuts.py:452: UserWarning: The acceptance probability in chain 0 does not match the target. It is 0.900466304728, but should be close to 0.8. Try to increase the number of tuning steps.
% (self._chain_id, mean_accept, target_accept))
In [39]:
Out[39]:
In [40]:
Out[40]:
In [41]:
Out[41]:
This notebook was createad on a computer x86_64 running and using:
Python 3.5.1
IPython 6.2.1
PyMC3 3.2
NumPy 1.12.0
Pandas 0.20.2
SciPy 0.19.1
Matplotlib 2.0.2