9.1 Good King Markov and his island kingdom

Code 9.1

Code 9.2

Code 9.3

9.2 Metropolis algorithms

Code 9.4

9.3 Hamiltonian Monte Carlo

Code 9.5

Code 9.6

Code 9.8, 9.9, 9.10 (before 9.7 to define HMC2 funcition)

Code 9.7

9.4 Easy HMC: ulam

Code 9.11

Code 9.12

Code 9.13

For Turing this is not needed

Code 9.14

Code 9.15

Code 9.16

For this to use multiple cores, julia has to be started with --threads 4 parameter, otherwise chains will be sampled sequentially

Code 9.17

This shows combined chains statistics. To get information about individual chains, use m9_1[:,:,1]

Code 9.18

Code 9.19

Code 9.20

Code 9.21

9.5 Care and feeding of your Markov chain

Code 9.22

To make it diverging with Turing, was needed to increase exp() argument.

Code 9.23

Code 9.24

Code 9.25

Code 9.26

Code 9.27