Each chain follows the Langevin update (14.61), x ← x + η∇ln p(x) + √(2η) ε: a gradient step uphill on ln p, which needs only the score and not the normalising constant, plus Gaussian noise that stops the chain from settling on the mode. Hundreds of independent chains are run at once, so the cloud of points shows the distribution after τ steps. Change the step size, switch the noise off, or add the Metropolis correction (MALA), and compare the cloud with the target.
Chains start at 2 ε0, ε0 ~ N(0, I). Langevin: x′ = x + ηg(x) + c√(2η)ε. MALA proposes the same move with c = 1 and accepts it with probability min{1, p(x′)q(x|x′)/p(x)q(x′|x)} (14.40), q(a|b) = N(a | b + ηg(b), 2ηI). The red path is chain 1 (first 150 steps).
code/ch14_sampling.py (langevin_run, target_logp_grad, supplementary Figures 14.S3 and 14.S4); with the same seed the chains here equal langevin_run, number for number.