 # Insights from Dynamic HMC animation

Could anyone share their opinion on what insights could be gain from this Dyanmic HMC from Mulivariate Gaussian animation by @betanalpha? I am adding some questions but I look forward to any general comments.

1. Is this algorithm NUTS? If so, which algorithm (1 to 6 from this paper) would it be?

From the animation, the number of steps change, which could be observed in NUTS. Also it runs forwards and backwards.

1. How are the new initial points selected at every iteration (in 19s and 28s)?

2. any possible explanation on how underlying distribution is affecting the sampling results? For example, balanced direction changes due to symmetry in gaussian.

This slide from @avehtari summarizes HMC nicely.

1. Algorithm 2 = Algorithm 3 except later will be more efficient. Algorithm 2/3 + Algorithm 4 + … = Algorithm 6. And since this video just shows the sampling phase, you don’t know if some sampler parameter is given by hand or algorithm so it may be 2, 3, 6.

2. This is described detailly by your cited paper.

3. You may be interested in this demo:

https://chi-feng.github.io/mcmc-demo/app.html?algorithm=HamiltonianMC&target=banana

which run multiple samplers on different target distributions.

@hyunji.moon The trajectories created in this video are actual trajectories created by the dynamic Hamiltonian Monte Carlo algorithm in Stan*. In particular the Stan implementation has evolved quite a bit since the original No-U-Turn sampler paper.
The best way to think about the algorithm is in two stages – first sampling a numerical trajectory that contains the initial point and then sampling a new point within that trajectory based on the local error in the Hamiltonian function. See also the accompanying video that shows divergent trajectories https://www.youtube.com/watch?v=1TKhH81k7QA.

For many more details see https://arxiv.org/abs/1701.02434, especially the appendix which includes detailed proofs for the invariance of the target distribution.

*Technically these trajectories are from a slightly older version of Stan before we added in more termination checks to avoid unnecessarily long trajectories, such as the few seen in the video. In the current version of Stan all of the trajectories will be approximately the same size for a normal target density function.

2 Likes