Reasons behind implemented T(z), V(z), and G in hmc

While looking through this code from mcmc>hmc, I had some questions:

  1. What is the difference between T(z) and V(z) in terms of their type? Why is this -> only used for the latter in this code?

  2. What is G and why is dG/dt = 2 T(z) - <q, g> in here?
    It seems dG_dt is used only for NUTS from here.


1 Like
  1. They’re both member functions but T is defined in the same class a few lines earlier while V is defined on the base class.
    Can’t say I really understand how C++ name lookup works but says

Within the body of a non-static member function of X, any id-expression E (e.g. an identifier) that resolves to a non-type non-static member of X or of a base class of X, is transformed to a member access expression (*this).E (unless it’s already a part of a member access expression). This does not occur in template definition context, so a name may have to be prefixed with this-> explicitly to become dependent.

(Emphasis added) diag_e_metric is a template so I guess that’s why it can’t find V.

  1. G is the virial and it’s used by XHMC (currently not exposed in the interfaces). See this paper for more information about Exhaustive Hamiltonian Monte Carlo.