📚 The CoCalc Library - books, templates and other resources
License: OTHER
Kernel: Python 3
In [1]:
Code 14.1
In [2]:
Out[2]:
0.67182846932698037
Code 14.2
In [3]:
Out[3]:
Code 14.3
In [4]:
Out[4]:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
96%|█████████▋| 4821/5000 [05:51<00:12, 13.97it/s]/home/osvaldo/Documentos/Proyectos/01_PyMC3/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 1 contains 1 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|██████████| 5000/5000 [06:03<00:00, 13.76it/s]
Code 14.4
In [5]:
Out[5]:
Code 14.5
In [6]:
Out[6]:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
95%|█████████▍| 4747/5000 [07:42<00:24, 10.45it/s]/home/osvaldo/Documentos/Proyectos/01_PyMC3/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 2 contains 1 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|█████████▉| 4999/5000 [08:00<00:00, 14.55it/s]/home/osvaldo/Documentos/Proyectos/01_PyMC3/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 0 contains 2 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|██████████| 5000/5000 [08:00<00:00, 10.41it/s]
In [7]:
Out[7]:
Code 14.6
In [8]:
Code 14.7
In [9]:
Out[9]:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
96%|█████████▌| 9555/10000 [03:55<00:09, 48.19it/s] /home/osvaldo/Documentos/Proyectos/01_PyMC3/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 1 contains 189 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|█████████▉| 9996/10000 [04:04<00:00, 47.86it/s]/home/osvaldo/Documentos/Proyectos/01_PyMC3/pymc3/pymc3/step_methods/hmc/nuts.py:452: UserWarning: The acceptance probability in chain 0 does not match the target. It is 0.664707186287, but should be close to 0.8. Try to increase the number of tuning steps.
% (self._chain_id, mean_accept, target_accept))
/home/osvaldo/Documentos/Proyectos/01_PyMC3/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 0 contains 533 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|██████████| 10000/10000 [04:05<00:00, 40.81it/s]
Code 14.8
In [10]:
Out[10]:
Code 14.9
In [11]:
Out[11]:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
98%|█████████▊| 9816/10000 [02:19<00:02, 82.03it/s]/home/osvaldo/Documentos/Proyectos/01_PyMC3/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 1 contains 7 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|█████████▉| 9994/10000 [02:21<00:00, 82.69it/s]/home/osvaldo/Documentos/Proyectos/01_PyMC3/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 0 contains 17 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|██████████| 10000/10000 [02:21<00:00, 70.57it/s]
Code 14.10
In [12]:
Out[12]:
Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
100%|█████████▉| 9994/10000 [04:11<00:00, 53.63it/s] /home/osvaldo/Documentos/Proyectos/01_PyMC3/pymc3/pymc3/step_methods/hmc/nuts.py:452: UserWarning: The acceptance probability in chain 0 does not match the target. It is 0.658126861926, but should be close to 0.8. Try to increase the number of tuning steps.
% (self._chain_id, mean_accept, target_accept))
/home/osvaldo/Documentos/Proyectos/01_PyMC3/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 0 contains 507 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
100%|██████████| 10000/10000 [04:12<00:00, 39.66it/s]
/home/osvaldo/Documentos/Proyectos/01_PyMC3/pymc3/pymc3/step_methods/hmc/nuts.py:468: UserWarning: Chain 1 contains 19 diverging samples after tuning. If increasing `target_accept` does not help try to reparameterize.
% (self._chain_id, n_diverging))
Code 14.11-14
Stan related. As you can see above, PyMC3 deal with missing value internally if you represent the observed data using a numpy mask array. The missing/masked value are replaced with a new random variable added to the model (with name *_missing
).
In [13]:
Out[13]:
This notebook was createad on a computer x86_64 running debian stretch/sid and using:
Python 3.6.2
IPython 6.1.0
PyMC3 3.2
NumPy 1.13.3
SciPy 0.19.1
Matplotlib 2.1.0