Introduction
Markov chain Monte Carlo (MCMC) [10 ] is a cornerstone of modern Bayesian analysis when the target posterior density is not analytically computable. In recent years, gradient-based MCMC methods have risen in popularity, mainly due to the target-informed proposals. Several of these algorithms are based on numerically integrated Hamiltonian flows. Such flows are naturally incorporated in the MCMC framework as they have the ability to preserve a desired target distribution after an appropriate Metropolis correction. Thus, a range of applications in fields like theoretical physics, molecular simulations and Bayesian statistics have adopted these methods. Examples of prominent algorithms in this family include kinetic/second-order/underdamped Langevin algorithms [22 , 9 ] , which include generalized Hamiltonian Monte Carlo [19 ] , standard Hamiltonian/Hybrid Monte Carlo [25 , 27 ] (Duane et al. 1987) and highly specialized Bayesian inference MCMC algorithms based on the former with the No-U-Turn sampler (NUTS) [17 ] as the prominent example.
The methods above typically require some sort of numerical integration to approximate the Hamiltonian flow. To this end, the Verlet/Størmer leapfrog integrator is typically used in conjunction with fixed (time) step sizes to guarantee time reversibility of the numerically integrated flow. However, to ensure a successful and efficient numerical integration procedure, the fixed step sizes must be tailored explicitly to each particular target distribution. Usually, the step size is chosen so that the numerically approximated flow is accurate enough even in the parts of the support where the logarithm of the target density has the largest curvature. Consequently, the parts of the support with more moderate curvature will be traversed using unnecessarily small step sizes, which in turn leads to wasted computational effort. In contrast, if the fixed step sizes are too large, this may lead to very slow exploration of the higher curvature regions, as stability limits may be breached for almost all simulated trajectories and subsequently lead to divergent transitions [31 ] .
Adaptive step sizes for the numerical integration of ordinary differential equations are ubiquitous in resolving the weaknesses mentioned in the preceding paragraph (see e.g., Hairer et al., 1993). Nevertheless, the naive use of such step size controllers to Hamiltonian involution flows obtained by numerical integrators would generally lead to the loss of both reversibility/involutional nature and the volume preservation property. With numerical flows no longer being involutions, it is not clear how to proceed with Metropolis-correcting for incurred numerical errors (even if the Jacobian determinant of the numerical flow is available). Kleppe [21 ] considers uncorrected MCMC based on Hamiltonian dynamics integrated using such conventional step size controllers. This approach may lead to competitive performance for challenging target distributions and numerical results indicate only minor biases relative to the overall Monte Carlo variation. However, it appears very difficult to quantify the incurred biases a priori.
Building on the adaptive step size mechanism of the recently proposed WALNUTS sampler [6 ] , this paper considers adaptive step sizes for Hamiltonian flow-based MCMC while at the same time retaining reversibility/correctness. The first contribution involves both a more detailed description and further extensions to the basic energy error-based algorithm of Bou-Rabee et al. [6 ] by leveraging insights from the numerical ODE literature.
More concretely, the adaptive step size algorithm of Bou-Rabee et al. [6 ] proceeds by dividing the desired numerically approximated Hamiltonian flow into a sequence of macro steps with fixed (time-) step size. Each macro step is traversed by a varying (integer) number of micro steps. The number of micro steps in each macro step is determined to ensure sufficient accuracy and therefore provides the desired adaptivity.
However, to ensure reversibility, the ideal procedure for determining the number of micro steps in each macro step should be such that the same number of micro steps would be chosen regardless of whether the integration happens forward or backward in time. Such exact reversibility is in general not feasible and/or not computationally efficient. To account for such imperfect reversibility, macro steps that fail to be reversible must either be rejected or the corresponding micro step numbers must be randomized (see also Bou-Rabee et al., [5 ] ). In both cases, this will impact the performance of the overall algorithm. To reduce the frequency of such reversibility breaches, the present paper describes further procedures to select the number of micro steps in each macro step beyond the energy error-based criterion of Bou-Rabee et al. [5 , 6 ] .
A further contribution of the paper is a detailed description of how such adaptive step size mechanisms may also be incorporated in other Hamiltonian flow-based MCMC algorithms beyond WALNUTS. Like for WALNUTS, the recently proposed Gibbs Self-tuning (GIST) framework of Bou-Rabee et al. [7 ] is utilized to this end. More specifically, it is demonstrated that these alternative adaptive step size methods can be formulated as a GIST sampler. Consequently, the corresponding transition kernel will be reversible with respect to the target distribution, thus ensuring the correctness of the methods.
A key finding of this paper is that the benefit of the proposed alternative micro step controllers depends strongly on the overarching Hamiltonian flow-based MCMC it is used within. Potentially larger benefits are observed for Hamiltonian flow-based MCMC methods where the complete proposal must be discarded if a reversibility failure occurs.
The remainder of this paper is laid out as follows: § 2 provides the background on HMC, GIST and the macro/micro locally adaptive step sizes of Bou-Rabee et al. [6 ] . § 3 introduces and compares different error measures under the framework of locally adaptive step size selection with the aim of reducing reversibility failures. § 4 explains how to include locally adaptive step sizes within other Hamiltonian flow-based MCMC methods beyond WALNUTS. Finally, § 5 provides numerical illustrations and § 6 concludes with a discussion. Source code for the implementations and numerical experiments is available at https://github.com/jihut/locally_adaptive_step_size_hmc .
Background and setup
The main goal is to sample from a given target distribution characterized by a probability density function (PDF) π ( θ ) : = π ~ ( θ ) / Z \pi(\theta) := \widetilde{\pi}(\theta)/Z π ( θ ) := π ( θ ) / Z , θ ∈ R d \theta\in\mathbb{R}^{d} θ ∈ R d . Here, 1 / Z 1/Z 1/ Z represents the unknown normalizing constant while π ~ ( θ ) \widetilde{\pi}(\theta) π ( θ ) is a density kernel of the PDF that can be evaluated pointwise.
Standard Hamiltonian Monte Carlo
The idea of the standard HMC method is to extend the state space R d \mathbb{R}^{d} R d to the phase space R 2 d \mathbb{R}^{2d} R 2 d by introducing an auxiliary momentum variable ρ ∈ R d \rho\in\mathbb{R}^{d} ρ ∈ R d so that z = ( θ , ρ ) ∈ R 2 d z = (\theta,\rho) \in\mathbb{R}^{2d} z = ( θ , ρ ) ∈ R 2 d . Furthermore, let M ∈ R d × d M \in\mathbb{R}^{d \times d} M ∈ R d × d be a symmetric and positive definite mass matrix. An ideal HMC method proceeds by constructing a Markov chain using proposals obtained by evolving the Hamiltonian system using the Hamiltonian flow φ t \varphi_t φ t given as φ t ( z ( τ ) ) : = z ( τ + t ) \varphi_t(z(\tau)) := z(\tau+ t) φ t ( z ( τ )) := z ( τ + t ) . This flow preserves the joint density μ ( θ , ρ ) ∝ exp ( − H ( θ , ρ ) ) \mu(\theta,\rho) \propto\exp(-H(\theta,\rho)) μ ( θ , ρ ) ∝ exp ( − H ( θ , ρ )) , which is also commonly known as the density of the Boltzmann-Gibbs distribution. Here, H H H simply denotes the Hamiltonian of the system at a given state z z z :
H ( z ) = H ( θ , ρ ) : = − log π ~ ( θ ) + 1 2 ρ T M − 1 ρ H(z) = H(\theta,\rho) := -\log\widetilde{\pi}(\theta) + \frac{1}{2}\rho^{T}M^{-1}\rho H ( z ) = H ( θ , ρ ) := − log π ( θ ) + 2 1 ρ T M − 1 ρ
The evolution of the state in time, and hence related to the flow φ t \varphi_t φ t , is obtained from solving Hamilton’s equations:
θ ˙ ( t ) = M − 1 ρ ( t ) , (1) \dot{\theta}(t) = M^{-1}\rho(t), \tag*{(1)} θ ˙ ( t ) = M − 1 ρ ( t ) , (1)
ρ ˙ ( t ) = ∇ θ log π ~ ( θ ( t ) ) (2) \dot{\rho}(t) = \nabla_{\theta}\log\widetilde{\pi}(\theta(t)) \tag*{(2)} ρ ˙ ( t ) = ∇ θ log π ( θ ( t )) (2)
As Equations (1) and (2) are not analytically solvable in most cases, the flow must be approximated numerically using a numerical integrator. The standard choice of such an integrator is the (Verlet/Størmer) leapfrog integrator (see e.g., Leimkuhler and Reich, [23 ] ; Bou-Rabee and Sanz-Serna, [4 ] ) as it preserves several key traits of the true Hamiltonian flow that are required to construct a simple but reversible Markov chain based on these proposals. More specifically, assume a current initial state in the phase space simply denoted as z = ( θ , ρ ) z=(\theta,\rho) z = ( θ , ρ ) . Then, given a fixed step size h > 0 h>0 h > 0 , the leapfrog integrator Φ h \Phi_h Φ h evolves the system by h h h time units from z z z to z ′ = Φ h ( z ) z'=\Phi_h(z) z ′ = Φ h ( z ) in the following way:
θ ′ = θ + M − 1 ( h ρ + h 2 2 ∇ θ log π ~ ( θ ) ) , (3) \theta'=\theta+M^{-1}\left(h\rho+\frac{h^2}{2}\nabla_\theta\log\widetilde{\pi}(\theta)\right), \tag*{(3)} θ ′ = θ + M − 1 ( h ρ + 2 h 2 ∇ θ log π ( θ ) ) , (3)
ρ ′ = ρ + h 2 ( ∇ θ log π ~ ( θ ) + ∇ θ log π ~ ( θ ′ ) ) (4) \rho'=\rho+\frac{h}{2}\left(\nabla_\theta\log\widetilde{\pi}(\theta)+\nabla_\theta\log\widetilde{\pi}(\theta')\right) \tag*{(4)} ρ ′ = ρ + 2 h ( ∇ θ log π ( θ ) + ∇ θ log π ( θ ′ ) ) (4)
Some of the most important properties that the leapfrog integrator has in common with φ t \varphi_t φ t are:
Time reversibility: Let F \mathcal{F} F denote the momentum flip operator, i.e., F ( z ) = ( θ , − ρ ) \mathcal{F}(z)=(\theta,-\rho) F ( z ) = ( θ , − ρ ) . Then, the inverse map can be expressed as
Φ h − 1 = F ∘ Φ h ∘ F . (5) \Phi_h^{-1}=\mathcal{F}\circ\Phi_h\circ\mathcal{F}. \tag*{(5)} Φ h − 1 = F ∘ Φ h ∘ F . (5)
Based on this fact, the map F ∘ Φ h \mathcal{F}\circ\Phi_h F ∘ Φ h is therefore an involution, i.e., the inverse of this map is itself.
By extending to a situation where one evolves the initial state by L ∈ Z L\in\mathbb{Z} L ∈ Z leapfrog steps, it is convenient to denote this composition of maps as Φ h L \Phi_h^L Φ h L . Then, one can express the map recursively based on the definition of the single leapfrog map as
Φ h L + 1 : = Φ h ∘ Φ h L , Φ h L − 1 : = Φ h − 1 ∘ Φ h L . \Phi_h^{L+1}:=\Phi_h\circ\Phi_h^L,\qquad\Phi_h^{L-1}:=\Phi_h^{-1}\circ\Phi_h^L. Φ h L + 1 := Φ h ∘ Φ h L , Φ h L − 1 := Φ h − 1 ∘ Φ h L .
This notation makes it possible to take both L > 0 L>0 L > 0 leapfrog steps forward in time and L < 0 L<0 L < 0 steps backward, which is useful when defining the more sophisticated HMC-like samplers later in the text. Given that the step size h h h is fixed, the map Φ h L \Phi_h^L Φ h L will also inherit the property of time reversibility.
Based on the properties of the leapfrog integrator, a simple Markov kernel that is μ \mu μ -invariant and uses proposals from the Hamiltonian system can be defined by employing the involution-based Metropolis-Hastings-Green algorithm (Green, [13 ] ) in the following way:
Momentum refresh: Sample ρ ∼ N ( 0 , M ) \rho\sim N(0,M) ρ ∼ N ( 0 , M ) .
Given ρ \rho ρ and the previous position state θ \theta θ , evolve this state by L L L leapfrog steps so that ( θ ′ , ρ ′ ) = Φ h L ( θ , ρ ) (\theta',\rho')=\Phi_h^L(\theta,\rho) ( θ ′ , ρ ′ ) = Φ h L ( θ , ρ ) .
Although not necessary for a situation with full momentum refresh after every iteration like in the standard HMC setting currently considered, the Metropolis-Hastings-Green algorithm requires that the deterministic map that leads to the proposed state is an involution. Thus, based on (5) , the relevant proposed state is
z ∗ = ( θ ′ , − ρ ′ ) . z^* = (\theta', -\rho'). z ∗ = ( θ ′ , − ρ ′ ) .
Using the volume preservation property, the acceptance probability given by the Metropolis-Hastings-Green algorithm simply becomes
α ( z , z ∗ ) : = min ( 1 , exp ( H ( z ) − H ( z ∗ ) ) ) . \alpha(z,z^*) := \min\left(1,\exp(H(z)-H(z^*))\right). α ( z , z ∗ ) := min ( 1 , exp ( H ( z ) − H ( z ∗ )) ) .
Then, the new proposed state z ∗ z^* z ∗ is accepted if u < α ( z , z ∗ ) u < \alpha(z,z^*) u < α ( z , z ∗ ) and rejected otherwise, where u ∼ Uniform [ 0 , 1 ] u \sim\operatorname{Uniform}[0,1] u ∼ Uniform [ 0 , 1 ] .
The above constitutes the standard HMC sampler and will be the foundation of the more elaborate samplers later.
For the standard HMC setup, it is crucial that the step size h h h is fixed for the L L L leapfrog steps that are performed (or more generally, at least the array consisting of the corresponding step sizes at each leapfrog step should be palindromic) in order to obtain a valid proposal. Otherwise, the time reversibility of Φ h L \Phi_h^L Φ h L will be violated and the map F ∘ Φ h L \mathcal{F} \circ\Phi_h^L F ∘ Φ h L is not an involution so that the involution-based Metropolis-Hastings-Green algorithm is no longer valid.
In particular, suppose h = γ ( θ , ρ ) h = \gamma(\theta,\rho) h = γ ( θ , ρ ) is some non-trivial step size selection mechanism, and let Φ ^ ( θ , ρ ) = Φ γ ( θ , ρ ) ( θ , ρ ) \widehat{\Phi}(\theta,\rho) = \Phi_{\gamma(\theta,\rho)}(\theta,\rho) Φ ( θ , ρ ) = Φ γ ( θ , ρ ) ( θ , ρ ) . For a given ( θ , ρ ) (\theta,\rho) ( θ , ρ ) , denote ( θ ′ , ρ ′ ) = Φ ^ ( θ , ρ ) (\theta',\rho') = \widehat{\Phi}(\theta,\rho) ( θ ′ , ρ ′ ) = Φ ( θ , ρ ) . Note that for F ∘ Φ ^ \mathcal{F} \circ\widehat{\Phi} F ∘ Φ to be an involution, one would require that γ ( θ , ρ ) = γ ( θ ′ , − ρ ′ ) \gamma(\theta,\rho) = \gamma(\theta',-\rho') γ ( θ , ρ ) = γ ( θ ′ , − ρ ′ ) , i.e., a reversible step size controller, which to the authors’ current knowledge is not readily available. To avoid these problems, one can proceed by representing the step sizes themselves as additional auxiliary random variables, which is the core idea of the GIST framework.
HMC-based GIST basics
In the context of Hamiltonian flow-based proposals, a GIST sampler (see Bou-Rabee et al. [7 ] for a more detailed and rigorous description) is a (Metropolized) Gibbs sampler targeting an enlarged space consisting of ( θ , ρ ) (\theta,\rho) ( θ , ρ ) and the tuning parameters used for determining the Hamiltonian flow. Specifically, denote v ∈ V v \in\mathbb{V} v ∈ V as the collection of auxiliary/tuning parameters for the flow step (e.g., the number of leapfrog steps, step sizes, mass matrices, etc.), and suppose that a tuning parameter distribution p ( v ∣ θ , ρ ) p(v|\theta,\rho) p ( v ∣ θ , ρ ) has been selected. Then, the GIST sampler proceeds to target the joint density μ ( θ , ρ , v ) ∝ exp ( − H ( θ , ρ ) ) p ( v ∣ θ , ρ ) \mu(\theta,\rho,v) \propto\exp(-H(\theta,\rho))p(v|\theta,\rho) μ ( θ , ρ , v ) ∝ exp ( − H ( θ , ρ )) p ( v ∣ θ , ρ ) on the augmented space A = R 2 d × V \mathcal{A} = \mathbb{R}^{2d} \times\mathbb{V} A = R 2 d × V .
The final ingredient of a GIST specification is a mapping of the form
( θ ′ , ρ ′ , v ′ ) = ( F ∘ G v ( θ , ρ ) , g θ , ρ ( v ) ) , (6) (\theta',\rho',v') = \left(\mathcal{F} \circ G_v(\theta,\rho),g_{\theta,\rho}(v)\right), \tag*{(6)} ( θ ′ , ρ ′ , v ′ ) = ( F ∘ G v ( θ , ρ ) , g θ , ρ ( v ) ) , (6)
where G v G_v G v is a numerically integrated Hamiltonian flow with tuning parameters v v v and g θ , ρ g_{\theta,\rho} g θ , ρ is a “parameter mapping.” Throughout the text, V \mathbb{V} V is a countable set (which corresponds to a set of vectors of micro step counts in this paper), and the reference measure on the augmented space A = R 2 d × V \mathcal{A} = \mathbb{R}^{2d} \times\mathcal{V} A = R 2 d × V is the product measure
ν : = Leb 2 d ⊗ # V , \nu:= \operatorname{Leb}_{2d} \otimes\#_{\mathcal{V}}, ν := Leb 2 d ⊗ # V ,
where Leb 2 d \operatorname{Leb}_{2d} Leb 2 d denotes the Lebesgue measure on R 2 d \mathbb{R}^{2d} R 2 d and # V \#_{\mathcal{V}} # V the counting measure on V \mathcal{V} V . For each ( θ , ρ ) (\theta,\rho) ( θ , ρ ) , p ( ⋅ ∣ θ , ρ ) p(\cdot\mid\theta,\rho) p ( ⋅ ∣ θ , ρ ) is a probability mass function on V \mathcal{V} V , and μ ( θ , ρ , v ) \mu(\theta,\rho,v) μ ( θ , ρ , v ) is a probability density with respect to ν \nu ν . The complete mapping in (6) must be a ν \nu ν -preserving involution of A \mathcal{A} A . In particular, it must satisfy
F ∘ G g ( θ , ρ ) ( v ) ∘ F ∘ G v ( θ , ρ ) = ( θ , ρ ) , \mathcal{F} \circ\mathcal{G}_{g(\theta,\rho)(v)} \circ\mathcal{F} \circ\mathcal{G}_{v}(\theta,\rho) = (\theta,\rho), F ∘ G g ( θ , ρ ) ( v ) ∘ F ∘ G v ( θ , ρ ) = ( θ , ρ ) ,
g F ∘ G v ( θ , ρ ) ( g ( θ , ρ ) ( v ) ) = v . g_{\mathcal{F}\circ\mathcal{G}_{v}(\theta,\rho)}\left(g_{(\theta,\rho)}(v)\right) = v. g F ∘ G v ( θ , ρ ) ( g ( θ , ρ ) ( v ) ) = v .
If the complete mapping in (6) is not reference-measure preserving, the corresponding Radon–Nikodym derivative must instead be included in the Metropolis-Hastings acceptance probability. A sufficient condition for ν \nu ν -preservation, which covers every construction in this paper, is that the parameter mapping does not depend on the state, i.e., g ( θ , ρ ) = g g_{(\theta,\rho)} = g g ( θ , ρ ) = g for a bijection g g g of V \mathcal{V} V , and that for every fixed v v v , the map G v \mathcal{G}_{v} G v is a volume preserving bijection of R 2 d \mathbb{R}^{2d} R 2 d . Indeed, writing Ψ ( θ , ρ , v ) : = ( ( F ∘ G v ) ( θ , ρ ) , g ( v ) ) \Psi(\theta,\rho,v) := ((\mathcal{F} \circ\mathcal{G}_{v})(\theta,\rho),g(v)) Ψ ( θ , ρ , v ) := (( F ∘ G v ) ( θ , ρ ) , g ( v )) , one has Ψ − 1 ( A × { v ′ } ) = { ( θ , ρ , g − 1 ( v ′ ) ) : ( F ∘ G g − 1 ( v ′ ) ) ( θ , ρ ) ∈ A } \Psi^{-1}(A \times\{v'\}) = \{(\theta,\rho,g^{-1}(v')) : (\mathcal{F} \circ\mathcal{G}_{g^{-1}(v')})(\theta,\rho) \in A\} Ψ − 1 ( A × { v ′ }) = {( θ , ρ , g − 1 ( v ′ )) : ( F ∘ G g − 1 ( v ′ ) ) ( θ , ρ ) ∈ A } for every measurable A ⊂ R 2 d A \subset\mathbb{R}^{2d} A ⊂ R 2 d and v ′ ∈ V v' \in\mathcal{V} v ′ ∈ V , and this set has ν \nu ν -measure Leb 2 d ( A ) \operatorname{Leb}_{2d}(A) Leb 2 d ( A ) . When the macro step size is randomized (like in § 4 ), the step size vector is included in v v v , V \mathcal{V} V becomes the product of a countable set and a Euclidean space, and # V \#_{\mathcal{V}} # V is replaced by the product of counting and Lebesgue measure while nothing else changes.
An instructive non-trivial example of such a joint mapping would be two leapfrog steps with individual step sizes, i.e., v = ( h 1 , h 2 ) v = (h_1,h_2) v = ( h 1 , h 2 ) , G v = Φ h 2 ∘ Φ h 1 \mathcal{G}_{v} = \Phi_{h_2} \circ\Phi_{h_1} G v = Φ h 2 ∘ Φ h 1 and g ( θ , ρ ) ( h 1 , h 2 ) = ( h 2 , h 1 ) g_{(\theta,\rho)}(h_1,h_2) = (h_2,h_1) g ( θ , ρ ) ( h 1 , h 2 ) = ( h 2 , h 1 ) (so the order of the step size array is reversed). Then, it is straightforward to verify that (6) is an involution as F ∘ G g ( θ , ρ ) ( v ) ∘ F ∘ G v ( θ , ρ ) = F ∘ Φ h 1 ∘ Φ h 2 ∘ F ∘ Φ h 2 ∘ Φ h 1 ( θ , ρ ) = ( θ , ρ ) \mathcal{F} \circ\mathcal{G}_{g_{(\theta,\rho)}(v)} \circ\mathcal{F} \circ\mathcal{G}_{v}(\theta,\rho) = \mathcal{F} \circ\Phi_{h_1} \circ\Phi_{h_2} \circ\mathcal{F} \circ\Phi_{h_2} \circ\Phi_{h_1}(\theta,\rho) = (\theta,\rho) F ∘ G g ( θ , ρ ) ( v ) ∘ F ∘ G v ( θ , ρ ) = F ∘ Φ h 1 ∘ Φ h 2 ∘ F ∘ Φ h 2 ∘ Φ h 1 ( θ , ρ ) = ( θ , ρ ) and g F ∘ G v ( θ , ρ ) ∘ g ( θ , ρ ) = id g_{\mathcal{F}\circ\mathcal{G}_{v}(\theta,\rho)} \circ g_{(\theta,\rho)} = \operatorname{id} g F ∘ G v ( θ , ρ ) ∘ g ( θ , ρ ) = id , since g g g does not depend on the state and reverses the order twice.
Provided that the above elements are specified, a GIST sampler would perform the following steps:
(Partial) momentum refresh that preserves ρ ∼ N ( 0 , M ) \rho\sim\mathcal{N}(0,M) ρ ∼ N ( 0 , M ) .
Update the auxiliary parameters by v ∼ p ( ⋅ ∣ θ , ρ ) v \sim p(\cdot\mid\theta,\rho) v ∼ p ( ⋅ ∣ θ , ρ ) .
Compute the Metropolis-Hastings-Green (MHG) involution proposal (6) .
Accept ( ( θ ′ , ρ ′ ) , v ′ ) ((\theta',\rho'),v') (( θ ′ , ρ ′ ) , v ′ ) with probability
min ( 1 , exp ( H ( θ , ρ ) − H ( θ ′ , ρ ′ ) ) p ( v ′ ∣ θ ′ , ρ ′ ) p ( v ∣ θ , ρ ) ) . (7) \min\left(1,\exp(H(\theta,\rho)-H(\theta',\rho'))\frac{p(v'\mid\theta',\rho')}{p(v\mid\theta,\rho)}\right). \tag*{(7)} min ( 1 , exp ( H ( θ , ρ ) − H ( θ ′ , ρ ′ )) p ( v ∣ θ , ρ ) p ( v ′ ∣ θ ′ , ρ ′ ) ) . (7)
Otherwise, keep ( ( θ , ρ ) , v ) ((\theta,\rho),v) (( θ , ρ ) , v ) . In either case, v v v is then discarded.
The momentum refresh in the first step preserves the phase-space target proportional to exp ( − H ) \exp(-H) exp ( − H ) . Consequently, if ( θ , ρ ) (\theta,\rho) ( θ , ρ ) has this distribution, then sampling v ∼ p ( ⋅ ∣ θ , ρ ) v \sim p(\cdot\mid\theta,\rho) v ∼ p ( ⋅ ∣ θ , ρ ) gives ( θ , ρ , v ) (\theta,\rho,v) ( θ , ρ , v ) the augmented target density μ ( θ , ρ , v ) \mu(\theta,\rho,v) μ ( θ , ρ , v ) . The Metropolis–Hastings step in steps 3–4 preserves this augmented target. Finally, discarding v v v after the accept–reject step recovers the correct phase-space marginal.
The standard HMC method above clearly fits within the above GIST framework (with V being a singleton), as does the (time-discretized) randomized HMC [3 ] , where the number of integration steps v = L v = L v = L has some distribution p ( L ) p(L) p ( L ) on the positive integers that is independent of ( θ , ρ ) (\theta,\rho) ( θ , ρ ) (and g g g is the identity).
Locally adaptive step size for standard Hamiltonian Monte Carlo
The GIST framework [7 ] provides a recipe for incorporating locally adaptive step size procedure. Consequently, this work follows Bou-Rabee et al. [6 ] in introducing the concepts of macro and micro steps and correcting for reversibility failures in the step size controller using the GIST Metropolis correction.
For the standard HMC algorithm, one would perform a fixed number L > 0 L > 0 L > 0 of macro steps. Each of these steps will correspond to an evolution of the system by a macro step size h h h , which will now be fixed so that the integration time from the initial state to the final state is identical in each iteration. For convenience, define also the uniform time grid as t j : = j h t_j := jh t j := j h , j ∈ Z j \in\mathbb{Z} j ∈ Z . This definition is rather general and useful for more elaborate samplers where one might perform both backward and forward integration steps. For the standard HMC, it is sufficient to assume that j ∈ N 0 j \in\mathbb{N}_0 j ∈ N 0 .
Within the macro step between t j t_j t j and t j + 1 t_{j+1} t j + 1 , one performs l j , j + 1 ∈ N l_{j,j+1} \in\mathbb{N} l j , j + 1 ∈ N micro (leapfrog) steps, each with step size h j , j + 1 l j , j + 1 − 1 h_{j,j+1}^{l_{j,j+1}^{-1}} h j , j + 1 l j , j + 1 − 1 . The leapfrog map evolving the system from time t j t_j t j to t j + 1 t_{j+1} t j + 1 is simply given as Φ h j , j + 1 l j , j + 1 − 1 l j , j + 1 \Phi_{h_{j,j+1}^{l_{j,j+1}^{-1}}}^{l_{j,j+1}} Φ h j , j + 1 l j , j + 1 − 1 l j , j + 1 and inherits the time reversibility property (conditionally on l j , j + 1 l_{j,j+1} l j , j + 1 ). See Figure 6 of Bou-Rabee et al. [6 ] for an illustration of the macro/micro step distinction.
Composing L L L such macro steps leads to the ( θ , ρ ) (\theta,\rho) ( θ , ρ ) -proposal Φ L , 0 ∣ l \Phi_{L,0 \mid\mathbf{l}} Φ L , 0 ∣ l
Φ L , 0 ∣ l : = { Φ h L − 1 , L l L − 1 , L − 1 L − 1 , L ∘ ⋯ ∘ Φ h 0 , 1 l 0 , 1 − 1 0 , 1 , if L > 0 , F ∘ Φ h L , L + 1 l L , L + 1 − 1 L , L + 1 ∘ ⋯ ∘ Φ h − 1 , 0 l − 1 , 0 − 1 − 1 , 0 ∘ F , if L < 0 , \Phi_{L,0 \mid\mathbf{l}} :=
\begin{cases}
\Phi_{h_{L-1,L}^{l_{L-1,L}^{-1}}}^{L-1,L} \circ\cdots\circ\Phi_{h_{0,1}^{l_{0,1}^{-1}}}^{0,1}, & \text{if } L > 0, \\
\mathcal{F} \circ\Phi_{h_{L,L+1}^{l_{L,L+1}^{-1}}}^{L,L+1} \circ\cdots\circ\Phi_{h_{-1,0}^{l_{-1,0}^{-1}}}^{-1,0} \circ\mathcal{F}, & \text{if } L < 0,
\end{cases} Φ L , 0 ∣ l := ⎩ ⎨ ⎧ Φ h L − 1 , L l L − 1 , L − 1 L − 1 , L ∘ ⋯ ∘ Φ h 0 , 1 l 0 , 1 − 1 0 , 1 , F ∘ Φ h L , L + 1 l L , L + 1 − 1 L , L + 1 ∘ ⋯ ∘ Φ h − 1 , 0 l − 1 , 0 − 1 − 1 , 0 ∘ F , if L > 0 , if L < 0 ,
where l \mathbf{l} l is a vector containing all the micro step size counts l j , j + 1 l_{j,j+1} l j , j + 1 such that ( l ) j = l j − 1 , j (\mathbf{l})_j = l_{j-1,j} ( l ) j = l j − 1 , j , j = 1 , … , L j = 1,\ldots,L j = 1 , … , L , for L ≥ 1 L \ge1 L ≥ 1 . A similar definition is also available for L ≤ − 1 L \le-1 L ≤ − 1 by letting ( l ) − j = l j , j + 1 (\mathbf{l})_{-j} = l_{j,j+1} ( l ) − j = l j , j + 1 , j = L , … , − 1 j = L,\ldots,-1 j = L , … , − 1 . For L = 0 L = 0 L = 0 , which may occur when L L L is randomized, Φ 0 , 0 ∣ l \Phi_{0,0 \mid\mathbf{l}} Φ 0 , 0 ∣ l is the identity map and l \mathbf{l} l is empty. Note that F ∘ Φ L , 0 ∣ l \mathcal{F} \circ\Phi_{L,0 \mid\mathbf{l}} F ∘ Φ L , 0 ∣ l itself is generally not an involution (unless l \mathbf{l} l happens to be palindromic).
The failure to be an involution may still be resolved by embedding this construction into the GIST framework. More specifically, let the collection of auxiliary parameters be v = l v = \mathbf{l} v = l and G 1 = Φ L , 0 ∣ l G_1 = \Phi_{L,0 \mid\mathbf{l}} G 1 = Φ L , 0 ∣ l . Furthermore, by choosing the parameter mapping g ( θ , ρ ) ( l ) = R ( l ) g_{(\theta,\rho)}(l)=\mathcal{R}(l) g ( θ , ρ ) ( l ) = R ( l ) , where R \mathcal{R} R reverses the order of the argument, it is clear that
( θ ′ , ρ ′ , l ′ ) = ( F ∘ Φ L , 0 ∣ l ( θ , ρ ) , R ( l ) ) (8) (\theta',\rho',l')=(\mathcal{F}\circ\Phi_{L,0}\mid l(\theta,\rho),\mathcal{R}(l)) \tag*{(8)} ( θ ′ , ρ ′ , l ′ ) = ( F ∘ Φ L , 0 ∣ l ( θ , ρ ) , R ( l )) (8)
is a volume-preserving involution which may be used within the Metropolis-Hastings-Green framework.
To complete the GIST sampler, it is required to specify the parameter distribution p ( l ∣ θ , ρ ) p(l\mid\theta,\rho) p ( l ∣ θ , ρ ) . This distribution should reflect the main objective of adapting the step sizes locally, i.e., choosing the largest leapfrog step size possible such that a given criterion related to the error in the flow approximation is below a prescribed threshold. In practice, p ( l ∣ θ , ρ ) p(l\mid\theta,\rho) p ( l ∣ θ , ρ ) is constructed in a sequential manner as
p ( l ∣ θ , ρ ) = ∏ j = 1 L p ( l j − 1 , j ∣ θ j − 1 , ρ j − 1 ) , (9) p(l\mid\theta,\rho)=\prod_{j=1}^{L}p(l_{j-1,j}\mid\theta_{j-1},\rho_{j-1}), \tag*{(9)} p ( l ∣ θ , ρ ) = j = 1 ∏ L p ( l j − 1 , j ∣ θ j − 1 , ρ j − 1 ) , (9)
where ( θ 0 , ρ 0 ) = ( θ , ρ ) (\theta_0,\rho_0)=(\theta,\rho) ( θ 0 , ρ 0 ) = ( θ , ρ ) , ( θ j , ρ j ) = Φ j , 0 ∣ ( l 0 , 1 , … , l j − 1 , j ) ( θ , ρ ) (\theta_j,\rho_j)=\Phi_{j,0}\mid_{(l_{0,1},\ldots,l_{j-1,j})}(\theta,\rho) ( θ j , ρ j ) = Φ j , 0 ∣ ( l 0 , 1 , … , l j − 1 , j ) ( θ , ρ ) , j = 1 , … , L j=1,\ldots,L j = 1 , … , L (and ( θ L , ρ L ) = ( θ ′ , ρ ′ ) (\theta_L,\rho_L)=(\theta',\rho') ( θ L , ρ L ) = ( θ ′ , ρ ′ ) ). Note that the same single macro step law p ( l ∣ θ , ρ ) p(l\mid\theta,\rho) p ( l ∣ θ , ρ ) appears in every factor of (9) . This time-homogeneity property is what makes the ratio in (10) below factorize over the macro steps.
The exact specifications of the distribution of the number of micro steps in a given macro step p ( l j − 1 , j ∣ θ j − 1 , ρ j − 1 ) p(l_{j-1,j}\mid\theta_{j-1},\rho_{j-1}) p ( l j − 1 , j ∣ θ j − 1 , ρ j − 1 ) will be discussed in detail shortly. Also, notice that due to the sequential nature of (9) , steps 2 and 3 in the GIST sampler described in § 2.2 are in practice performed concurrently.
Contingent on the specification from (9) , the GIST-MHG acceptance probability (7) for the proposal represented by (8) reduces to
min ( 1 , exp ( H ( θ , ρ ) − H ( θ ′ , ρ ′ ) ) ∏ j = 1 L p ( l j − 1 , j ∣ θ j , − ρ j ) p ( l j − 1 , j ∣ θ j − 1 , ρ j − 1 ) ) . (10) \min\left(1,\exp\left(H(\theta,\rho)-H(\theta',\rho')\right)\prod_{j=1}^{L}\frac{p(l_{j-1,j}\mid\theta_j,-\rho_j)}{p(l_{j-1,j}\mid\theta_{j-1},\rho_{j-1})}\right). \tag*{(10)} min ( 1 , exp ( H ( θ , ρ ) − H ( θ ′ , ρ ′ ) ) j = 1 ∏ L p ( l j − 1 , j ∣ θ j − 1 , ρ j − 1 ) p ( l j − 1 , j ∣ θ j , − ρ j ) ) . (10)
Note that an ideal micro step number distribution would be “reversible” in the sense that the distribution of the number of micro steps would be identical regardless of whether the macro step would be carried out forward or backward in time, i.e., p ( l ∣ θ , ρ ) = p ( l ∣ F ∘ Φ h l − 1 l ( θ , ρ ) ) p(l\mid\theta,\rho)=p(l\mid\mathcal{F}\circ\Phi_{h l-1}^{l}(\theta,\rho)) p ( l ∣ θ , ρ ) = p ( l ∣ F ∘ Φ h l − 1 l ( θ , ρ )) for all h > 0 h>0 h > 0 , l ∈ N l\in\mathbb{N} l ∈ N and ( θ , ρ ) ∈ R 2 d (\theta,\rho)\in\mathbb{R}^{2d} ( θ , ρ ) ∈ R 2 d . In practice, finding such exactly reversible distributions seems infeasible, and instead this paper considers choices of p ( l ∣ θ , ρ ) p(l\mid\theta,\rho) p ( l ∣ θ , ρ ) which are only approximately reversible.
Although the numerically integrated Hamiltonian flow obtained via (9) may be Metropolis-corrected using (10) for a very general choice of p ( l ∣ θ , ρ ) p(l\mid\theta,\rho) p ( l ∣ θ , ρ ) , only p ( l ∣ θ , ρ ) p(l\mid\theta,\rho) p ( l ∣ θ , ρ ) with a specific structure will be considered. More specifically, let κ ( θ , ρ , h , l ) \kappa(\theta,\rho,h,l) κ ( θ , ρ , h , l ) be a general measure of error associated with a macro step based on l l l micro steps. Also, denote the desired error tolerance by δ \delta δ . As an example, κ ( θ , ρ , h , l ) = ∣ H ( θ , ρ ) − H ( Φ h / l l ( θ , ρ ) ) ∣ \kappa(\theta,\rho,h,l)=\lvert H(\theta,\rho)-H(\Phi_{h/l}^{l}(\theta,\rho))\rvert κ ( θ , ρ , h , l ) = ∣ H ( θ , ρ ) − H ( Φ h / l l ( θ , ρ ))∣ for the energy error. Finally, define L \mathcal{L} L as the smallest (power of 2) number of micro steps fulfilling the error criterion:
L ( θ , ρ , h , δ ) = 2 c ∗ , where c ∗ = min { c ∈ { c min , c min + 1 , … } : κ ( θ , ρ , h , 2 c ) < δ } . (11) \mathcal{L}(\theta,\rho,h,\delta)=2^{c^*},\quad\text{where }c^*=\min\{c\in\{c_{\min},c_{\min}+1,\ldots\}:\kappa(\theta,\rho,h,2^c)<\delta\}. \tag*{(11)} L ( θ , ρ , h , δ ) = 2 c ∗ , where c ∗ = min { c ∈ { c m i n , c m i n + 1 , … } : κ ( θ , ρ , h , 2 c ) < δ } . (11)
Here, c min ∈ N 0 c_{\min} \in\mathbb{N}_0 c m i n ∈ N 0 is the log 2 \log_2 log 2 of the smallest number of micro steps allowed within a macro step according to the prescribed criterion.
Throughout the theoretical development, all numerical maps are understood in exact arithmetic. It is assumed that, for every fixed h > 0 h > 0 h > 0 and δ > 0 \delta> 0 δ > 0 , the mappings
( θ , ρ ) ⟼ κ ( θ , ρ , h , 2 c ) (\theta,\rho) \longmapsto\kappa(\theta,\rho,h,2^c) ( θ , ρ ) ⟼ κ ( θ , ρ , h , 2 c )
are measurable and satisfy
lim c → ∞ κ ( θ , ρ , h , 2 c ) = 0 \lim_{c\to\infty} \kappa(\theta,\rho,h,2^c) = 0 c → ∞ lim κ ( θ , ρ , h , 2 c ) = 0
for almost every ( θ , ρ ) (\theta,\rho) ( θ , ρ ) with respect to the phase-space target distribution. If a numerical trajectory is not well-defined for a particular value of c c c , its error is assigned the value + ∞ +\infty + ∞ . These assumptions ensure that the set in (11) is nonempty almost surely, that L ( θ , ρ , h , δ ) \mathcal{L}(\theta,\rho,h,\delta) L ( θ , ρ , h , δ ) is finite, and that L \mathcal{L} L is measurable.
Two remarks are in order. First, in Algorithm 1 below, L \mathcal{L} L is evaluated not only at the initial state, but also at the intermediate states ( θ j , ± ρ j ) (\theta_j,\pm\rho_j) ( θ j , ± ρ j ) . The map ( θ , ρ ) ↦ ( θ j , ± ρ j ) (\theta,\rho)\mapsto(\theta_j,\pm\rho_j) ( θ , ρ ) ↦ ( θ j , ± ρ j ) is defined piecewise: on the set of initial states for which a given vector of micro step counts ( l 0 , 1 , … , l j − 1 , j ) (l_{0,1},\ldots,l_{j-1,j}) ( l 0 , 1 , … , l j − 1 , j ) is selected, it is equal to a fixed composition of leapfrog maps and F \mathcal{F} F , which is a volume preserving bijection of R 2 d \mathbb{R}^{2d} R 2 d and therefore maps Lebesgue null sets to null sets. There are countably many such sets and they are measurable, so the map sends null sets to null sets on all of R 2 d \mathbb{R}^{2d} R 2 d . Consequently, L \mathcal{L} L is finite at every state at which the algorithm evaluates it, for μ \mu μ -almost every initial state. On the exceptional null set, the transition may be defined arbitrarily (for instance as a rejection) without affecting invariance.
Second, the limit assumption above holds for the three error measures considered in this paper under mild conditions. Suppose that log π ~ ∈ C 4 ( R d ) \log\widetilde{\pi} \in C^4(\mathbb{R}^d) log π ∈ C 4 ( R d ) is bounded above. Then, the Hamiltonian flow φ t \varphi_t φ t is complete since the conservation of H H H confines each trajectory to a compact set, and for every ( θ , ρ ) (\theta,\rho) ( θ , ρ ) , the leapfrog approximation Φ h 2 − c 2 ( θ , ρ ) \Phi_{h2^{-c}}^2(\theta,\rho) Φ h 2 − c 2 ( θ , ρ ) converges to φ h ( θ , ρ ) \varphi_h(\theta,\rho) φ h ( θ , ρ ) as c → ∞ c\to\infty c → ∞ ([15 Chapter II] ). Consequently, κ H → ∣ H − H ∘ φ h ∣ = 0 \kappa_H \to\lvert H-H\circ\varphi_h\rvert=0 κ H → ∣ H − H ∘ φ h ∣ = 0 ; κ M R F → 0 \kappa_{MRF}\to0 κ M R F → 0 because both the fine and the coarse leapfrog flows converge to φ h \varphi_h φ h ; and κ R K N F → 0 \kappa_{RKNF}\to0 κ R K N F → 0 because each of the terms f k , b k f_k,b_k f k , b k given by (21) –(22) is a local error of size O ( ( h 2 − c ) 3 ) O((h2^{-c})^3) O (( h 2 − c ) 3 ) uniformly in k k k by Lemma 1 from Appendix B.
In the implementation, the search in (11) is truncated at a maximal level c max c_{\max} c m a x (here, c max = 20 c_{\max}=20 c m a x = 20 is used), and L : = 2 c max \mathcal{L}:=2^{c_{\max}} L := 2 c m a x when no c ≤ c max c\le c_{\max} c ≤ c m a x satisfies the criterion. This truncated rule is itself a deterministic choice of L \mathcal{L} L , it removes the need for the limit assumption, and Proposition 1 below continues to hold for it: if L ( θ , ρ , h , δ ) = 2 c ∗ \mathcal{L}(\theta,\rho,h,\delta)=2^{c^*} L ( θ , ρ , h , δ ) = 2 c ∗ with c ∗ < c max c^*<c_{\max} c ∗ < c m a x , the proof applies verbatim, and if L ( θ , ρ , h , δ ) = 2 c max \mathcal{L}(\theta,\rho,h,\delta)=2^{c_{\max}} L ( θ , ρ , h , δ ) = 2 c m a x , the inequality (15) is trivial. Accordingly, in the backward check of Algorithm 2, the value l j b : = l j f l_j^b:=l_j^f l j b := l j f is assigned whenever no c < c ∗ c<c^* c < c ∗ satisfies the criterion. None of the experiments reported below reached c max c_{\max} c m a x .
Algorithm 1 A single iteration of the locally adaptive step size standard HMC algorithm
Predefine the number of macro steps L L L and the macro step size h h h .
Let θ ( n ) \theta^{(n)} θ ( n ) denote the current position and set θ 0 = θ ( n ) \theta_0 = \theta^{(n)} θ 0 = θ ( n ) . Independently sample a new momentum ρ 0 ∼ N ( 0 , M ) \rho_0 \sim N(0, M) ρ 0 ∼ N ( 0 , M ) .
for j = 1 , … , L j = 1, \ldots, L j = 1 , … , L do
Compute l j f = L ( θ j − 1 , ρ j − 1 , h , δ ) l_j^f = \mathcal{L}(\theta_{j-1}, \rho_{j-1}, h, \delta) l j f = L ( θ j − 1 , ρ j − 1 , h , δ ) .
Set ( θ j , ρ j ) = Φ k ( l j f ) l j f ( θ j − 1 , ρ j − 1 ) (\theta_j, \rho_j) = \Phi_{k(l_j^f)}^{l_j^f}(\theta_{j-1}, \rho_{j-1}) ( θ j , ρ j ) = Φ k ( l j f ) l j f ( θ j − 1 , ρ j − 1 ) .
Compute l j b = L ( θ j , − ρ j , h , δ ) l_j^b = \mathcal{L}(\theta_j, -\rho_j, h, \delta) l j b = L ( θ j , − ρ j , h , δ ) .
Set w j ′ = 1 w'_j = 1 w j ′ = 1 if l j f = l j b l_j^f = l_j^b l j f = l j b and 0 otherwise.
end for
With probability given by (13), set θ ( n + 1 ) = θ L \theta^{(n+1)} = \theta_L θ ( n + 1 ) = θ L . Otherwise, set θ ( n + 1 ) = θ ( n ) \theta^{(n+1)} = \theta^{(n)} θ ( n + 1 ) = θ ( n ) . The momentum variables are then discarded.
In this paper, only a deterministic variant of p ( l ∣ θ , ρ ) p(l|\theta,\rho) p ( l ∣ θ , ρ ) is considered. This is specified by
p ( l ∣ θ , ρ ) = { 1 , if l = L ( θ , ρ , h , δ ) , 0 , otherwise. (12) p(l|\theta,\rho) =
\begin{cases}
1, & \text{if } l = \mathcal{L}(\theta,\rho,h,\delta),\\
0, & \text{otherwise.}
\end{cases} \tag*{(12)} p ( l ∣ θ , ρ ) = { 1 , 0 , if l = L ( θ , ρ , h , δ ) , otherwise. (12)
Consequently, this leads to the acceptance probability
α ( ( θ 0 , ρ 0 ) , ( θ L , − ρ L ) ) = min ( 1 , exp ( H ( θ 0 , ρ 0 ) − H ( θ L , − ρ L ) ) ) ∏ j = 1 L w j ′ , (13) \alpha((\theta_0,\rho_0),(\theta_L,-\rho_L)) = \min\left(1,\exp(H(\theta_0,\rho_0)-H(\theta_L,-\rho_L))\right)\prod_{j=1}^{L}w'_j, \tag*{(13)} α (( θ 0 , ρ 0 ) , ( θ L , − ρ L )) = min ( 1 , exp ( H ( θ 0 , ρ 0 ) − H ( θ L , − ρ L )) ) j = 1 ∏ L w j ′ , (13)
where w j ′ = 1 w'_j = 1 w j ′ = 1 if l j f = l j b l_j^f = l_j^b l j f = l j b and 0 otherwise. Here, l j f : = L ( θ j − 1 , ρ j − 1 , h , δ ) l_j^f := \mathcal{L}(\theta_{j-1},\rho_{j-1},h,\delta) l j f := L ( θ j − 1 , ρ j − 1 , h , δ ) and l j b : = L ( θ j , − ρ j , h , δ ) l_j^b := \mathcal{L}(\theta_j,-\rho_j,h,\delta) l j b := L ( θ j , − ρ j , h , δ ) . Overall, a single iteration of the locally adaptive step size version of standard HMC as a GIST sampler is summarized in Algorithm 1 after omitting the auxiliary variables (except for the momentum) for clarity. Because the momentum is sampled independently from N ( 0 , M ) N(0,M) N ( 0 , M ) at every iteration and discarded after the accept–reject step, Algorithm 1 defines a Markov transition kernel on the position variable θ \theta θ alone.
Before proceeding, a few remarks on the choices made above are discussed. Firstly, it should be noted that the practice of considering only 2 c 2^c 2 c , c = c min , c min + 1 , … c = c_{\min}, c_{\min} + 1, \ldots c = c m i n , c m i n + 1 , … , micro steps per macro step is somewhat arbitrary, but has been found to work well in practice [5 , 6 ] . Different schedules of progressively finer discretization could also be possible, but would have to balance the need for arriving fast enough at an acceptable l l l (without computationally wasteful search through unnecessary coarser discretizations) while not being too aggressive at the same time (and thereby wasting computation by choosing substantially finer discretizations than what is needed). Secondly, the choice of a deterministic p ( l ∣ θ , ρ ) p(l|\theta,\rho) p ( l ∣ θ , ρ ) is also made based on experience with computational performance. Bou-Rabee et al. [5 , 6 ] also consider randomized variants of (12) that place mass on both L \mathcal{L} L and the next finer discretization (with equal mass on the two in Bou-Rabee et al. [6 ] ), which may preclude outright rejection of the complete proposal in cases where l b < l f l^b < l^f l b < l f (see Proposition 1 below). However, this practice will also entail that overly fine discretizations are being used (when l = L + 1 l = \mathcal{L} + 1 l = L + 1 ), and the approach was found by Bou-Rabee et al. [6 ] to be generally less computationally efficient than (12).
On approximate reversibility
Before proceeding, a further notion is useful. An error measure κ \kappa κ is said to be reversible if, for all h > 0 h > 0 h > 0 , all l ∈ { 2 c : c ≥ c min } l \in\{2^c : c \ge c_{\min}\} l ∈ { 2 c : c ≥ c m i n } and all ( θ , ρ ) ∈ R 2 d (\theta,\rho) \in\mathbb{R}^{2d} ( θ , ρ ) ∈ R 2 d for which both sides are defined, the following condition is satisfied:
κ ( θ , ρ , h , l ) = κ ( θ ′ , − ρ ′ , h , l ) , where ( θ ′ , ρ ′ ) = Φ h / l l ( θ , ρ ) . (14) \kappa(\theta,\rho,h,l) = \kappa(\theta',-\rho',h,l), \text{ where } (\theta',\rho') = \Phi_{h/l}^{l}(\theta,\rho). \tag*{(14)} κ ( θ , ρ , h , l ) = κ ( θ ′ , − ρ ′ , h , l ) , where ( θ ′ , ρ ′ ) = Φ h / l l ( θ , ρ ) . (14)
For instance, because the leapfrog integrator is exactly reversible and H ∘ F = H H \circ F = H H ∘ F = H , it is clear that the absolute energy error κ ( θ , ρ , h , l ) = ∣ H ( θ , ρ ) − H ( Φ h / l l ( θ , ρ ) ) ∣ \kappa(\theta,\rho,h,l) = \lvert H(\theta,\rho) - H(\Phi_{h/l}^{l}(\theta,\rho))\rvert κ ( θ , ρ , h , l ) = ∣ H ( θ , ρ ) − H ( Φ h / l l ( θ , ρ ))∣ is an example of a reversible error measure. In the remaining part of the text, only reversible error measures will be considered. For reversible error measures, the following result, which generalizes Lemma 14 of Bou-Rabee et al. [6 ] , holds:
Proposition 1. Suppose that κ \kappa κ is a reversible error measure. Then
L ( θ , ρ , h , δ ) ≥ L ( θ ∗ , − ρ ∗ , h , δ ) where ( θ ∗ , ρ ∗ ) = Φ h / L ( θ , ρ , h , δ ) L ( θ , ρ , h , δ ) ( θ , ρ ) . (15) \mathcal{L}(\theta,\rho,h,\delta) \ge\mathcal{L}(\theta^*,-\rho^*,h,\delta) \text{ where } (\theta^*,\rho^*) = \Phi_{h/\mathcal{L}(\theta,\rho,h,\delta)}^{\mathcal{L}(\theta,\rho,h,\delta)}(\theta,\rho). \tag*{(15)} L ( θ , ρ , h , δ ) ≥ L ( θ ∗ , − ρ ∗ , h , δ ) where ( θ ∗ , ρ ∗ ) = Φ h / L ( θ , ρ , h , δ ) L ( θ , ρ , h , δ ) ( θ , ρ ) . (15)
Proof. Let L ( θ , ρ , h , δ ) = 2 c ∗ \mathcal{L}(\theta,\rho,h,\delta) = 2^{c^*} L ( θ , ρ , h , δ ) = 2 c ∗ , where c ∗ c^* c ∗ is the minimum in (11) . By definition,
κ ( θ , ρ , h , 2 c ∗ ) < δ . \kappa(\theta,\rho,h,2^{c^*}) < \delta. κ ( θ , ρ , h , 2 c ∗ ) < δ .
Because κ \kappa κ is reversible and
( θ ∗ , ρ ∗ ) = Φ h 2 − c ∗ 2 c ∗ ( θ , ρ ) , (\theta^*,\rho^*)=\Phi_{h^{2-c^*}}^{2c^*}(\theta,\rho), ( θ ∗ , ρ ∗ ) = Φ h 2 − c ∗ 2 c ∗ ( θ , ρ ) ,
it follows that
κ ( θ ∗ , − ρ ∗ , h , 2 c ∗ ) < δ . \kappa(\theta^*,-\rho^*,h,2^{c^*})<\delta. κ ( θ ∗ , − ρ ∗ , h , 2 c ∗ ) < δ .
Thus, c ∗ c^* c ∗ belongs to the set over which the minimum defining L ( θ ∗ , − ρ ∗ , h , δ ) \mathcal{L}(\theta^*,-\rho^*,h,\delta) L ( θ ∗ , − ρ ∗ , h , δ ) is taken. Consequently,
L ( θ ∗ , − ρ ∗ , h , δ ) ≤ 2 c ∗ = L ( θ , ρ , h , δ ) , \mathcal{L}(\theta^*,-\rho^*,h,\delta)\le2^{c^*}=\mathcal{L}(\theta,\rho,h,\delta), L ( θ ∗ , − ρ ∗ , h , δ ) ≤ 2 c ∗ = L ( θ , ρ , h , δ ) ,
which proves the result.
Reversibility of the error measure κ \kappa κ in the sense of (14) does not make the micro step number distribution (12) reversible in the sense of § 2.3 : Proposition 1 yields only the inequality L ( θ ∗ , − ρ ∗ , h , δ ) ≤ L ( θ , ρ , h , δ ) \mathcal{L}(\theta^*,-\rho^*,h,\delta)\le\mathcal{L}(\theta,\rho,h,\delta) L ( θ ∗ , − ρ ∗ , h , δ ) ≤ L ( θ , ρ , h , δ ) . The indicator w j ′ w_j' w j ′ in (13) is equal to one when the equality holds in the macro step j j j and zero when the inequality is strict.
Proposition 1 provides several insights. First, it is clear that any reversibility failures originate from the fact that a coarser discretization is acceptable when integrating backward in time. An example of such a reversibility failure for a standard Gaussian target distribution with c min = 0 c_{\min}=0 c m i n = 0 and the energy error measure is presented in Figure 1 . For a fixed combination of h h h and δ \delta δ , the regions in the phase space leading to reversibility failures are indicated by the red shaded area. The dashed lines represent the boundaries between different choices of c = log 2 ( l ) c=\log_2(l) c = log 2 ( l ) . The reversibility failures occur when ( θ ∗ , − ρ ∗ ) (\theta^*,-\rho^*) ( θ ∗ , − ρ ∗ ) (the state after the first blue arrow originating from the blue dot and the first red arrow) is in a lower c c c -region (c = 1 c=1 c = 1 , l = 2 l=2 l = 2 ) than ( θ , ρ ) (\theta,\rho) ( θ , ρ ) (i.e., the blue dot itself, which is located in the region of c = 2 c=2 c = 2 , l = 4 l=4 l = 4 ). As the boundaries between different micro step numbers are determined by the particular error measure κ \kappa κ employed, the first motivation of this paper is to investigate and develop other error measures beyond the energy error that are less susceptible to such reversibility failures. Using Figure 1 , this corresponds to reducing the total area (or volume in higher dimensions) of the red shaded regions.
Figure 1. A concrete example of a scenario where reversibility fails for the Hamiltonian criterion. The target distribution is a univariate standard Gaussian, M = 1 M = 1 M = 1 , h = π / 2 h = \pi/2 h = π /2 , c min = 0 c_{\min} = 0 c m i n = 0 and δ = 0.2 \delta= 0.2 δ = 0.2 . The blue point represents an initial state ( θ , ρ ) = ( 1.45 , − 2.00 ) (\theta,\rho) = (1.45,-2.00) ( θ , ρ ) = ( 1.45 , − 2.00 ) . The blue arrows denote forward macro steps while the red arrows correspond to momentum flips. The first blue arrow therefore shows the first forward macro step while the remaining constitute the backward macro step with the orange point as the final destination. The red shaded area illustrates the region of points that will experience reversibility failures, the dashed lines are the boundaries between areas of two neighbouring micro step sizes.
A second insight provided by Proposition 1 is that if L ( θ , ρ , h , δ ) = 2 c min \mathcal{L}(\theta,\rho,h,\delta)=2^{c_{\min}} L ( θ , ρ , h , δ ) = 2 c m i n , one necessarily obtains equality in (15) and therefore with certainty achieves a reversible macro step. In the graphical representation in Figure 1 , this observation translates to the absence of red shaded area within the (innermost) region where c = c min = 0 c=c_{\min}=0 c = c m i n = 0 , l = 1 l=1 l = 1 . This property may be leveraged to reduce the number of reversibility failures, typically by reducing the macro step size h h h for a fixed error threshold δ \delta δ so that the majority of macro steps involve only a single micro step. A value of P ( c = c min ) P(c=c_{\min}) P ( c = c m i n ) around 0.8 has been found to work well in practice ([6 ] ). Such choices of h h h appear to be a reasonable balance between (for small h h h ) certain reversibility, but also the potential for unnecessarily high accuracy/inefficient simulations, against (for large h h h ) better adapted micro step sizes, but also higher rates of reversibility failures which may lead to inefficiencies in the overarching MCMC simulation.
Algorithm 2 A single optimized macro step assuming a reversible error criterion κ \kappa κ (replaces the macro step j j j indicated by the blue lines in Algorithm 1). Note that the computation of Φ h / 2 − c 2 c \Phi_{h/2-c}^{2^c} Φ h /2 − c 2 c and the associated error measure κ \kappa κ is typically done concurrently as indicated below.
for c = c min , c min + 1 , … c = c_{\min}, c_{\min} + 1, \ldots c = c m i n , c m i n + 1 , … do
Compute ( ( θ j , ρ j ) , k ) = ( Φ h / 2 − c 2 c ( θ j − 1 , ρ j − 1 ) , κ ( θ j − 1 , ρ j − 1 , h , 2 c ) ) ((\theta_j,\rho_j), k) = \left(\Phi_{h/2-c}^{2^c}(\theta_{j-1},\rho_{j-1}), \kappa(\theta_{j-1},\rho_{j-1},h,2^c)\right) (( θ j , ρ j ) , k ) = ( Φ h /2 − c 2 c ( θ j − 1 , ρ j − 1 ) , κ ( θ j − 1 , ρ j − 1 , h , 2 c ) )
if k < δ k < \delta k < δ then
c ∗ = c c^* = c c ∗ = c
break
end if
end for
w j ′ = 1 w'_j = 1 w j ′ = 1
if c ∗ > c min c^* > c_{\min} c ∗ > c m i n then
for c = c min , c min + 1 , … , ( c ∗ − 1 ) c = c_{\min}, c_{\min} + 1, \ldots, (c^* - 1) c = c m i n , c m i n + 1 , … , ( c ∗ − 1 ) do
Compute k = κ ( θ j , − ρ j , h , 2 c ) k = \kappa(\theta_j,-\rho_j,h,2^c) k = κ ( θ j , − ρ j , h , 2 c ) (the state Φ h / 2 − c 2 c ( θ j , − ρ j ) \Phi_{h/2-c}^{2^c}(\theta_j,-\rho_j) Φ h /2 − c 2 c ( θ j , − ρ j ) is computed as a by-product, but is not needed)
if k < δ k < \delta k < δ then
w j ′ = 0 w'_j = 0 w j ′ = 0
break
end if
end for
end if
Algorithm 2 summarizes a single macro step (equivalent to the blue lines in Algorithm 1) which is optimized via the utilization of Proposition 1. In particular, no reversibility check needs to be done if the minimal number of micro steps, i.e., c ∗ = c min c^* = c_{\min} c ∗ = c m i n , is acceptable in the forward step. When c ∗ > c min c^* > c_{\min} c ∗ > c m i n , the c = c ∗ c = c^* c = c ∗ backward check is not needed as it is already known from the forward pass to be acceptable due to Proposition 1 (since κ \kappa κ is assumed to be reversible).
Error measures for the micro step selection criterion
So far, the error measures for adaptive step size MCMC methods have predominantly been based on energy/Hamiltonian error ([20 , 2 , 5 , 6 ] ). Based on the above discussion, it is clear that one would prefer to avoid using error measures that result in too many w j ′ w'_j w j ′ being zero, at least from the perspective of the standard HMC method. Two alternatives that are different from the former will be developed and presented, with the goal of reducing the frequency of reversibility failures. However, such improvements generally come at the cost of additional gradient evaluations per micro step. Whether such added costs pay off in the overall MCMC simulation efficiency will be explored later.
Hamiltonian criterion
As presented before, the energy error measure κ H \kappa_H κ H may be summarized by
κ H ( θ , ρ , h , l ) = ∣ H ( θ , ρ ) − H ∘ Φ h / l l ( θ , ρ ) ∣ . (16) \kappa_H(\theta,\rho,h,l) = \left|H(\theta,\rho) - H \circ\Phi_{h/l}^{l}(\theta,\rho)\right|. \tag*{(16)} κ H ( θ , ρ , h , l ) = H ( θ , ρ ) − H ∘ Φ h / l l ( θ , ρ ) . (16)
It is straightforward to verify that κ H \kappa_H κ H is reversible, and the additional computational cost of κ H \kappa_H κ H is negligible (since Φ h l ( θ , ρ ) \Phi_h^l(\theta,\rho) Φ h l ( θ , ρ ) must be computed anyway as it corresponds to the final state after a macro step of size h h h ).
For a given combination of the macro step size h h h and the criterion threshold δ \delta δ , the c c c -boundaries associated with (16) for a univariate standard Gaussian target are illustrated in Figure 1 . The energy error of a single leapfrog step in this case is quadratic in ( θ , ρ ) (\theta,\rho) ( θ , ρ ) . Consequently, the boundary between the region of c = 0 c=0 c = 0 and c = 1 c=1 c = 1 is a pair of hyperbolas that both approach asymptotically the roots of the energy error (i.e., the roots of (16) in ( θ , ρ ) (\theta,\rho) ( θ , ρ ) ). In the case of Figure 1 , these are given as ρ = ( π / 4 ) θ \rho=(\pi/4)\theta ρ = ( π /4 ) θ and ρ = [ ( π 2 − 16 ) / ( 4 π ) ] θ \rho=[(\pi^2-16)/(4\pi)]\theta ρ = [( π 2 − 16 ) / ( 4 π )] θ . On the other hand, the error in the position and momentum vector increases linearly in ( θ , ρ ) (\theta,\rho) ( θ , ρ ) . Hence, the energy error criterion (16) may in fact allow for an arbitrarily poor representation of the underlying Hamiltonian flow obtained by the leapfrog integrator for an arbitrarily small δ \delta δ when the initial z = ( θ , ρ ) z=(\theta,\rho) z = ( θ , ρ ) is close to the roots of the energy error boundary defining the region of one single micro step.
One is not concerned with the accuracy of the representation of the Hamiltonian flow per se (as only the energy error enters the acceptance probability, e.g., (13) ). However, tolerating such large flow errors may allow for instabilities in the computation of proposals. Furthermore, and possibly more importantly, it is seen from Figure 1 that the regions of reversibility failures tend (arguably to a varying degree) to be concentrated close to the c c c -boundaries. To utilize this insight in order to achieve fewer reversibility failures, it seems natural to look for error criteria κ \kappa κ that induce less complicated c c c -boundaries, and possibly also such that the boundaries are more aligned with the flow (vector) field in the phase space.
Embedded integration step flow criterion
In this subsection, to obtain an error measure with simpler c c c -boundaries, an alternative criterion based on measuring flow error is developed and presented. More specifically, the embedded integration step approach, commonly used for step size control for Runge-Kutta methods (see e.g., Hairer et al., 1993), is employed. Embedded integration steps involve at least two methods for advancing the flow with different error orders, while using at least some of the same force (which corresponds to the gradient of the log-target density here) evaluations. The difference between these methods is interpreted as an approximation to the local error of the method with the lowest error order, and this estimate may subsequently be used for step size control.
Here, to the authors’ knowledge, a novel third-order Runge-Kutta-Nyström (RKN) step ([15 ] ) is embedded with a leapfrog step for measuring the second-order leapfrog flow error in a reversible manner. The RKN step exploits an already computed leapfrog step and adds a single additional gradient evaluation to obtain a higher order method. In particular, for a general step size ϵ \epsilon ϵ , denote by ( θ , ρ ) (\theta,\rho) ( θ , ρ ) the initial state and ( θ ′ , ρ ′ ) = Φ ϵ ( θ , ρ ) (\theta',\rho')=\Phi_\epsilon(\theta,\rho) ( θ ′ , ρ ′ ) = Φ ϵ ( θ , ρ ) . To get a third-order integrator based on the already computed leapfrog state ( θ ′ , ρ ′ ) (\theta',\rho') ( θ ′ , ρ ′ ) (and the associated log-target density gradients), define Φ ˉ ϵ : ( θ , ρ ) ↦ ( θ ′ ′ , ρ ′ ′ ) \bar{\Phi}_{\epsilon} : (\theta,\rho) \mapsto(\theta^{\prime\prime},\rho^{\prime\prime}) Φ ˉ ϵ : ( θ , ρ ) ↦ ( θ ′′ , ρ ′′ ) in the following manner:
θ m = 1 2 ( θ + θ ′ ) + ϵ 8 M − 1 ( ρ − ρ ′ ) , (17) \theta_m = \frac{1}{2}(\theta+\theta^\prime)+\frac{\epsilon}{8}M^{-1}(\rho-\rho^\prime), \tag*{(17)} θ m = 2 1 ( θ + θ ′ ) + 8 ϵ M − 1 ( ρ − ρ ′ ) , (17)
θ ′ ′ = θ + ϵ M − 1 ρ + ϵ 2 M − 1 ( 1 3 ∇ θ log π ~ ( θ ) + 1 6 ∇ θ log π ~ ( θ ′ ) ) , (18) \theta^{\prime\prime}=\theta+\epsilon M^{-1}\rho+\epsilon^2M^{-1}\left(\frac{1}{3}\nabla_\theta\log\widetilde{\pi}(\theta)+\frac{1}{6}\nabla_\theta\log\widetilde{\pi}(\theta^\prime)\right), \tag*{(18)} θ ′′ = θ + ϵ M − 1 ρ + ϵ 2 M − 1 ( 3 1 ∇ θ log π ( θ ) + 6 1 ∇ θ log π ( θ ′ ) ) , (18)
ρ ′ ′ = ρ + ϵ ( 1 6 ∇ θ log π ~ ( θ ) + 2 3 ∇ θ log π ~ ( θ m ) + 1 6 ∇ θ log π ~ ( θ ′ ) ) . (19) \rho^{\prime\prime}=\rho+\epsilon\left(\frac{1}{6}\nabla_\theta\log\widetilde{\pi}(\theta)+\frac{2}{3}\nabla_\theta\log\widetilde{\pi}(\theta_m)+\frac{1}{6}\nabla_\theta\log\widetilde{\pi}(\theta^\prime)\right). \tag*{(19)} ρ ′′ = ρ + ϵ ( 6 1 ∇ θ log π ( θ ) + 3 2 ∇ θ log π ( θ m ) + 6 1 ∇ θ log π ( θ ′ ) ) . (19)
Note that the intermediate θ m \theta_m θ m has been selected so that it coincides in the calculation of both Φ ˉ ϵ ( θ , ρ ) \bar{\Phi}_{\epsilon}(\theta,\rho) Φ ˉ ϵ ( θ , ρ ) and Φ ˉ ϵ ∘ F ( θ ′ , ρ ′ ) \bar{\Phi}_{\epsilon}\circ\mathcal{F}(\theta^\prime,\rho^\prime) Φ ˉ ϵ ∘ F ( θ ′ , ρ ′ ) . Therefore, obtaining a reversible/symmetric error measure, say max ( ∥ ( θ ′ , ρ ′ ) − Φ ˉ ϵ ( θ , ρ ) ∥ , ∥ F ( θ , ρ ) − Φ ˉ ϵ ∘ F ( θ ′ , ρ ′ ) ∥ ) \max(\|(\theta^\prime,\rho^\prime)-\bar{\Phi}_{\epsilon}(\theta,\rho)\|,\|\mathcal{F}(\theta,\rho)-\bar{\Phi}_{\epsilon}\circ\mathcal{F}(\theta^\prime,\rho^\prime)\|) max ( ∥ ( θ ′ , ρ ′ ) − Φ ˉ ϵ ( θ , ρ ) ∥ , ∥ F ( θ , ρ ) − Φ ˉ ϵ ∘ F ( θ ′ , ρ ′ ) ∥ ) , requires only a single additional gradient evaluation ∇ θ log π ~ ( θ m ) \nabla_\theta\log\widetilde{\pi}(\theta_m) ∇ θ log π ( θ m ) (and a handful of vector operations) relative to the underlying leapfrog integration.
Combining (17) –(19) and the macro/micro-construction yields the RKN-flow-based (RKNF) error measure
κ R K N F ( θ , ρ , h , l ) = max k ∈ { 1 , … , l } { max ( f k , b k ) } , (20) \kappa_{RKNF}(\theta,\rho,h,l)=\max_{k\in\{1,\ldots,l\}}\{\max(f_k,b_k)\}, \tag*{(20)} κ R K N F ( θ , ρ , h , l ) = k ∈ { 1 , … , l } max { max ( f k , b k )} , (20)
f k = ∥ ( θ ( k ) , ρ ( k ) ) − Φ ˉ h 2 − c ( θ ( k − 1 ) , ρ ( k − 1 ) ) ∥ , (21) f_k=\|(\theta^{(k)},\rho^{(k)})-\bar{\Phi}_{h2^{-c}}(\theta^{(k-1)},\rho^{(k-1)})\|, \tag*{(21)} f k = ∥ ( θ ( k ) , ρ ( k ) ) − Φ ˉ h 2 − c ( θ ( k − 1 ) , ρ ( k − 1 ) ) ∥ , (21)
b k = ∥ F ( θ ( k − 1 ) , ρ ( k − 1 ) ) − Φ ˉ h 2 − c ∘ F ( θ ( k ) , ρ ( k ) ) ∥ (22) b_k=\|\mathcal{F}(\theta^{(k-1)},\rho^{(k-1)})-\bar{\Phi}_{h2^{-c}}\circ\mathcal{F}(\theta^{(k)},\rho^{(k)})\| \tag*{(22)} b k = ∥ F ( θ ( k − 1 ) , ρ ( k − 1 ) ) − Φ ˉ h 2 − c ∘ F ( θ ( k ) , ρ ( k ) ) ∥ (22)
with ( θ ( k ) , ρ ( k ) ) = Φ h / l k ( θ , ρ ) (\theta^{(k)},\rho^{(k)})=\Phi_{h/l}^{k}(\theta,\rho) ( θ ( k ) , ρ ( k ) ) = Φ h / l k ( θ , ρ ) (and Φ 0 = I \Phi^0=I Φ 0 = I ). Here, ∥ ⋅ ∥ \|\cdot\| ∥ ⋅ ∥ is an arbitrary (vector) norm, which in the numerical computations of this paper will be the L ∞ L^\infty L ∞ -norm, and l = 2 c l=2^c l = 2 c , where c ≥ c min c\ge c_{\min} c ≥ c m i n for some c min ≥ 0 c_{\min}\ge0 c m i n ≥ 0 . Note that the leapfrog flow is used for advancing the integrator in accordance with (8) . The RKNF steps, which are generally not reversible, are only used for the error measurement so that the resulting RKN states are subsequently discarded.
Due to the measurement of error both for the forward and backward micro steps, the following result holds:
Proposition 2. κ R K N F \kappa_{RKNF} κ R K N F defined by (20) –(22) is reversible in the sense of (14) .
Proof. See Appendix A.1.
The proof uses no property of ∥ ⋅ ∥ \|\cdot\| ∥ ⋅ ∥ beyond it being a norm on R 2 d \mathbb{R}^{2d} R 2 d . In particular, the norm does not need to be invariant under F \mathcal{F} F . Note that the error tolerance δ \delta δ employed in (11) is no longer interpretable in terms of energy errors when (11) is used together with (20) –(22) , and must in general be tuned so that the energy error entering an acceptance probability (e.g., (13) ) is in an appropriate range. However, it should be noted that for proposals involving multiple macro steps, tuning of δ \delta δ in conjunction with the energy error (16) is generally also needed (see Bou-Rabee et al., [6 ] ).
The RKN map (17) –(19) is third-order accurate, and a verification is given in Appendix B. It requires only one additional gradient evaluation relative to leapfrog. However, it is not optimized for stability, so the RKN comparison map may dominate the error criterion and force the selection of an unnecessarily fine discretization for large micro step sizes.
Multi-resolution flow criterion
The flow criterion from the previous subsection considers the norm of the difference between the leapfrog and a third-order accurate state for a given micro step, but the cruder leapfrog state is used to advance the flow (and the more accurate and computationally costly RKN step is subsequently discarded). As known in the numerical ODE literature, local extrapolation, whereby the more precise integrator is also used for advancing the integration process, may in many cases be beneficial [15 Chapter II.5] . In this subsection, another error measure based on comparing the leapfrog integration flow using two different step sizes is presented. In contrast to the previous criterion, the following quantity allows for advancing the integration process using the most precise leapfrog flow approximation computed. Superficially, this approach has some similarities to the Bulirsch-Stoer (BS) method [15 ] in the sense that the same time interval is traversed multiple times using the same integrator, but with different step sizes and number of integration steps. However, BS methods also involve extrapolation steps, which are infeasible in the present context as these may break the reversibility of the resulting integration process.
More specifically, the proposed error measure, which will now be referred to as multi-resolution flow (MRF) error, applies only for c min ≥ 1 c_{\min} \ge1 c m i n ≥ 1 and may be summarized for l = 2 c l = 2^c l = 2 c , c = c min , c min + 1 , … c = c_{\min}, c_{\min} + 1, \ldots c = c m i n , c m i n + 1 , … , by
κ M R F ( θ , ρ , h , l ) = max ( ∥ ( θ ′ , ρ ′ ) − Φ 2 h / l l / 2 ( θ , ρ ) ∥ , ∥ F ( θ , ρ ) − Φ 2 h / l l / 2 ∘ F ( θ ′ , ρ ′ ) ∥ ) , where ( θ ′ , ρ ′ ) = Φ h / l l ( θ , ρ ) . (23) \kappa_{MRF}(\theta,\rho,h,l) = \max\left( \left\lVert(\theta',\rho') - \Phi_{2h/l}^{l/2}(\theta,\rho) \right\rVert, \left\lVert\mathcal{F}(\theta,\rho) - \Phi_{2h/l}^{l/2} \circ\mathcal{F}(\theta',\rho') \right\rVert\right), \quad\text{where } (\theta',\rho') = \Phi_{h/l}^{l}(\theta,\rho). \tag*{(23)} κ M R F ( θ , ρ , h , l ) = max ( ( θ ′ , ρ ′ ) − Φ 2 h / l l /2 ( θ , ρ ) , F ( θ , ρ ) − Φ 2 h / l l /2 ∘ F ( θ ′ , ρ ′ ) ) , where ( θ ′ , ρ ′ ) = Φ h / l l ( θ , ρ ) . (23)
In other words, the error estimate associated with traversing the macro step using l = 2 c l = 2^c l = 2 c , c = c min , c min + 1 , … c = c_{\min}, c_{\min} + 1, \ldots c = c m i n , c m i n + 1 , … micro steps is obtained by comparing with the flow obtained using 2 c − 1 2^{c-1} 2 c − 1 micro steps (i.e., with a micro step size that is twice as large) in either direction. Figure 2 provides an illustration of the error measurement (23) for l = 4 l = 4 l = 4 . The “backward checks” (second argument of the max-function in (23) ) ensure the following:
Figure 2. An illustration of the multi-resolution flow (MRF) criterion where the (high-resolution) final state ( θ ′ , ρ ′ ) (\theta',\rho') ( θ ′ , ρ ′ ) (orange) is the result of l = 4 l = 4 l = 4 forward micro steps from the initial state ( θ , ρ ) (\theta,\rho) ( θ , ρ ) (blue). The red state corresponds to the state obtained using 2 forward micro steps from the initial state. Finally, the green state corresponds to the resulting state after 2 backward micro steps from ( θ ′ , ρ ′ ) (\theta',\rho') ( θ ′ , ρ ′ ) . The criterion checks if both the norm of the difference between the two "final" states (red and orange) and the norm of the difference between the two "initial" states (blue and green) are less than a desired value δ \delta δ . Note that the same computations and comparisons would be performed regardless of whether one calculates κ M R F ( θ , ρ , h , 4 ) \kappa_{\mathrm{MRF}}(\theta,\rho,h,4) κ MRF ( θ , ρ , h , 4 ) or κ M R F ( θ ′ , − ρ ′ , h , 4 ) \kappa_{\mathrm{MRF}}(\theta',-\rho',h,4) κ MRF ( θ ′ , − ρ ′ , h , 4 ) .
Proposition 3. For l = 2 c l = 2^c l = 2 c , c = c min , c min + 1 , … c = c_{\min}, c_{\min} + 1, \ldots c = c m i n , c m i n + 1 , … , κ M R F \kappa_{MRF} κ M R F defined in (23) is reversible in the sense of (14) .
Proof. See Appendix § 7 .§ 2 .
In the numerical computations presented below, L ∞ L^\infty L ∞ -norms are again used in (23) . Note that (23) may be interpreted as approximately measuring the error of traversing the macro step using l / 2 l/2 l /2 leapfrog micro steps. As such, one would expect the error tolerance δ \delta δ to be larger for MRF than for RKNF to obtain the same accuracy for the selected ( θ ′ , ρ ′ ) (\theta',\rho') ( θ ′ , ρ ′ ) . On the other hand, since ( θ ′ , ρ ′ ) (\theta',\rho') ( θ ′ , ρ ′ ) is based on at least two leapfrog steps, MRF-based macro step sizes h h h could also possibly be larger than the RKNF counterparts.
Nevertheless, since the error estimation for MRF happens relative to a cruder discretization, one would still require macro step sizes that lead to numerical stability when performing 2 c − 1 2^{c-1} 2 c − 1 leapfrog steps in order to select ( θ ′ , ρ ′ ) (\theta',\rho') ( θ ′ , ρ ′ ) based on 2 c 2^c 2 c leapfrog steps. Similarly to RKNF, the requirement for stability of the forward and backward numerical flows with 2 c min − 1 2^{c_{\min}-1} 2 c m i n − 1 leapfrog steps in order to select ( θ ′ , ρ ′ ) (\theta',\rho') ( θ ′ , ρ ′ ) based on 2 c min 2^{c_{\min}} 2 c m i n leapfrog steps may in certain cases put an upper bound on the integration error attainable and/or make the MRF-based controller insensitive to δ \delta δ for large values of δ \delta δ . Consequently, it is conceivable in certain situations that MRF-based control can lead to unnecessarily precise/inefficient integration relative to the other controllers.
Finally, it should be noted that by careful implementation of κ M R F ( θ , ρ , h , 2 c ) \kappa_{MRF}(\theta,\rho,h,2^c) κ M R F ( θ , ρ , h , 2 c ) for consecutive values of c c c , computational savings can be realized relative to each sequential computation of (23) from scratch as indicated in Algorithm 2 (see also Table 1 ). These savings originate primarily from the fact that the high-resolution forward flow in κ M R F ( θ , ρ , h , 2 c ) \kappa_{MRF}(\theta,\rho,h,2^c) κ M R F ( θ , ρ , h , 2 c ) is identical to the low-resolution forward flow in κ M R F ( θ , ρ , h , 2 c + 1 ) \kappa_{MRF}(\theta,\rho,h,2^{c+1}) κ M R F ( θ , ρ , h , 2 c + 1 ) . See Appendix § 10 for more details regarding this matter.
Table 1. Computational cost of a full macro step where the final new configuration ( θ ′ , ρ ′ ) (\theta',\rho') ( θ ′ , ρ ′ ) is computed using 2 c 2^c 2 c micro steps assuming that c min = 0 c_{\min}=0 c m i n = 0 for the Hamiltonian energy and RKNF error criterion and c min = 1 c_{\min}=1 c m i n = 1 for MRF error criterion. Note that for RKNF and c > 0 c>0 c > 0 , the gradient count is an upper bound as the computation of the error measure (20) may be stopped early if one of { f k , b k } > δ \{f_k,b_k\}>\delta { f k , b k } > δ .
Computational cost
Under the assumption that a single given macro step is reversible, Table 1 provides a summary of the computational cost in terms of gradient evaluations to obtain the final state of the macro step. The new configuration ( θ ′ , ρ ′ ) (\theta',\rho') ( θ ′ , ρ ′ ) is computed using 2 c 2^c 2 c micro steps. Although MRF and RKNF are more costly relative to the Hamiltonian error measure per se, these costs come with benefits that are explored further below.
In addition, observe that the computation of κ R K N F \kappa_{RKNF} κ R K N F for c > 0 c>0 c > 0 may be stopped early if a micro step error estimate f k f_k f k is found to exceed δ \delta δ . Accordingly, the results of RKNF in Table 1 should be regarded as upper bounds. It is also worth noting that a variant of the energy error measure (see Equation 9 of Bou-Rabee et al. [6 ] ) could also allow for such early stopping. However, in line with Remark 13 of Bou-Rabee et al. [6 ] , only (16) is considered in this work.
Preliminary illustrative examples
The left-hand side panels of Figure 3 show the level sets of c ∗ c^* c ∗ (see Equation (11) ) for a single macro step (L = 1 L=1 L = 1 ) with step size control based on the three error measures presented above. The target distribution is a standard Gaussian, where the exact flows are elliptical around the origin. The macro step size is the same in all cases. The choices of δ \delta δ approximately lead to around 80% acceptance probability (13) for the Hamiltonian and RKNF criterion. For the MRF criterion, due to the c min = 1 c_{\min}=1 c m i n = 1 floor, the energy acceptance probability from (13) cannot be made smaller than approximately 95%. Also, the flow-based criteria are observed to have less complicated c c c -boundaries,
Figure 3. Results for a univariate standard Gaussian and a single integration step. Left plots: c = log 2 ( L ( θ , ρ , h , δ ) ) c = \log_{2}(\mathcal{L}(\theta,\rho,h,\delta)) c = log 2 ( L ( θ , ρ , h , δ )) for tuning parameters given in the plots according to a given error measure. Right plots: The red regions are the initial states in the phase space leading to reversibility failures.
where the boundaries to a larger degree align with the flow of the underlying system.
The right-hand side panels of Figure 3 show the initial phase space configurations leading to reversibility failures.
Weighted by the Boltzmann-Gibbs distribution ∝ exp ( − H ) \propto\exp(-H) ∝ exp ( − H ) , the reversibility failure probability is around 17% for the Hamiltonian criterion. For RKNF and MRF, the same quantity corresponds to roughly 3% and 0.9%, respectively.
As such, it is clear that Figure 3 may serve as a proof of concept that quite drastic decreases in reversibility failure rates (and thereby increasing the expected number of subsequent reversible macro steps by a sizable factor, say 5-10) are possible with a more careful selection of error measure.
To further explore the effect of varying the error measure, a simple experiment based on a 100-dimensional standard normal target is considered. The macro step size is set to h = π / 2 h = \pi/2 h = π /2 (which would lead to iid samples if the exact flow is used) with L = 1 L = 1 L = 1 and full momentum refreshes are performed. For all three criteria, δ \delta δ is chosen so that the overall Metropolis acceptance rate is close to 80%. Ten independent chains are run, each with 100000 iterations in both the warmup and sampling periods. Various diagnostic results for this simple example are summarized in Table 2 and Table 3 .
Table 2. Reversibility results of the 100-dimensional standard normal distribution using standard HMC with h = π / 2 h = \pi/2 h = π /2 and L = 1 L = 1 L = 1 .
Table 3. ESS results of the 100-dimensional standard normal distribution using standard HMC with h = π / 2 h = \pi/2 h = π /2 and L = 1 L = 1 L = 1 .
Regarding reversibility, one can observe from Table 2 that the ratio of macro steps with no reversibility issues is roughly 83% for the Hamiltonian criterion, which is not far from the target Metropolis acceptance rate of 80%. In order to maintain the desired target acceptance rate, smaller micro step size is needed to compensate for this fact, thus leading to more gradient evaluations. For the RKNF and MRF criteria, the reversibility rate is 97.5% and 97.8%, respectively. Larger micro step sizes are therefore possible while retaining the desired Metropolis acceptance rate and high reversibility rate. Thus, fewer gradient evaluations are performed in such scenarios, leading to a higher ESS produced per gradient evaluation compared to the standard Hamiltonian criterion based on Table 3 .
The examples so far illustrate how large an impact the choice of micro step size criterion can potentially have, even for L = 1 L = 1 L = 1 , in very simple situations. The reversibility problem will become even more apparent for HMC when L > 1 L > 1 L > 1 as several consecutive macro steps need to be reversible in order not to outright reject the proposal.
Effect of tuning parameters h h h and δ \delta δ
The micro step number selection mechanism given by (11) involves two tuning parameters; the macro step size h h h and the error threshold δ \delta δ . To gain further insight on how these influence the behaviour of the macro step in the context of the three different error measures described above, a set of preliminary and smaller simulation experiments is considered.
First, a bivariate normal distribution with zero mean, unit marginal variances and correlation set to 0.95 is considered as the target distribution. For each criterion, Figure 4 shows how the (simulated) reversibility failure probability (left) and the (simulated) distribution of the number of micro steps (right) given a fixed δ \delta δ (δ = 0.1 \delta= 0.1 δ = 0.1 , c min = 0 c_{\min} = 0 c m i n = 0 for κ H \kappa_{\mathrm{H}} κ H , δ = 0.05 \delta= 0.05 δ = 0.05 , c min = 0 c_{\min} = 0 c m i n = 0 for κ R K N F \kappa_{\mathrm{RKNF}} κ RK NF and δ = 1.0 \delta= 1.0 δ = 1.0 , c min = 1 c_{\min} = 1 c m i n = 1 for κ M R F \kappa_{\mathrm{MRF}} κ MRF ) vary with respect to h h h . At each value of h h h , 100000 macro steps are performed with initial states drawn according to the Boltzmann-Gibbs distribution μ ( θ , ρ ) \mu(\theta, \rho) μ ( θ , ρ ) .
Figure 4. Illustrations of 100000 simulated macro steps with different initial states using the three criteria for the highly correlated bivariate normal distribution. Left plots: Probability of a macro step experiencing the reversibility issue with respect to the macro step size h h h . Right plots: Probability of taking a given number of micro steps to achieve the desired error for a given criterion with respect to the macro step size h h h . Here, δ H = 0.1 \delta_{\mathrm{H}} = 0.1 δ H = 0.1 , δ R K N F = 0.05 \delta_{\mathrm{RKNF}} = 0.05 δ RK NF = 0.05 and δ M R F = 1 \delta_{\mathrm{MRF}} = 1 δ MRF = 1 . A 95% confidence interval calculated using the Clopper-Pearson interval is plotted for the plots on the left as red bands, but the width is very small.
From Figure 4 , one may first observe that L = 2 c min \mathcal{L} = 2^{c_{\min}} L = 2 c m i n , and therefore a macro step with guaranteed reversibility in line with Proposition 1, can be obtained for each of the error measures by selecting a sufficiently small macro step size. For the selected values of δ \delta δ , it is seen that κ H \kappa_H κ H leads to a substantially higher prevalence of reversibility failures for larger macro step sizes than the flow-based error measures. Furthermore, Figure 4 shows, possibly somewhat counterintuitively, that reversibility failure probabilities are not monotone with respect to the macro step size h h h . Also, presumably due to the rather complicated c c c -boundaries associated with the energy error measure, the distributions of selected micro step numbers (right panel) exhibit quite complicated structure, whereas the flow-based measures transition more smoothly towards more micro steps as h h h grows.
In Figure 5 , reversibility failure probabilities and micro step number distributions are plotted for the same target distribution, but with fixed h = 1 h = 1 h = 1 and varying δ \delta δ . In this particular example, except for very low error tolerances (which would lead to highly inefficient proposal generations), it is observed that the energy error criterion leads to quite high reversibility failure probabilities. For RKNF and relevant values of δ \delta δ , say e.g., below 0.1 Var ( θ i ) 0.1\sqrt{\operatorname{Var}(\theta_i)} 0.1 Var ( θ i ) , the reversibility failure rate is lower than for the Hamiltonian energy criterion. On the other hand, the MRF reversibility failure probabilities seem to be less sensitive to the choice of δ \delta δ , at least for the range of values of δ \delta δ considered here. Again, note that the reversibility failure probability is not monotone with respect to δ \delta δ .
Figure 5. Illustrations of 100000 simulated macro steps with different initial states using the three criteria for the highly correlated bivariate normal distribution. The horizontal axis is plotted in log-scale. Left plots: Probability of a macro step experiencing the reversibility issue with respect to the threshold δ \delta δ . Right plots: Probability of taking a given number of micro steps to achieve the desired criteria with respect to the threshold δ \delta δ . Here, h = 1 h = 1 h = 1 . A 95% confidence interval calculated using the Clopper-Pearson interval is plotted for the plots on the left as red bands, but the width is very small.
The above discussion provides some insights regarding reasonable tuning strategies for δ \delta δ and h h h . As discussed in Bou-Rabee et al. [6 ] , a possible strategy, which will also be pursued to some degree here, is to tune:
However, it should be noted that other alternatives also exist. For instance, for the Hamiltonian criterion, the reference implementation of WALNUTS (Carpenter et al. [8 ] ) uses fixed δ \delta δ and varies h h h and c min c_{\min} c m i n to obtain efficient sampling. A full discussion of tuning adaptive step size methods is beyond the scope of this paper since the strategy for tuning necessarily also depends strongly on the overarching MCMC method and the error measure employed, as highlighted in § 5 . The choices regarding the chosen tuning parameters leading to the numerical results presented in the remainder of this text are made in the interest of illustrating differences between the criteria and their application in different MCMC methods in various situations. As such, the results should not be interpreted as providing a more formal ranking of the relative merits of the proposed methods, as this would require more tailored tuning strategies for each particular situation.
Further remarks on locally adaptive step sizes
Before proceeding to examine how locally adaptive step sizes as discussed above may be integrated in various other Hamiltonian flow-based MCMC methods, a few remarks are in order.
The macro/micro step construction described, as mentioned above, is not restricted to the (fixed mass) Hamiltonian flow. Similar constructions in conjunction with explicit reversible integrators can be made for e.g., Riemannian manifold HMC based on explicit integrators (see e.g., Hartmann et al., [16 ] ), various forms of non-volume-preserving dynamics such as the isokinetic/microcanonical flow (see e.g., Robnik et al., [29 , 30 ] ) and extended state space methods such as the Nosé-Hoover thermostat (see e.g., Leimkuhler and Reich, [24 ] ). In particular, if some form of conserved quantity exists, error measures similar to κ H \kappa_H κ H may be utilized. In any case, error measures similar to κ M R F \kappa_{MRF} κ M R F will be available with otherwise minimal changes to the above theory.
For reversible implicit integrators, e.g., the generalized leapfrog (see e.g., Leimkuhler and Reich, [23 ] ; Girolami and Calderhead [12 ] ) or implicit midpoint, the macro/micro construction may be employed to monitor the convergence of iterative processes such as fixed point iterations used to advance the integrator instead of focusing directly on the flow or energy error quality. However, it should be noted that whether such an iterative process converges in a prescribed number of iterations is generally not reversible in the sense of (14) .
As briefly mentioned above, the reference WALNUTS C++ implementation (Carpenter et al., [8 ] ) increases c min c_{\min} c m i n (and increases h h h ) in order to control the number of macro steps/reversibility checks per orbit. This allows for building longer orbits uninterrupted by reversibility failures. However, this practice could introduce computational inefficiencies as the locally adaptive nature of the integrator is to some degree lost, i.e., longer time intervals of Hamiltonian trajectory would need to be integrated with the same step size, even if only a short time interval within the macro step needs a reduction in the (micro) step sizes. A motivation for the present work is to reduce the need for such reduced adaptivity by increasing the reversibility probability.
Locally adaptive step size for other HMC-type methods
The previous section utilizes the standard HMC method to illustrate how the locally adaptive step size technique may be embedded into an overarching MCMC method. In this section, such embedding is also discussed for other Hamiltonian flow-based MCMC methods with modest modifications.
It is worth mentioning that enhanced variants of standard HMC such as Randomized HMC (Bou-Rabee and Sanz-Serna, [3 ] ), where L L L is drawn from some distribution f L ( L ) f_L(L) f L ( L ) (not depending on ( θ , ρ ) (\theta,\rho) ( θ , ρ ) ) in each MCMC iteration, can be used within Algorithm 1 without altering the acceptance probability. To see this, observe that if L L L is added to ν ∈ W \nu\in\mathcal{W} ν ∈ W with the associated identity parameter mapping g g g , the factor arising from f L f_L f L will cancel in the definition of the acceptance probability (7). Also, the same applies when step size jittering (see e.g., Neal, [27 ] , § 3.3 ) is employed so that h h h is drawn from some distribution (not depending on ( θ , ρ ) (\theta,\rho) ( θ , ρ ) ). In that case, for each MCMC iteration, one can rely on the same (random) h h h for each of the L L L macro steps or introduce individual (random) values of h h h in each of the L L L macro steps. Then, a similar argument to the situation of randomized L L L applies with the modification that for the case of individual values of h h h , the parameter mapping g g g must reverse the order of the array corresponding to the values of h h h following the order of the macro steps (see e.g., § 2.2 ).
Langevin/diffusion-based methods
MALA
As explained in Neal [27 ] , the Metropolis adjusted Langevin Algorithm (MALA) is equivalent to the standard HMC with L = 1 L = 1 L = 1 and a full momentum refresh ([28 ] ). However, unless c = 0 c = 0 c = 0 for the given macro step (when κ \kappa κ is the Hamiltonian or the RKNF criterion), Algorithm 1 with L = 1 L = 1 L = 1 is interpreted as simply HMC with 2 c 2^{c} 2 c leapfrog steps with step size h / 2 c h/2^{c} h / 2 c . Therefore, note that Algorithm 1 with L = 1 L = 1 L = 1 is different from earlier time-step adaptive MALA variants such as Kleppe [20 ] or Biron-Lattes et al. [2 ] because the macro/micro construction is not used there, see Remark 16 of Bou-Rabee et al. [6 ] .
Kinetic Langevin
Ignoring an adaptive step size scheme, it is well known that MALA may suffer from random walk-like behaviour, in particular for high-dimensional settings. Kinetic/Generalized/second-order Langevin dynamics (see e.g., Leimkuhler and Matthews [22 ] ) introduces a persistent momentum variable to counteract such behaviour. More specifically, consider the stochastic differential equation
d θ t = M − 1 ρ t d t , d ρ t = [ ∇ θ log π ~ ( θ t ) − γ ρ t ] d t + 2 γ M 1 / 2 d B t , (24) \begin{aligned}
\mathrm{d}\theta_t &= M^{-1}\rho_t\mathrm{d}t,\\
\mathrm{d}\rho_t &= \left[\nabla_\theta\log\widetilde{\pi}(\theta_t)-\gamma\rho_t\right]\mathrm{d}t+\sqrt{2\gamma}M^{1/2}\mathrm{d}B_t, \tag*{(24)}
\end{aligned} d θ t d ρ t = M − 1 ρ t d t , = [ ∇ θ log π ( θ t ) − γ ρ t ] d t + 2 γ M 1/2 d B t , (24)
where B t B_t B t is a d d d -dimensional standard Brownian motion, γ > 0 \gamma> 0 γ > 0 is a scalar friction coefficient and M 1 / 2 M^{1/2} M 1/2 is some matrix square root of M M M . The process defined by (24) -(25) admits ∝ exp ( − H ) \propto\exp(-H) ∝ exp ( − H ) as the unique stationary distribution under weak regularity conditions on π ~ ( θ ) \widetilde{\pi}(\theta) π ( θ ) . Consequently, time-discretized versions of (24) -(25) may serve as proposal mechanisms for MCMC methods with (see e.g., [19 , 18 ] ) or without (see e.g., [22 ) and references therein] ) subsequent Metropolis corrections.
The approach of using an OBAB discretization with time step h h h (Leimkuhler and Matthews [22 ] ), together with a Metropolis correction of the leapfrog step (3) –(4) , is commonly referred to as generalized HMC (GHMC). Unlike standard HMC, GHMC retains the momentum between iterations and therefore defines a Markov chain on phase space.
More precisely, let ( θ ( n ) , ρ ( n ) ) (\theta^{(n)}, \rho^{(n)}) ( θ ( n ) , ρ ( n ) ) denote the current phase-space state. First, partially refresh the momentum according to
ρ ~ ∼ N ( exp ( − γ h ) ρ ( n ) , ( 1 − exp ( − 2 γ h ) ) M ) . (25) \widetilde{\rho} \sim N\left(\exp(-\gamma h)\rho^{(n)}, (1-\exp(-2\gamma h))M\right). \tag*{(25)} ρ ∼ N ( exp ( − γ h ) ρ ( n ) , ( 1 − exp ( − 2 γ h )) M ) . (25)
This update preserves the N ( 0 , M ) N(0,M) N ( 0 , M ) momentum distribution. Set ( θ 0 , ρ 0 ) = ( θ ( n ) , ρ ~ ) (\theta_0,\rho_0)=(\theta^{(n)},\widetilde{\rho}) ( θ 0 , ρ 0 ) = ( θ ( n ) , ρ ) , and perform one locally adaptive macro step by computing
l f = L ( θ 0 , ρ 0 , h , δ ) , ( θ 1 , ρ 1 ) = Φ h / l f l f ( θ 0 , ρ 0 ) , l^f=\mathcal{L}(\theta_0,\rho_0,h,\delta), \qquad(\theta_1,\rho_1)=\Phi_{h/l^f}^{l^f}(\theta_0,\rho_0), l f = L ( θ 0 , ρ 0 , h , δ ) , ( θ 1 , ρ 1 ) = Φ h / l f l f ( θ 0 , ρ 0 ) ,
followed by
l b = L ( θ 1 , − ρ 1 , h , δ ) . l^b=\mathcal{L}(\theta_1,-\rho_1,h,\delta). l b = L ( θ 1 , − ρ 1 , h , δ ) .
The proposal is accepted with probability
α = 1 { l f = l b } min { 1 , exp ( H ( θ 0 , ρ 0 ) − H ( θ 1 , ρ 1 ) ) } . \alpha=\mathbf{1}_{\{l^f=l^b\}}\min\left\{1,\exp\left(H(\theta_0,\rho_0)-H(\theta_1,\rho_1)\right)\right\}. α = 1 { l f = l b } min { 1 , exp ( H ( θ 0 , ρ 0 ) − H ( θ 1 , ρ 1 ) ) } .
If the proposal is accepted, set
( θ ( n + 1 ) , ρ ( n + 1 ) ) = ( θ 1 , ρ 1 ) ; (\theta^{(n+1)},\rho^{(n+1)})=(\theta_1,\rho_1); ( θ ( n + 1 ) , ρ ( n + 1 ) ) = ( θ 1 , ρ 1 ) ;
otherwise, set
( θ ( n + 1 ) , ρ ( n + 1 ) ) = ( θ 0 , − ρ 0 ) . (\theta^{(n+1)},\rho^{(n+1)})=(\theta_0,-\rho_0). ( θ ( n + 1 ) , ρ ( n + 1 ) ) = ( θ 0 , − ρ 0 ) .
Thus, the momentum is retained after each iteration, with a momentum flip upon rejection. This construction leaves the phase-space target μ ∝ exp ( − H ) \mu\propto\exp(-H) μ ∝ exp ( − H ) invariant: one iteration is the composition of the momentum refresh (26), which is an Ornstein–Uhlenbeck step preserving N ( 0 , M ) N(0,M) N ( 0 , M ) , and hence μ \mu μ , with the locally adaptive GIST Metropolis step with L = 1 L=1 L = 1 , which is μ \mu μ -reversible by § 2.3 , followed by the momentum flip F \mathcal{F} F on rejection; the last two together define a μ \mu μ -invariant, though not μ \mu μ -reversible, kernel exactly as in Horowitz [19 ] . In contrast to Algorithm 1, the position sequence alone is generally not Markov because the momentum is only partially refreshed.
Finally, it should also be mentioned that the application of the macro/micro construction to diffusion processes where the time-discretization does not involve uninterrupted leapfrog steps (i.e., BAB) such as BAOAB (see e.g., Leimkuhler and Matthews [22 ] ) is presently being investigated.
Multinomial HMC methods, biased progressive HMC and WALNUTS
Background
Multinomial HMC methods, in a broad sense encompassing biased progressive HMC, NUTS and WALNUTS, are characterized by the generation of proposals in two stages. Firstly, an orbit , consisting of the current state and one or more new candidate states, is constructed. Denote by { ( θ [ k ] , ρ [ k ] ) } k = a b \{(\theta_{[k]},\rho_{[k]})\}_{k=a}^{b} {( θ [ k ] , ρ [ k ] ) } k = a b , a = 0 , − 1 , − 2 , … a=0,-1,-2,\ldots a = 0 , − 1 , − 2 , … and b = 0 , 1 , 2 , … b=0,1,2,\ldots b = 0 , 1 , 2 , … , the set of states constituting the orbit, with the convention that ( θ [ 0 ] , ρ [ 0 ] ) (\theta_{[0]}, \rho_{[0]}) ( θ [ 0 ] , ρ [ 0 ] ) is the current state of the MCMC chain.
Fixed step size implementations of multinomial HMC methods typically generate new candidates (separated by h h h units of time) by sequentially applying R ≥ 1 R \ge1 R ≥ 1 leapfrog steps both forward and backward in time, say ( θ [ k ] , ρ [ k ] ) = Φ h / R R ( θ [ k − 1 ] , ρ [ k − 1 ] ) (\theta_{[k]}, \rho_{[k]}) = \Phi_{h/R}^{R}(\theta_{[k-1]}, \rho_{[k-1]}) ( θ [ k ] , ρ [ k ] ) = Φ h / R R ( θ [ k − 1 ] , ρ [ k − 1 ] ) , k = 1 , … , b k = 1, \ldots, b k = 1 , … , b if b ≥ 1 b \ge1 b ≥ 1 and ( θ [ k ] , ρ [ k ] ) = F ∘ Φ h / R R ∘ F ( θ [ k + 1 ] , ρ [ k + 1 ] ) (\theta_{[k]}, \rho_{[k]}) = \mathcal{F} \circ\Phi_{h/R}^{R} \circ\mathcal{F}(\theta_{[k+1]}, \rho_{[k+1]}) ( θ [ k ] , ρ [ k ] ) = F ∘ Φ h / R R ∘ F ( θ [ k + 1 ] , ρ [ k + 1 ] ) , k = − 1 , … , a k = -1, \ldots, a k = − 1 , … , a if a ≤ − 1 a \le-1 a ≤ − 1 .
Secondly, a new state of the MCMC chain is drawn from the states constituting the orbit with multinomial weights W [ k ] ∝ exp ( − H ( θ [ k ] , ρ [ k ] ) ) W_{[k]} \propto\exp(-H(\theta_{[k]}, \rho_{[k]})) W [ k ] ∝ exp ( − H ( θ [ k ] , ρ [ k ] )) . In general, there is no accept/reject step, but since the current state ( θ [ 0 ] , ρ [ 0 ] ) (\theta_{[0]}, \rho_{[0]}) ( θ [ 0 ] , ρ [ 0 ] ) is a part of the orbit, it may be selected in the second step, causing the overall MCMC to be stuck for an iteration.
As such, multinomial HMC methods are still reliant on relatively accurate simulation of the underlying Hamiltonian flow in order to keep the weights { W [ k ] } k = a b \{W_{[k]}\}_{k=a}^{b} { W [ k ] } k = a b from deviating too much from being uniform.
The different multinomial HMC methods deviate in how the orbit is constructed and also in how the multinomial sampling is performed. A full discussion of these methods is beyond the scope of this text, and the reader is referred to Hoffman and Gelman [17 ] ; Betancourt [1 ] ; Bou-Rabee et al. [7 ] for technical details and proofs of correctness. In short, the conventional multinomial HMC approach builds orbits with a fixed number of states L ∗ : = L + 1 = b − a + 1 L^{*} := L + 1 = b - a + 1 L ∗ := L + 1 = b − a + 1 , where L L L is the number of leapfrog steps as before. Given L L L , b b b is then sampled uniformly from 0 , … , L 0, \ldots, L 0 , … , L before setting a = b − L a = b - L a = b − L . On the other hand, biased progressive HMC and (WAL)NUTS build orbits by doubling the number of states of the orbit either forward or backward in time, i.e., ( a , b ) → ( a , b + L ∗ ) (a,b) \to(a,b+L^{*}) ( a , b ) → ( a , b + L ∗ ) or ( a , b ) → ( a − L ∗ , b ) (a,b) \to(a-L^{*},b) ( a , b ) → ( a − L ∗ , b ) , with equal probability. This doubling process is performed (at most) m m m times, where m m m is the prescribed number of doublings, leading to orbits consisting of 2 m 2^{m} 2 m states.
The doubling process allows the (WAL)NUTS orbit building process to stop early if a U-turn criterion is satisfied, thereby saving computations relative to obtaining the 2 m − 1 2^{m}-1 2 m − 1 new states as biased progressive HMC does.
Furthermore, provided that the multinomial weights { W [ k ] } k = a b \{W_{[k]}\}_{k=a}^{b} { W [ k ] } k = a b are close to being uniform, the doubling construction allows biased progressive HMC and most implementations of (WAL)NUTS to sample the new state from the states originating from the last doubling with high probability, thus increasing the probability that the new MCMC chain state is more distant (in ∣ k ∣ |k| ∣ k ∣ ) compared to the independent multinomial sampling, where the final index defining the next state in the chain is known to have a discrete triangular distribution centred at zero as the marginal distribution (Bou-Rabee et al., [6 ] ).
Common to the three above mentioned methods is that they ensure that the orbit building process itself is reversible, and the application of step size adaptivity as considered here would require this reversibility property to be retained. More precisely, for reversibility, it is necessary that for any state ( θ [ j ] , ρ [ j ] ) (\theta_{[j]}, \rho_{[j]}) ( θ [ j ] , ρ [ j ] ) , j ∈ { a , a + 1 , … , b } j \in\{a, a+1, \ldots, b\} j ∈ { a , a + 1 , … , b } in the original orbit { ( θ [ k ] , ρ [ k ] ) } k = a b \{(\theta_{[k]}, \rho_{[k]})\}_{k=a}^{b} {( θ [ k ] , ρ [ k ] ) } k = a b , there exists a corresponding sequence of orbit building decisions such that a (hypothetical) orbit { ( θ [ k ∗ ] ∗ , ρ [ k ∗ ] ∗ ) } k = a ∗ b ∗ \{(\theta^{*}_{[k^{*}]}, \rho^{*}_{[k^{*}]})\}_{k=a^{*}}^{b^{*}} {( θ [ k ∗ ] ∗ , ρ [ k ∗ ] ∗ ) } k = a ∗ b ∗ with current state being ( θ [ 0 ] ∗ , ρ [ 0 ] ∗ ) = F ( θ [ j ] , ρ [ j ] ) (\theta^{*}_{[0]}, \rho^{*}_{[0]}) = \mathcal{F}(\theta_{[j]}, \rho_{[j]}) ( θ [ 0 ] ∗ , ρ [ 0 ] ∗ ) = F ( θ [ j ] , ρ [ j ] ) contains exactly the momentum flipped states of the original orbit. In other words, for any j ∈ { a , a + 1 , … , b } j \in\{a, a+1, \ldots, b\} j ∈ { a , a + 1 , … , b } , one has a ∗ = j − b a^{*} = j-b a ∗ = j − b , b ∗ = j − a b^{*} = j-a b ∗ = j − a and ( θ [ j − k ] ∗ , ρ [ j − k ] ∗ ) = F ( θ [ k ] , ρ [ k ] ) (\theta^{*}_{[j-k]}, \rho^{*}_{[j-k]}) = \mathcal{F}(\theta_{[k]}, \rho_{[k]}) ( θ [ j − k ] ∗ , ρ [ j − k ] ∗ ) = F ( θ [ k ] , ρ [ k ] ) , ∀ k ∈ { a , a + 1 , … , b } \forall k \in\{a, a+1, \ldots, b\} ∀ k ∈ { a , a + 1 , … , b } . Moreover, the reversibility requires that the probability of the forward and backward orbit building decisions is the same, which is fulfilled both for the conventional multinomial HMC and the doubling construction used in (WAL)NUTS. See the proof in Appendix § 9 for the multinomial HMC case. The corresponding proof for biased progressive sampling follows closely the proof in Bou-Rabee et al. [6 ] .
Locally adaptive step sizes for multinomial HMC
Introducing locally adaptive step sizes in multinomial HMC methods involves first building the orbit using the macro step construction, i.e.,
( θ [ k ] , ρ [ k ] ) = Φ k , 0 ∣ l ( θ [ 0 ] , ρ [ 0 ] ) , ∀ k ∈ { a , a + 1 , … , − 1 , 1 , 2 , … , b } , (\theta_{[k]}, \rho_{[k]}) = \Phi_{k,0 \mid l}(\theta_{[0]}, \rho_{[0]}), \quad\forall k \in\{a, a+1, \ldots, -1, 1, 2, \ldots, b\}, ( θ [ k ] , ρ [ k ] ) = Φ k , 0 ∣ l ( θ [ 0 ] , ρ [ 0 ] ) , ∀ k ∈ { a , a + 1 , … , − 1 , 1 , 2 , … , b } ,
where the micro step counts are determined (in the case of the deterministic step size control given by (12) ) as
l k − 1 , k = L ( θ [ k − 1 ] , ρ [ k − 1 ] , h , δ ) , k = 1 , 2 , … , b , l_{k-1,k} = \mathcal{L}(\theta_{[k-1]}, \rho_{[k-1]}, h, \delta), \quad k = 1, 2, \ldots, b, l k − 1 , k = L ( θ [ k − 1 ] , ρ [ k − 1 ] , h , δ ) , k = 1 , 2 , … , b ,
and
l k , k + 1 = L ( F ( θ [ k + 1 ] , ρ [ k + 1 ] ) , h , δ ) , k = − 1 , − 2 , … , a . l_{k,k+1} = \mathcal{L}(\mathcal{F}(\theta_{[k+1]}, \rho_{[k+1]}), h, \delta), \quad k = -1, -2, \ldots, a. l k , k + 1 = L ( F ( θ [ k + 1 ] , ρ [ k + 1 ] ) , h , δ ) , k = − 1 , − 2 , … , a .
Both the leftmost index a a a and the rightmost index b b b of the orbit are decided in the same manner as for the fixed step size scenario indicated above.
Correction for possible reversibility failures is accomplished by modifying the multinomial weights used for sampling the next state j j j . More specifically, define the reversibility indicators
w [ k − 1 , k ] ′ = { 1 , if L ( θ [ k − 1 ] , ρ [ k − 1 ] , h , δ ) = L ( F ( θ [ k ] , ρ [ k ] ) , h , δ ) , 0 , otherwise, w'_{[k-1,k]} =
\begin{cases}
1, & \text{if } \mathcal{L}(\theta_{[k-1]}, \rho_{[k-1]}, h, \delta) = \mathcal{L}(\mathcal{F}(\theta_{[k]}, \rho_{[k]}), h, \delta),\\
0, & \text{otherwise,}
\end{cases} w [ k − 1 , k ] ′ = { 1 , 0 , if L ( θ [ k − 1 ] , ρ [ k − 1 ] , h , δ ) = L ( F ( θ [ k ] , ρ [ k ] ) , h , δ ) , otherwise,
with k = a + 1 , … , b k = a+1, \ldots, b k = a + 1 , … , b and the reversibility weights
r [ k ] = { 1 , if k = 0 , ∏ n = 1 k w [ n − 1 , n ] , if k ≥ 1 , ∏ n = k + 1 0 w [ n − 1 , n ] ′ , if k ≤ − 1. (26) r_{[k]} =
\begin{cases}
1, & \text{if } k = 0,\\
\prod_{n=1}^{k} w_{[n-1,n]}, & \text{if } k \ge1,\\
\prod_{n=k+1}^{0} w'_{[n-1,n]}, & \text{if } k \le-1.
\end{cases} \tag*{(26)} r [ k ] = ⎩ ⎨ ⎧ 1 , ∏ n = 1 k w [ n − 1 , n ] , ∏ n = k + 1 0 w [ n − 1 , n ] ′ , if k = 0 , if k ≥ 1 , if k ≤ − 1. (26)
For conventional multinomial HMC, conditional on the constructed orbit, the next-state index is sampled according to
P ( J = k ∣ O ) = r [ k ] exp ( − H ( θ [ k ] , ρ [ k ] ) ) ∑ j = a b r [ j ] exp ( − H ( θ [ j ] , ρ [ j ] ) ) . (27) \mathbb{P}(J = k \mid O) = \frac{r_{[k]} \exp(-H(\theta_{[k]}, \rho_{[k]}))}{\sum_{j=a}^{b} r_{[j]} \exp(-H(\theta_{[j]}, \rho_{[j]}))}. \tag*{(27)} P ( J = k ∣ O ) = ∑ j = a b r [ j ] exp ( − H ( θ [ j ] , ρ [ j ] )) r [ k ] exp ( − H ( θ [ k ] , ρ [ k ] )) . (27)
Thus, states separated from the current state by a macro step that fails the reversibility check receive zero probability.
For biased progressive HMC and WALNUTS, the quantities
r [ k ] exp ( − H ( θ [ k ] , ρ [ k ] ) ) r_{[k]} \exp(-H(\theta_{[k]}, \rho_{[k]})) r [ k ] exp ( − H ( θ [ k ] , ρ [ k ] ))
are instead used as the state weights within the recursive biased progressive selection rule of Bou-Rabee et al. (2026a, § 3.3 ). The resulting selection distribution is not, in general, the multinomial distribution (28), and correctness follows from the reversibility argument of Bou-Rabee et al. [6 ] , which will be indicated now. That argument uses three ingredients: (i) the map that re-indexes an orbit so that one of its states becomes the origin, together with the reversed sequence of doubling decisions, is a measure-preserving involution (their Lemma 17); (ii) the doubling decisions are symmetric, so that the original and the re-indexed orbit have the same probability; and (iii) the index selection kernel of biased progressive sampling satisfies an index detailed balance identity (their Lemma 6 in the fixed step size case, and Lemma 21 for WALNUTS) whose proof uses only that the state weights are invariant under re-indexing. With fixed step sizes the weights are exp ( − H ( θ [ k ] , ρ [ k ] ) ) \exp(-H(\theta_{[k]}, \rho_{[k]})) exp ( − H ( θ [ k ] , ρ [ k ] )) and this invariance is H ∘ F = H H \circ\mathcal{F} = H H ∘ F = H . With locally adaptive step sizes and weights r [ k ] exp ( − H ( θ [ k ] , ρ [ k ] ) ) r_{[k]}\exp(-H(\theta_{[k]}, \rho_{[k]})) r [ k ] exp ( − H ( θ [ k ] , ρ [ k ] )) , ingredient (i) holds on the set { r [ j ] = 1 } \{r_{[j]} = 1\} { r [ j ] = 1 } by Lemma 2 and the change of variables in the proof of Proposition 5 in Appendix § 9 ; ingredient (ii) is unchanged; and the invariance required in (iii) is exactly the identity r [ j − k ] ⋆ = r [ k ] r^{\star}_{[j-k]} = r_{[k]} r [ j − k ] ⋆ = r [ k ] of Lemma 2. For WALNUTS, the U-turn conditions are evaluated on the same states in both orbits (up to F \mathcal{F} F and index reversal, under which the U-turn criterion of Bou-Rabee et al. [6 ] is invariant), so the stopping rule is symmetric as well. The routine verification is therefore omitted and the conclusion is now recorded.
Proposition 4. The locally adaptive biased progressive HMC and WALNUTS transitions, with state weights r [ k ] exp ( − H ( θ [ k ] , ρ [ k ] ) ) r_{[k]}\exp(-H(\theta_{[k]}, \rho_{[k]})) r [ k ] exp ( − H ( θ [ k ] , ρ [ k ] )) and orbits built as described above, are π \pi π -reversible Markov kernels on R d \mathbb{R}^{d} R d .
Proof. Lemmas 17 and 21 and Theorem 22 of Bou-Rabee et al. [6 ] apply verbatim with exp ( − H ( θ [ k ] , ρ [ k ] ) ) \exp(-H(\theta_{[k]}, \rho_{[k]})) exp ( − H ( θ [ k ] , ρ [ k ] )) replaced by r [ k ] exp ( − H ( θ [ k ] , ρ [ k ] ) ) r_{[k]}\exp(-H(\theta_{[k]}, \rho_{[k]})) r [ k ] exp ( − H ( θ [ k ] , ρ [ k ] )) , the only property of the weights used there being their invariance under re-indexing, which is Lemma 2.
A self-contained proof for the conventional multinomial case is given in Appendix § 9 . The above observation is in contrast to locally adaptive step size procedures for the standard HMC counterpart, where the whole simulated Hamiltonian trajectory Φ L , 0 ∣ l \Phi_{L,0 \mid l} Φ L , 0 ∣ l must be rejected if a reversibility failure is encountered. One would therefore expect locally adaptive standard HMC to be more sensitive to reversibility failures, thus benefiting more from the improved error measures than multinomial HMC methods. This is indeed the case according to the numerical illustrations presented in the following section. In addition, based on the fact that biased progressive HMC favours final states that are more distant from the initial state compared to the standard multinomial HMC, it is also anticipated that biased progressive HMC and WALNUTS will gain slightly more from the longer trajectories produced by the flow-based measures due to fewer reversibility issues.
Numerical illustrations
To further illustrate the relative merits of the different variants of locally adaptive step size selection in different contexts, this section considers the application within HMC, GHMC, multinomial HMC, biased progressive HMC and WALNUTS for three challenging target distributions. In all combinations of the chosen error measure, the overarching MCMC method and the tuning parameters, 10 independent chains are computed. For the first two scenarios, each chain executes 100000 iterations during both the warmup and sampling period, leading to a total of 1 million samples across the 10 chains. For the stochastic volatility model, 10000 iterations are performed during both phases, collecting 100000 samples across the chains. Effective sample sizes (ESS) (Geyer, [11 ] ) based on the combined chains are then computed using the rstan::monitor function in R package rstan (Stan Development Team, [31 ] ).
The presented experiments below are by no means claiming that the tuning employed for each combination of the target distribution, MCMC method and error measure is the optimal in any sense. Instead, the choices with respect to the tuning parameters are made to give insight into the relative strengths and weaknesses of the different error measures in varying contexts. In particular, the actual strategies/objectives for optimally tuning the different combinations of error measure and MCMC methods may differ across this spectrum, e.g., controlling P ( c = c min ) P(c = c_{\min}) P ( c = c m i n ) to ensure infrequent reversibility failures for the energy error measure κ H \kappa_H κ H as in Bou-Rabee et al. [5 ] may be less relevant for the alternative error measures. Finding the best such strategy for each particular combination is left for future research. When tuning of δ \delta δ is performed for the multinomial HMC methods, the following quantity
Δ = max j ∈ C 0 H ( θ j , ρ j ) − min j ∈ C 0 H ( θ j , ρ j ) \Delta= \max_{j \in C_0} H(\theta_j,\rho_j) - \min_{j \in C_0} H(\theta_j,\rho_j) Δ = j ∈ C 0 max H ( θ j , ρ j ) − j ∈ C 0 min H ( θ j , ρ j )
is relevant. In other words, Δ \Delta Δ represents the largest deviation in the energy among the reachable states of an orbit, i.e., C 0 : = { k ∈ { a , … , b } : r [ k ] = 1 } C_0 := \{k \in\{a,\ldots,b\}: r_{[k]} = 1\} C 0 := { k ∈ { a , … , b } : r [ k ] = 1 } , see e.g., Appendix § 9 . Therefore, states obtained after a macro step that fails reversibility are not included in the definition of Δ \Delta Δ . The same applies for tuning of h h h , where P ( c = c min ) P(c = c_{\min}) P ( c = c m i n ) is the achieved rate of macro steps leading to reachable states with c = c min c = c_{\min} c = c m i n , see Appendix E for further details.
AR(1) model
The first model considered is the marginally standard Gaussian AR(1)/Toeplitz model, characterized by
θ 1 ∼ N ( 0 , 1 ) , θ t ∣ θ t − 1 ∼ N ( φ θ t − 1 , 1 − φ 2 ) , t = 2 , … , d . (28) \theta_1 \sim N(0,1),\ \theta_t \mid\theta_{t-1} \sim N(\varphi\theta_{t-1},1-\varphi^2),\ t = 2,\ldots,d. \tag*{(28)} θ 1 ∼ N ( 0 , 1 ) , θ t ∣ θ t − 1 ∼ N ( φ θ t − 1 , 1 − φ 2 ) , t = 2 , … , d . (28)
In particular, d = 100 d = 100 d = 100 and φ = 0.95 \varphi= 0.95 φ = 0.95 are considered here, leading to a correlated high-dimensional setting where the approach of locally adapting the step size should be beneficial.
Standard HMC and GHMC
Tables 4 and 5 provide diagnostic results and performance results for standard HMC and GHMC, respectively. For standard HMC, h = 0.25 h = 0.25 h = 0.25 is chosen for the macro step size while the number of macro steps L L L is drawn independently in each iteration as L = max ( 1 , L ~ ) L = \max(1,\widetilde{L}) L = max ( 1 , L ) with L ~ ∼ Poisson ( 16 ) \widetilde{L} \sim\operatorname{Poisson}(16) L ∼ Poisson ( 16 ) , in the spirit of randomized HMC (Bou-Rabee and Sanz-Serna, [3 ] ), in order to avoid the resonances that a fixed integration time can produce (Neal, [27 ] , § 4.2 ).
For GHMC (i.e., L = 1 L = 1 L = 1 ), the macro step size is set to h = 1.0 h = 1.0 h = 1.0 while the friction coefficient is selected so that the momentum refreshes have an autocorrelation of exp ( − γ h ) = 0.95 \exp(-\gamma h) = 0.95 exp ( − γ h ) = 0.95 . The same values of L L L and h h h are used for each error measure so that the proposals will have similar characteristics.
For standard HMC, tuning of the error threshold δ \delta δ is performed to achieve an expected Metropolis acceptance rate of around 70%. For GHMC, the corresponding target value of the same quantity is 90%. For both standard HMC and GHMC, it is seen from Table 4 that in order to achieve the desired acceptance rate, δ \delta δ has to be chosen rather small for the Hamiltonian error measure. In addition, for the Hamiltonian error measure, the reversibility rate is almost equal to the Metropolis rate, suggesting that close to all rejections are due to reversibility failures.
Table 4. Reversibility and diagnostic results of the AR(1) model (29) using standard HMC and GHMC. Results are based on 10 independent chains, each with 100000 iterations. Reversibility rate gives the proportion of transitions with ∏ j = 1 L w j ′ = 1 \prod_{j=1}^{L} w'_j = 1 ∏ j = 1 L w j ′ = 1 (see Equation (13) ) and Metropolis rate is the estimated expected value of (13). N n o d e N_{\mathrm{node}} N node is the number of gradient evaluations required to obtain the samples. Here, c min = 0 c_{\min} = 0 c m i n = 0 for H and RKNF, and c min = 1 c_{\min} = 1 c m i n = 1 for MRF.
The flow-based error measures do not experience such a scenario, allowing the selection of δ \delta δ that attains the desired acceptance ratio with a large proportion of rejections being due to the inaccurate flow simulation. Since the Hamiltonian error measure requires substantially more gradient evaluations to obtain the desired acceptance ratio, the sampling performance (see Table 5 ) of the flow-based measures is better. In case of standard HMC, an order of magnitude is observed.
Table 5. ESS results of AR(1) model (29) using standard HMC and GHMC. Results are based on 10 independent chains, each with 100000 iterations. Effective sample sizes are calculated across the chains. In both cases, c min = 0 c_{\min} = 0 c m i n = 0 for H and RKNF, and c min = 1 c_{\min} = 1 c m i n = 1 for MRF.
Multinomial HMC, Biased progressive HMC and WALNUTS
For the “rejection-free” methods like the multinomial HMC, biased progressive HMC and WALNUTS, two situations are considered. In the former, for all three samplers, h = 0.25 h = 0.25 h = 0.25 . For the multinomial HMC, the number of leapfrog steps L L L is set to 32 so that the total number of states in an orbit is L ∗ = L + 1 = 33 L^* = L + 1 = 33 L ∗ = L + 1 = 33 . For the case of biased progressive HMC and WALNUTS, the (maximum for WALNUTS) number of doublings m m m is chosen to be 5 so that the (maximum) number of states is 2 m = 2 5 = 32 2^m = 2^5 = 32 2 m = 2 5 = 32 and comparable to the multinomial case. δ \delta δ is tuned so that Δ ≤ 0.2 \Delta\le0.2 Δ ≤ 0.2 for around 80% of the generated orbits. Various diagnostic information for this situation is given in the upper half of Table 6 , while information related to the sampling performance is presented in the upper half of Table 7 . The macro step size is chosen to be rather large in this situation so that non-trivial adaptation of step sizes, that is c > c min c > c_{\min} c > c m i n , happens in the majority of the macro steps. It is observed from Table 6 that this practice leads to a large proportion of orbits having dead ends, i.e., some of the states in the generated orbit are not reachable as they are beyond the point of reversibility failures, for the energy error measure κ H \kappa_H κ H . This proportion is greatly reduced for the flow-based error measures, with MRF giving slightly fewer reversibility failures than RKNF for all three MCMC methods.
Table 6. Diagnostic results of AR(1) model (29) for the multinomial HMC methods. Results are based on 10 independent chains, each with 100000 iterations. Effective sample sizes are calculated across the chains. Here, Δ = max j ∈ C 0 H ( θ j , ρ j ) − min j ∈ C 0 H ( θ j , ρ j ) \Delta= \max_{j \in C_0} H(\theta_j,\rho_j) - \min_{j \in C_0} H(\theta_j,\rho_j) Δ = max j ∈ C 0 H ( θ j , ρ j ) − min j ∈ C 0 H ( θ j , ρ j ) and c min = 0 c_{\min} = 0 c m i n = 0 for H and RKNF, and c min = 1 c_{\min} = 1 c m i n = 1 for MRF. For a given final value of h h h after tuning, the corresponding value of L L L for the multinomial HMC is set to ⌈ h 0 L 0 / h ⌉ \lceil h_0L_0/h\rceil ⌈ h 0 L 0 / h ⌉ , where h 0 = 0.25 h_0 = 0.25 h 0 = 0.25 , L 0 = 32 L_0 = 32 L 0 = 32 and ⌈ ⋅ ⌉ \lceil\cdot\rceil ⌈ ⋅ ⌉ denotes the ceiling function. Similarly for biased progressive HMC and WALNUTS, the corresponding value of m m m is ⌈ log 2 ( ( 2 m 0 − 1 ) h 0 / h + 1 ) ⌉ \lceil\log_2((2^{m_0}-1)h_0/h+1)\rceil ⌈ log 2 (( 2 m 0 − 1 ) h 0 / h + 1 )⌉ , where m 0 = 5 m_0 = 5 m 0 = 5 . This ensures that the (maximum) path length after tuning is at least as long as the initial path length defined by h 0 h_0 h 0 and either L 0 L_0 L 0 or m 0 m_0 m 0 depending on the given sampler.
Table 7. Performance results of AR(1) model (28) for the multinomial HMC methods. Results are based on 10 independent chains, each with 100000 iterations. Effective sample sizes are calculated across the chains. See the caption of Table 6 for further details.
Regarding the sampling performance, in this situation, where active use of the adaptive step size mechanism is very prevalent, it is seen from Table 7 that the flow-based error measures recapture the higher computational cost per step (in terms of ESS/gradient evaluation) in many cases, with the effect possibly being stronger for biased progressive HMC and WALNUTS (as they benefit more from longer runs of reversible macro steps), except for the single case of MRF using biased progressive HMC. In other words, the prevalence of dead ends for κ H \kappa_H κ H leads to much lower raw ESS values with the difference arguably being larger for the biased progressive methods.
The lower halves of Table 6 and Table 7 consider a situation where the macro step size h h h is also tuned towards P ( c = c min ) = 0.8 P(c = c_{\min}) = 0.8 P ( c = c m i n ) = 0.8 (in addition to δ \delta δ towards P ( Δ < 0.2 ) = 0.8 P(\Delta< 0.2) = 0.8 P ( Δ < 0.2 ) = 0.8 as before), which is similar to the strategy used in Bou-Rabee et al. [6 ] . Based on the tuned h h h , for the multinomial HMC, L L L is chosen so that the path length is at least as long as the initial path length of 32 · 0.25 = 8 time units. Similarly, for biased progressive HMC and WALNUTS, m m m is chosen so that the (maximum for WALNUTS) path length is larger than or equal to ( 2 5 − 1 ) ⋅ 0.25 = 7.75 (2^5 - 1) \cdot0.25 = 7.75 ( 2 5 − 1 ) ⋅ 0.25 = 7.75 time units.
Employing tuned, smaller macro step sizes reduces the prevalence of dead ends for H and RKNF (even if the orbits involve more macro steps), whereas the corresponding figures for MRF are more similar across choices of h h h in this case. From Table 7 , it is quite clear that the additional computational cost of the flow-based error measures does not pay off for the multinomial methods in this situation, as H produces similar values of raw ESS as the others with less computational cost. The exception is biased progressive HMC, where the number of raw ESS produced by H is roughly half of the other alternatives. Nevertheless, the energy criterion only performs only one fifth as many gradient evaluations as the flow-based criteria, leading to more ESS produced per gradient evaluation.
Neal's funnel model
In this section, a similar study is performed for a version of Neal’s funnel model [26 ] . More specifically, consider the following model:
θ 1 ∼ N ( 0 , 3 2 ) , θ i ∣ θ 1 ∼ iid N ( 0 , exp ( θ 1 ) ) , i = 2 , … , d . (29) \theta_1 \sim N(0,3^2),\ \theta_i \mid\theta_1 \sim\operatorname{iid} N(0,\exp(\theta_1)),\ i=2,\ldots,d. \tag*{(29)} θ 1 ∼ N ( 0 , 3 2 ) , θ i ∣ θ 1 ∼ iid N ( 0 , exp ( θ 1 )) , i = 2 , … , d . (29)
For this example, the dimension d d d is set to d = 10 d=10 d = 10 . The joint distribution is known to have complicated geometric properties resembling a funnel shape such that standard HMC methods with fixed step size tend to struggle to explore the whole distribution (see e.g., Kleppe [21 ] , Bou-Rabee et al. [6 ] and references therein). As such, the funnel distribution typically requires substantially larger variation in the step sizes compared to the above considered AR(1) model. Fixed step size implementations would therefore require very small step sizes and large numbers of integration steps in each iteration to fully explore the target distribution.
Standard HMC and GHMC
Table 8. Diagnostic results for Neal’s funnel model (29) using standard HMC and GHMC. Results are based on 10 independent chains, each with 100000 iterations. Reversibility rate gives the proportion of transitions with ∏ j = 1 L w j ′ = 1 \prod_{j=1}^{L} w'_j=1 ∏ j = 1 L w j ′ = 1 (see Equation (13) ) and Metropolis rate is the estimated expected value of (13). N o d e N_{\mathrm{ode}} N ode is the number of gradient evaluations required to obtain the samples.
Tables 8 and 9 provide diagnostic information and performance results for standard HMC and GHMC (h = 1 h=1 h = 1 and exp ( − γ h ) = 0.95 \exp(-\gamma h)=0.95 exp ( − γ h ) = 0.95 ). For standard HMC, δ \delta δ is tuned towards a 70% Metropolis acceptance probability. Note that for moderate L L L (say ≤ 16 \le16 ≤ 16 ), standard leapfrog HMC at macro step size h ≈ 0.40 h\approx0.40 h ≈ 0.40 attains a 70% Metropolis acceptance probability for this model (i.e., δ = ∞ \delta=\infty δ = ∞ ), but produces biased samples as the narrow part of the funnel is rarely visited. Consequently, macro step sizes are chosen larger than h = 0.40 h = 0.40 h = 0.40 to avoid the adaptive methods becoming insensitive to δ \delta δ .
For the H and RKNF criteria, L = 4 L = 4 L = 4 macro steps of size h = 0.5 h = 0.5 h = 0.5 are chosen. For H, at larger L L L with h = 0.5 h = 0.5 h = 0.5 , the acceptance rate is non-monotone in δ \delta δ and peaks below 70%, so no threshold achieves the target. Reducing to L = 4 L = 4 L = 4 restores monotonicity and makes the target achievable. The required δ = 0.031 \delta= 0.031 δ = 0.031 incurs a reversibility failure rate of roughly 29%. The RKNF criterion with the same combination of h h h and L L L is better behaved: the acceptance rate decreases monotonically as δ \delta δ increases, and the target is achieved when δ = 0.4 \delta= 0.4 δ = 0.4 with a reversibility failure rate of only around 9%. For the MRF criterion with h ≤ 0.5 h \le0.5 h ≤ 0.5 (and therefore a micro step size ≤ 0.25 \le0.25 ≤ 0.25 ), the acceptance rate is substantially larger than 70% for any δ \delta δ . Reaching 70% therefore requires a much larger step size, where h = 1.0 h = 1.0 h = 1.0 is chosen.
The results in Table 9 are comparable with what is found for the standard HMC and GHMC in the case of the AR(1) model. Except for the min ESS parameter in the standard HMC scenario using the MRF criterion, the flow-based measures offer substantial improvements in sampling efficiency relative to H.
Table 9. ESS results for Neal’s funnel model (30) using standard HMC and GHMC. Results are based on 10 independent chains, each with 100000 iterations. Effective sample sizes are calculated across the chains.
Multinomial HMC, Biased progressive HMC and WALNUTS
Tables 10 and 11 provide diagnostic and performance information of multinomial HMC methods for Neal’s funnel model (30). As for the AR(1) model, two situations are considered, either with fixed macro step size h h h or with h h h tuned towards P ( c = c min ) = 0.8 P(c = c_{\min}) = 0.8 P ( c = c m i n ) = 0.8 . For the fixed step size simulations, the orbits of multinomial HMC are chosen to consist of L ∗ = L + 1 = 17 L^* = L + 1 = 17 L ∗ = L + 1 = 17 states. For the biased progressive HMC, m = 4 m = 4 m = 4 while m = 7 m = 7 m = 7 for the WALNUTS case as it can adaptively choose the final orbit size at each iteration. With these choices, a rather comparable number of gradient evaluations across the three samplers is obtained. In the fixed h h h case with WALNUTS and MRF error measure, the chosen h h h yields near compliance with the P ( Δ ≤ 0.2 ) P(\Delta\le0.2) P ( Δ ≤ 0.2 ) -criterion for a wide range of δ \delta δ -values. This is due to the c min = 1 c_{\min}=1 c m i n = 1 floor of MRF, which in this case is already adequate to obtain the desired accuracy. Thus, δ \delta δ is set to 25, corresponding to the rather arbitrary largest value considered. In this setting, the adaptive step size mechanism only guards against single macro step divergences. Based on the presented results, reversibility failures for the H-measure appear not to be performance limiting for this particular model, and the increased computational cost of the flow-based error measures does not pay off in faster sampling efficiency.
Table 10. Diagnostic results for multinomial HMC methods applied to Neal’s funnel model (30). Here Δ = max j ∈ C 0 H ( θ j , ρ j ) − min j ∈ C 0 H ( θ j , ρ j ) \Delta= \max_{j\in C_0} H(\theta_j,\rho_j)-\min_{j\in C_0} H(\theta_j,\rho_j) Δ = max j ∈ C 0 H ( θ j , ρ j ) − min j ∈ C 0 H ( θ j , ρ j ) . For the lower half where h h h is tuned, the value of L L L for the multinomial HMC is set to ⌈ h 0 L 0 / h ⌉ \lceil h_0L_0/h\rceil ⌈ h 0 L 0 / h ⌉ , where h 0 = 0.25 h_0=0.25 h 0 = 0.25 and L 0 = 16 L_0=16 L 0 = 16 . Similarly for biased progressive HMC and WALNUTS, the corresponding values of m m m are ⌈ log 2 ( ( 2 m 0 − 1 ) h 0 / h + 1 ) ⌉ \lceil\log_2((2^{m_0}-1)h_0/h+1)\rceil ⌈ log 2 (( 2 m 0 − 1 ) h 0 / h + 1 )⌉ , where m 0 = 4 m_0=4 m 0 = 4 for biased progressive HMC and m 0 = 7 m_0=7 m 0 = 7 for WALNUTS. This ensures that the (maximum) path length after tuning is at least as long as the initial path length defined by h 0 h_0 h 0 and either L 0 L_0 L 0 or m 0 m_0 m 0 depending on the given sampler.
Overall, the picture of Neal’s funnel distribution in the current setting is somewhat dissimilar to the one obtained from the AR(1) model. In this case, the orbits chosen by (WAL)NUTS do not involve a sufficient number of macro steps to warrant more elaborate flow-based error measures.
Stochastic volatility model with leverage
As a more challenging real data example, a stochastic volatility model with leverage (see e.g., Yu [32 ] ) is considered.
Here, the same data set of T = 2515 T=2515 T = 2515 log-return observations y = ( y 1 , … , y T ) y=(y_1,\ldots,y_T) y = ( y 1 , … , y T ) of the S&P500 index from October 1st 1999 to September 30th 2009 examined in Grothe et al. [14 ] is used. Let x = ( x 0 , … , x T ) x = (x_0, \ldots, x_T) x = ( x 0 , … , x T ) correspond to the latent log-volatilities. Given the volatility scale parameter σ > 0 \sigma> 0 σ > 0 and the leverage parameter α ∈ ( − 1 , 1 ) \alpha\in(-1, 1) α ∈ ( − 1 , 1 ) , the joint process is modeled as
Table 11. Performance results for multinomial HMC methods applied to Neal’s funnel model (30). See caption of Table 10 for further details.
( y t , x t ) T ∣ x t − 1 ∼ N ( ( 0 , x t − 1 ) T , V t − 1 ) , V t − 1 = ( exp ( x t − 1 ) α σ exp ( x t − 1 / 2 ) α σ exp ( x t − 1 / 2 ) σ 2 ) . (y_t, x_t)^{T} \mid x_{t-1} \sim\mathcal{N}((0, x_{t-1})^{T}, V_{t-1}), \quad V_{t-1} =
\begin{pmatrix}
\exp(x_{t-1}) & \alpha\sigma\exp(x_{t-1}/2) \\
\alpha\sigma\exp(x_{t-1}/2) & \sigma^2
\end{pmatrix}. ( y t , x t ) T ∣ x t − 1 ∼ N (( 0 , x t − 1 ) T , V t − 1 ) , V t − 1 = ( exp ( x t − 1 ) α σ exp ( x t − 1 /2 ) α σ exp ( x t − 1 /2 ) σ 2 ) .
It is often seen for stock index data that negative returns tend to be associated with increases in volatility [32 ] , hence negative correlation α \alpha α is typically observed.
Instead of sampling directly from x x x , the a priori standard Gaussian driving variables z = ( z 1 , … , z T ) z = (z_1, \ldots, z_T) z = ( z 1 , … , z T ) are introduced so that the observationally equivalent model may be summarized as
z t ∼ N ( 0 , 1 ) , t = 1 , … , T , (30) z_t \sim N(0,1),\ t = 1,\ldots,T, \tag*{(30)} z t ∼ N ( 0 , 1 ) , t = 1 , … , T , (30)
x t ∣ z t , x t − 1 = x t − 1 + σ z t , t = 1 , … , T , (31) x_t \mid z_t, x_{t-1} = x_{t-1} + \sigma z_t,\ t = 1,\ldots,T, \tag*{(31)} x t ∣ z t , x t − 1 = x t − 1 + σ z t , t = 1 , … , T , (31)
y t ∣ z t , x t − 1 ∼ N ( α z t exp ( x t − 1 / 2 ) , ( 1 − α 2 ) exp ( x t − 1 ) ) , t = 1 , … , T . (32) y_t \mid z_t, x_{t-1} \sim N\left(\alpha z_t \exp(x_{t-1}/2), (1-\alpha^2)\exp(x_{t-1})\right),\ t = 1,\ldots,T. \tag*{(32)} y t ∣ z t , x t − 1 ∼ N ( α z t exp ( x t − 1 /2 ) , ( 1 − α 2 ) exp ( x t − 1 ) ) , t = 1 , … , T . (32)
To finalize the model specification, the priors x 0 ∼ N ( μ 0 , σ 0 2 ) x_0 \sim N(\mu_0,\sigma_0^2) x 0 ∼ N ( μ 0 , σ 0 2 ) , σ 2 ∼ 0.1 / χ 10 2 \sigma^2 \sim0.1/\chi_{10}^2 σ 2 ∼ 0.1/ χ 10 2 and α ∼ Unif ( − 1 , 1 ) \alpha\sim\operatorname{Unif}(-1,1) α ∼ Unif ( − 1 , 1 ) are specified together with the following transformations to obtain unconstrained parameters:
σ = exp ( υ ) , α = − 1 + 2 exp ( η ) 1 + exp ( η ) . \sigma= \exp(\upsilon),\ \alpha= -1 + \frac{2\exp(\eta)}{1+\exp(\eta)}. σ = exp ( υ ) , α = − 1 + 1 + exp ( η ) 2 exp ( η ) .
Here, μ 0 ≈ − 8.54 \mu_0 \approx-8.54 μ 0 ≈ − 8.54 based on the logarithm of the variance of the observation vector y 1 : T y_{1:T} y 1 : T and σ 0 \sigma_0 σ 0 is chosen to be 10. Therefore, the vector of sampled variables corresponds to θ = ( η , υ , x 0 , z 1 : T ) \theta= (\eta,\upsilon,x_0,z_{1:T}) θ = ( η , υ , x 0 , z 1 : T ) . Funnel-effects stemming from sampling σ \sigma σ jointly with x 0 : T x_{0:T} x 0 : T are removed by the introduction of the driving variables z t z_t z t . However, α \alpha α also interacts with both the location and scale of z t z_t z t under the posterior distribution, and the model is therefore expected to exhibit funnel-like behaviour which is not easily removed through reparameterizations. Using the above parameterization, η \eta η mixes substantially slower than the remaining components when using HMC-like methods.
For this particular example, only the scenarios of fixed h h h GHMC and fixed h h h and m m m WALNUTS are considered. In both cases, the macro step size h h h is chosen to be quite large. In other words, reduction of reversibility failures through increasing the prevalence of c = c min c = c_{\min} c = c m i n is deliberately not attempted to achieve a situation where micro step sizes are chosen fully by the step size controller with P ( c = c min ) P(c = c_{\min}) P ( c = c m i n ) close to zero. As such, this situation would give more insight into the relative reversibility failure prevalence also in the case where the relevant micro step sizes are much smaller than the macro step size. In all cases, δ \delta δ is tuned in order to obtain a desired acceptance probability/log-weight variability.
caption: ESS results for the stochastic volatility model defined by (31)-(33) using GHMC. Results are based on 10 independent chains, each with 10000 iterations. Effective sample sizes are calculated across the chains.
:::
GHMC
For GHMC with h = 1 h = 1 h = 1 , δ \delta δ is tuned to achieve a Metropolis acceptance rate close to 90%. Ten independent chains are generated, where 10000 iterations are performed for both the warmup and the sampling period for each chain. Table 12 shows that the reversibility rate is almost identical to the obtained Metropolis rate for the Hamiltonian criterion, indicating again that almost all rejections are caused by the reversibility failures of the adaptive step size procedures. Interestingly, a similar behaviour is observed for the MRF criterion too. The RKNF criterion appears to have rejections based on both reversibility issues and standard Metropolis rejections. Thus, in order to achieve the desired target of Metropolis acceptance rate, the RKNF criterion requires far fewer gradient evaluations. This is reflected in the performance results presented in Table 13. Although the raw ESS values are rather comparable across the three approaches, the RKNF approach is indeed the most efficient when considering the number of ESS per gradient evaluation.
Table 12. Diagnostic results for the stochastic volatility model defined by (30) –(32) using GHMC. Results are based on 10 independent chains, each with 10000 iterations. Reversibility rate gives the proportion of transitions with ∏ j = 1 L w j ′ = 1 \prod_{j=1}^{L} w'_j = 1 ∏ j = 1 L w j ′ = 1 (see Equation (13) ) and Metropolis rate is the estimated expected value of (13). N n o d e N_{\mathrm{node}} N node is the number of gradient evaluations required to obtain the samples.
WALNUTS
Next, the stochastic volatility model is examined using WALNUTS with a fixed macro step size of h = 0.25 h = 0.25 h = 0.25 and m = 5 m = 5 m = 5 , and δ \delta δ is tuned so that P ( Δ ≤ 0.2 ) P(\Delta\le0.2) P ( Δ ≤ 0.2 ) is roughly 0.8 similar to the previous experiments. Table 14 provides diagnostic statistics, with the RKNF approach leading to the smallest ratio of orbits with at least one dead end due to reversibility issues. The MRF criterion has again a higher ratio of orbits with at least one dead end than RKNF, but far lower than for the Hamiltonian criterion, for which roughly 87% of the 100000 orbits will experience a reversibility issue in one of the directions.
Table 14. Diagnostic results for WALNUTS applied to the stochastic volatility model (31)-(33). Here Δ = max j ∈ C 0 H ( θ j , ρ j ) − min j ∈ C 0 H ( θ j , ρ j ) \Delta= \max_{j\in C_0} H(\theta_j,\rho_j) - \min_{j\in C_0} H(\theta_j,\rho_j) Δ = max j ∈ C 0 H ( θ j , ρ j ) − min j ∈ C 0 H ( θ j , ρ j ) .
Consequently, based on the results of Table 15 , the RKNF criterion leads to the largest values of raw ESS and ESS per gradient evaluation. However, although the raw ESS of the MRF criterion is larger, it uses roughly twice as many gradient evaluations as the Hamiltonian criterion. Therefore, the reduction in the reversibility failure ratio only leads to a slight increase in the number of ESS per gradient evaluation for the latent variables.
Table 15. Performance results for WALNUTS applied to the stochastic volatility model (31)–(33). See caption of Table 14 for further details.
To conclude, for this particular, more realistic model, and without the aid of a carefully tuned macro step size, it clearly appears that RKNF provides substantial computational advantage, even for multinomial methods such as WALNUTS, especially for the latent states.
Discussion
This paper has carefully explained and illustrated the locally adaptive step size procedure of Bou-Rabee et al. [6 ] under more general assumptions. Also, further error measures with the aim of reducing reversibility failures have been developed and introduced. It is also shown how to introduce the locally adaptive step sizes into standard HMC and Metropolis-corrected kinetic Langevin/GHMC. Finally, a numerical study of the relative merits of the proposed error measures in the context of different Hamiltonian flow-based MCMC methods has been presented.
It is believed that any general purpose Hamiltonian flow-based MCMC code should employ such adaptive step size procedures. In particular, the most significant finding from the numerical study is that non-multinomial HMC methods such as the standard HMC and kinetic Langevin/GHMC may benefit more from improved error measures. In contrast, energy errors seem to be working well for certain models using the conventional multinomial HMC. Still, for the two models considered in § 5.1 and § 5.2 , the orbit sizes are relatively modest, and it is conceivable that other models which would require larger orbits could benefit more from the flow-based error measures. For instance, the results from the stochastic volatility model examined in § 5.3 already show that one of the flow-based error measures outperforms the energy error when using WALNUTS.
The paper should to some degree be read as an invitation to further work, where optimal tuning for given combinations of error measures and overarching MCMC methods should be considered. In addition, extending the locally adaptive step sizes also to other forms of flow, as indicated in § 3.6 , and the BAOAB integrator for Langevin-type models are currently being investigated.
Supplementary material to "Locally adaptive step sizes for Hamiltonian Monte Carlo methods" by Jimmy Huy Tran, Tore Selland Kleppe and Nawaf Bou-Rabee
Proofs
Proof of Proposition 2
Proof. Recall that Φ ˉ h / l \bar{\Phi}_{h/l} Φ ˉ h / l denotes the embedded third-order RKN comparison map defined by (17) –(19) . This map is used only to estimate the error of a leapfrog microstep; the numerical trajectory itself is advanced using the leapfrog map Φ h / l \Phi_{h/l} Φ h / l .
Let
z 0 = ( θ , ρ ) , z k : = Φ h / l k ( z 0 ) , k = 0 , … , l . z_0=(\theta,\rho),\qquad z_k:=\Phi_{h/l}^{k}(z_0),\qquad k=0,\ldots,l. z 0 = ( θ , ρ ) , z k := Φ h / l k ( z 0 ) , k = 0 , … , l .
For each k = 1 , … , l k=1,\ldots,l k = 1 , … , l , define
f k : = ∥ z k − Φ ˉ h / l ( z k − 1 ) ∥ , f_k:=\left\lVert z_k-\bar{\Phi}_{h/l}(z_{k-1})\right\rVert, f k := z k − Φ ˉ h / l ( z k − 1 ) ,
b k : = ∥ F ( z k − 1 ) − Φ ˉ h / l ∘ F ( z k ) ∥ . b_k:=\left\lVert\mathcal{F}(z_{k-1})-\bar{\Phi}_{h/l}\circ\mathcal{F}(z_k)\right\rVert. b k := F ( z k − 1 ) − Φ ˉ h / l ∘ F ( z k ) .
Thus,
κ R K N N F ( z 0 , h , l ) = max 1 ≤ k ≤ l max { f k , b k } . \kappa_{\mathrm{RKNNF}}(z_0,h,l)=\max_{1\leq k\leq l}\max\{f_k,b_k\}. κ RKNNF ( z 0 , h , l ) = 1 ≤ k ≤ l max max { f k , b k } .
Now consider the leapfrog trajectory beginning at the momentum-flipped endpoint of the original trajectory:
z ~ 0 : = F ( z l ) , z ~ j : = Φ h / l j ( z ~ 0 ) , j = 0 , … , l . \widetilde{z}_0:=\mathcal{F}(z_l),\qquad\widetilde{z}_j:=\Phi_{h/l}^{j}(\widetilde{z}_0),\qquad j=0,\ldots,l. z 0 := F ( z l ) , z j := Φ h / l j ( z 0 ) , j = 0 , … , l .
The time reversibility of the leapfrog integrator implies that
Φ h / l j ∘ F = F ∘ Φ h / l − j . \Phi_{h/l}^{j}\circ\mathcal{F}=\mathcal{F}\circ\Phi_{h/l}^{-j}. Φ h / l j ∘ F = F ∘ Φ h / l − j .
Consequently,
z ~ j = Φ h / l j ∘ F ∘ Φ h / l l ( z 0 ) = F ∘ Φ h / l − j ∘ Φ h / l l ( z 0 ) = F ∘ Φ h / l l − j ( z 0 ) = F ( z l − j ) . \begin{aligned}
\widetilde{z}_j&=\Phi_{h/l}^{j}\circ\mathcal{F}\circ\Phi_{h/l}^{l}(z_0)\\
&=\mathcal{F}\circ\Phi_{h/l}^{-j}\circ\Phi_{h/l}^{l}(z_0)\\
&=\mathcal{F}\circ\Phi_{h/l}^{l-j}(z_0)\\
&=\mathcal{F}(z_{l-j}).
\end{aligned} z j = Φ h / l j ∘ F ∘ Φ h / l l ( z 0 ) = F ∘ Φ h / l − j ∘ Φ h / l l ( z 0 ) = F ∘ Φ h / l l − j ( z 0 ) = F ( z l − j ) .
For the trajectory { z ~ j } j = 0 l \{\widetilde{z}_j\}_{j=0}^{l} { z j } j = 0 l , define the corresponding error terms, for j = 1 , … , l j=1,\ldots,l j = 1 , … , l , by
f ~ j : = ∥ z ~ j − Φ ‾ h / l ( z ~ j − 1 ) ∥ , b ~ j : = ∥ F ( z ~ j − 1 ) − Φ ‾ h / l ∘ F ( z ~ j ) ∥ . \begin{aligned}
\widetilde{f}_j &:= \lVert\widetilde{z}_j-\overline{\Phi}_{h/l}(\widetilde{z}_{j-1})\rVert,\\
\widetilde{b}_j &:= \lVert\mathcal{F}(\widetilde{z}_{j-1})-\overline{\Phi}_{h/l}\circ\mathcal{F}(\widetilde{z}_j)\rVert.
\end{aligned} f j b j := ∥ z j − Φ h / l ( z j − 1 )∥ , := ∥ F ( z j − 1 ) − Φ h / l ∘ F ( z j )∥ .
Using z ~ j = F ( z l − j ) \widetilde{z}_j=\mathcal{F}(z_{l-j}) z j = F ( z l − j ) , one obtains
f ~ j = ∥ F ( z l − j ) − Φ ‾ h / l ∘ F ( z l − j + 1 ) ∥ = b l − j + 1 , \begin{aligned}
\widetilde{f}_j
&=\lVert\mathcal{F}(z_{l-j})-\overline{\Phi}_{h/l}\circ\mathcal{F}(z_{l-j+1})\rVert\\
&=b_{l-j+1},
\end{aligned} f j = ∥ F ( z l − j ) − Φ h / l ∘ F ( z l − j + 1 )∥ = b l − j + 1 ,
and, using F ∘ F = Id \mathcal{F}\circ\mathcal{F}=\operatorname{Id} F ∘ F = Id ,
b ~ j = ∥ F ∘ F ( z l − j + 1 ) − Φ ‾ h / l ∘ F ∘ F ( z l − j ) ∥ = ∥ z l − j + 1 − Φ ‾ h / l ( z l − j ) ∥ = f l − j + 1 . \begin{aligned}
\widetilde{b}_j
&=\lVert\mathcal{F}\circ\mathcal{F}(z_{l-j+1})-\overline{\Phi}_{h/l}\circ\mathcal{F}\circ\mathcal{F}(z_{l-j})\rVert\\
&=\lVert z_{l-j+1}-\overline{\Phi}_{h/l}(z_{l-j})\rVert\\
&=f_{l-j+1}.
\end{aligned} b j = ∥ F ∘ F ( z l − j + 1 ) − Φ h / l ∘ F ∘ F ( z l − j )∥ = ∥ z l − j + 1 − Φ h / l ( z l − j )∥ = f l − j + 1 .
Since j ↦ l − j + 1 j\mapsto l-j+1 j ↦ l − j + 1 is a bijection of { 1 , … , l } \{1,\ldots,l\} { 1 , … , l } , it follows that
κ R K F N ( z ~ 0 , h , l ) = max 1 ≤ j ≤ l max { f ~ j , b ~ j } = max 1 ≤ j ≤ l max { b l − j + 1 , f l − j + 1 } = max 1 ≤ k ≤ l max { f k , b k } = κ R K F N ( z 0 , h , l ) . \begin{aligned}
\kappa_{\mathrm{RKFN}}(\widetilde{z}_0,h,l)
&=\max_{1\leq j\leq l}\max\{\widetilde{f}_j,\widetilde{b}_j\}\\
&=\max_{1\leq j\leq l}\max\{b_{l-j+1},f_{l-j+1}\}\\
&=\max_{1\leq k\leq l}\max\{f_k,b_k\}\\
&=\kappa_{\mathrm{RKFN}}(z_0,h,l).
\end{aligned} κ RKFN ( z 0 , h , l ) = 1 ≤ j ≤ l max max { f j , b j } = 1 ≤ j ≤ l max max { b l − j + 1 , f l − j + 1 } = 1 ≤ k ≤ l max max { f k , b k } = κ RKFN ( z 0 , h , l ) .
Therefore, κ R K F N \kappa_{\mathrm{RKFN}} κ RKFN is reversible in the sense of (14) .
Proof of Proposition 3
Proof. Let z = ( θ , ρ ) z=(\theta,\rho) z = ( θ , ρ ) , and define the fine forward endpoint, the coarse forward endpoint, and the coarse endpoint computed from the momentum-flipped fine endpoint, respectively, by
z f : = Φ h / l l ( z ) , z_f:=\Phi_{h/l}^{l}(z), z f := Φ h / l l ( z ) ,
z c : = Φ 2 h / l l / 2 ( z ) , z_c:=\Phi_{2h/l}^{l/2}(z), z c := Φ 2 h / l l /2 ( z ) ,
z b : = Φ 2 h / l l / 2 ∘ F ( z f ) . z_b:=\Phi_{2h/l}^{l/2}\circ\mathcal{F}(z_f). z b := Φ 2 h / l l /2 ∘ F ( z f ) .
With this notation, the MRF error measure is
κ M R F ( z , h , l ) = max { ∥ z f − z c ∥ , ∥ F ( z ) − z b ∥ } . \kappa_{\mathrm{MRF}}(z,h,l)=\max\{\lVert z_f-z_c\rVert,\lVert\mathcal{F}(z)-z_b\rVert\}. κ MRF ( z , h , l ) = max {∥ z f − z c ∥ , ∥ F ( z ) − z b ∥} .
To verify reversibility, consider the momentum-flipped fine endpoint
z ~ : = F ( z f ) . \tilde{z}:=\mathcal{F}(z_f). z ~ := F ( z f ) .
Define the corresponding fine and coarse endpoints starting from z ~ \tilde{z} z ~ by
z ~ f : = Φ h / l l ( z ~ ) , z ~ c : = Φ 2 h / l l / 2 ( z ~ ) , z ~ b : = Φ 2 h / l l / 2 ∘ F ( z ~ f ) . \begin{aligned}
\tilde{z}_f&:=\Phi_{h/l}^{l}(\tilde{z}),\\
\tilde{z}_c&:=\Phi_{2h/l}^{l/2}(\tilde{z}),\\
\tilde{z}_b&:=\Phi_{2h/l}^{l/2}\circ\mathcal{F}(\tilde{z}_f).
\end{aligned} z ~ f z ~ c z ~ b := Φ h / l l ( z ~ ) , := Φ 2 h / l l /2 ( z ~ ) , := Φ 2 h / l l /2 ∘ F ( z ~ f ) .
By the time reversibility of the leapfrog integrator,
Φ h / l l ∘ F ∘ Φ h / l l = F . \Phi_{h/l}^{l}\circ\mathcal{F}\circ\Phi_{h/l}^{l}=\mathcal{F}. Φ h / l l ∘ F ∘ Φ h / l l = F .
Therefore,
z ~ f = Φ h / l l ∘ F ( z f ) = Φ h / l l ∘ F ∘ Φ h / l l ( z ) = F ( z ) . \tilde{z}_f=\Phi_{h/l}^{l}\circ\mathcal{F}(z_f)=\Phi_{h/l}^{l}\circ\mathcal{F}\circ\Phi_{h/l}^{l}(z)=\mathcal{F}(z). z ~ f = Φ h / l l ∘ F ( z f ) = Φ h / l l ∘ F ∘ Φ h / l l ( z ) = F ( z ) .
Moreover, by the definitions of z b z_b z b and z ~ \tilde{z} z ~ ,
z ~ c = Φ 2 h / l l / 2 ( z ~ ) = Φ 2 h / l l / 2 ∘ F ( z f ) = z b . \tilde{z}_c=\Phi_{2h/l}^{l/2}(\tilde{z})=\Phi_{2h/l}^{l/2}\circ\mathcal{F}(z_f)=z_b. z ~ c = Φ 2 h / l l /2 ( z ~ ) = Φ 2 h / l l /2 ∘ F ( z f ) = z b .
Finally, since z ~ f = F ( z ) \tilde{z}_f=\mathcal{F}(z) z ~ f = F ( z ) ,
z ~ b = Φ 2 h / l l / 2 ∘ F ( z ~ f ) = Φ 2 h / l l / 2 ∘ F ∘ F ( z ) = Φ 2 h / l l / 2 ( z ) = z c . \tilde{z}_b=\Phi_{2h/l}^{l/2}\circ\mathcal{F}(\tilde{z}_f)=\Phi_{2h/l}^{l/2}\circ\mathcal{F}\circ\mathcal{F}(z)=\Phi_{2h/l}^{l/2}(z)=z_c. z ~ b = Φ 2 h / l l /2 ∘ F ( z ~ f ) = Φ 2 h / l l /2 ∘ F ∘ F ( z ) = Φ 2 h / l l /2 ( z ) = z c .
Applying the definition of the MRF error measure at z ~ \tilde{z} z ~ gives
κ M R F ( z ~ , h , l ) = max { ∥ z ~ f − z ~ c ∥ , ∥ F ( z ~ ) − z ~ b ∥ } = max { ∥ F ( z ) − z b ∥ , ∥ z f − z c ∥ } = κ M R F ( z , h , l ) . \begin{aligned}
\kappa_{\mathrm{MRF}}(\tilde{z},h,l)&=\max\{\lVert\tilde{z}_f-\tilde{z}_c\rVert,\lVert\mathcal{F}(\tilde{z})-\tilde{z}_b\rVert\}\\
&=\max\{\lVert\mathcal{F}(z)-z_b\rVert,\lVert z_f-z_c\rVert\}\\
&=\kappa_{\mathrm{MRF}}(z,h,l).
\end{aligned} κ MRF ( z ~ , h , l ) = max {∥ z ~ f − z ~ c ∥ , ∥ F ( z ~ ) − z ~ b ∥} = max {∥ F ( z ) − z b ∥ , ∥ z f − z c ∥} = κ MRF ( z , h , l ) .
Thus, κ M R F \kappa_{\mathrm{MRF}} κ MRF is reversible in the sense of (14) .
Order verification for the embedded RKN map
Lemma 1. Assume that log π ~ \log\widetilde{\pi} log π is four times continuously differentiable in a neighborhood of the exact Hamiltonian trajectory. Then, the map Φ ˉ ϵ \bar{\Phi}_{\epsilon} Φ ˉ ϵ defined by (17) –(19) satisfies
Φ ˉ ϵ ( θ , ρ ) = φ ϵ ( θ , ρ ) + O ( ϵ 4 ) as ϵ → 0. \bar{\Phi}_{\epsilon}(\theta,\rho)=\varphi_{\epsilon}(\theta,\rho)+O(\epsilon^{4}) \quad\text{as }\epsilon\to0. Φ ˉ ϵ ( θ , ρ ) = φ ϵ ( θ , ρ ) + O ( ϵ 4 ) as ϵ → 0. Thus, Φ ˉ ϵ \bar{\Phi}_{\epsilon} Φ ˉ ϵ is a third-order one-step method. Moreover, because leapfrog is a second-order method,
Φ ϵ ( θ , ρ ) − Φ ˉ ϵ ( θ , ρ ) = O ( ϵ 3 ) , \Phi_{\epsilon}(\theta,\rho)-\bar{\Phi}_{\epsilon}(\theta,\rho)=O(\epsilon^{3}), Φ ϵ ( θ , ρ ) − Φ ˉ ϵ ( θ , ρ ) = O ( ϵ 3 ) , so their difference provides an estimate of the local leapfrog error.
Proof. For the proof, write
v = M − 1 ρ , a ( θ ) = M − 1 ∇ θ log π ~ ( θ ) , v=M^{-1}\rho,\qquad a(\theta)=M^{-1}\nabla_{\theta}\log\widetilde{\pi}(\theta), v = M − 1 ρ , a ( θ ) = M − 1 ∇ θ log π ( θ ) ,
and let
A = D a ( θ ) , B = D 2 a ( θ ) . A=Da(\theta),\qquad B=D^{2}a(\theta). A = D a ( θ ) , B = D 2 a ( θ ) .
Taylor expansion of the exact Hamiltonian flow gives
θ ( ϵ ) = θ + ϵ v + ϵ 2 2 a ( θ ) + ϵ 3 6 A v + O ( ϵ 4 ) , v ( ϵ ) = v + ϵ a ( θ ) + ϵ 2 2 A v + ϵ 3 6 ( A a ( θ ) + B [ v , v ] ) + O ( ϵ 4 ) , \begin{aligned}
\theta(\epsilon)&=\theta+\epsilon v+\frac{\epsilon^{2}}{2}a(\theta)+\frac{\epsilon^{3}}{6}Av+O(\epsilon^{4}),\\
v(\epsilon)&=v+\epsilon a(\theta)+\frac{\epsilon^{2}}{2}Av+\frac{\epsilon^{3}}{6}\left(Aa(\theta)+B[v,v]\right)+O(\epsilon^{4}),
\end{aligned} θ ( ϵ ) v ( ϵ ) = θ + ϵ v + 2 ϵ 2 a ( θ ) + 6 ϵ 3 A v + O ( ϵ 4 ) , = v + ϵ a ( θ ) + 2 ϵ 2 A v + 6 ϵ 3 ( A a ( θ ) + B [ v , v ] ) + O ( ϵ 4 ) ,
where B [ ⋅ , ⋅ ] B[\cdot,\cdot] B [ ⋅ , ⋅ ] denotes the vector-valued bilinear form induced by the third derivative tensor B B B . Let ( θ ′ , ρ ′ ) = Φ ϵ ( θ , ρ ) (\theta',\rho')=\Phi_{\epsilon}(\theta,\rho) ( θ ′ , ρ ′ ) = Φ ϵ ( θ , ρ ) and set v ′ = M − 1 ρ ′ v'=M^{-1}\rho' v ′ = M − 1 ρ ′ . The leapfrog position update gives
θ ′ = θ + ϵ v + ϵ 2 2 a ( θ ) . \theta'=\theta+\epsilon v+\frac{\epsilon^{2}}{2}a(\theta). θ ′ = θ + ϵ v + 2 ϵ 2 a ( θ ) .
Consequently,
a ( θ ′ ) = a ( θ ) + ϵ A v + ϵ 2 2 ( A a ( θ ) + B [ v , v ] ) + O ( ϵ 3 ) . a(\theta')=a(\theta)+\epsilon Av+\frac{\epsilon^{2}}{2}\left(Aa(\theta)+B[v,v]\right)+O(\epsilon^{3}). a ( θ ′ ) = a ( θ ) + ϵ A v + 2 ϵ 2 ( A a ( θ ) + B [ v , v ] ) + O ( ϵ 3 ) .
The leapfrog momentum update therefore implies
v ′ = v + ϵ a ( θ ) + ϵ 2 2 A v + ϵ 3 4 ( A a ( θ ) + B [ v , v ] ) + O ( ϵ 4 ) . v'=v+\epsilon a(\theta)+\frac{\epsilon^{2}}{2}Av+\frac{\epsilon^{3}}{4}\left(Aa(\theta)+B[v,v]\right)+O(\epsilon^{4}). v ′ = v + ϵ a ( θ ) + 2 ϵ 2 A v + 4 ϵ 3 ( A a ( θ ) + B [ v , v ] ) + O ( ϵ 4 ) .
Using the definition of θ m \theta_m θ m , one obtains
θ m = θ + ϵ 2 v + ϵ 2 8 a ( θ ) + O ( ϵ 3 ) , \theta_m = \theta+ \frac{\epsilon}{2}v + \frac{\epsilon^2}{8}a(\theta) + O(\epsilon^3), θ m = θ + 2 ϵ v + 8 ϵ 2 a ( θ ) + O ( ϵ 3 ) ,
and hence
a ( θ m ) = a ( θ ) + ϵ 2 A v + ϵ 2 8 ( A a ( θ ) + B [ v , v ] ) + O ( ϵ 3 ) . a(\theta_m) = a(\theta) + \frac{\epsilon}{2}Av + \frac{\epsilon^2}{8}\left(Aa(\theta) + B[v,v]\right) + O(\epsilon^3). a ( θ m ) = a ( θ ) + 2 ϵ A v + 8 ϵ 2 ( A a ( θ ) + B [ v , v ] ) + O ( ϵ 3 ) .
Substituting into (18) gives
θ ′ ′ = θ + ϵ v + ϵ 2 2 a ( θ ) + ϵ 3 6 A v + O ( ϵ 4 ) , \theta'' = \theta+ \epsilon v + \frac{\epsilon^2}{2}a(\theta) + \frac{\epsilon^3}{6}Av + O(\epsilon^4), θ ′′ = θ + ϵ v + 2 ϵ 2 a ( θ ) + 6 ϵ 3 A v + O ( ϵ 4 ) ,
while substituting into (19) gives
M − 1 ρ ′ ′ = v + ϵ a ( θ ) + ϵ 2 2 A v + ϵ 3 6 ( A a ( θ ) + B [ v , v ] ) + O ( ϵ 4 ) . M^{-1}\rho'' = v + \epsilon a(\theta) + \frac{\epsilon^2}{2}Av + \frac{\epsilon^3}{6}\left(Aa(\theta) + B[v,v]\right) + O(\epsilon^4). M − 1 ρ ′′ = v + ϵ a ( θ ) + 2 ϵ 2 A v + 6 ϵ 3 ( A a ( θ ) + B [ v , v ] ) + O ( ϵ 4 ) .
These expansions agree with the exact-flow expansions through terms of order ϵ 3 \epsilon^3 ϵ 3 , proving the result.
Correctness of locally adaptive multinomial HMC
Throughout this appendix, L \mathcal{L} L is the deterministic rule (11) (or its truncated version), H ∘ F = H H \circ F = H H ∘ F = H , and the momentum is refreshed from N ( 0 , M ) N(0,M) N ( 0 , M ) at the beginning of every iteration and discarded at the end.
Orbits. Given a current state z [ 0 ] = ( θ [ 0 ] , ρ [ 0 ] ) z_{[0]} = (\theta_{[0]}, \rho_{[0]}) z [ 0 ] = ( θ [ 0 ] , ρ [ 0 ] ) and a window ( a , b ) (a,b) ( a , b ) with a ≤ 0 ≤ b a \leq0 \leq b a ≤ 0 ≤ b , the orbit O = { z [ k ] } k = a b \mathcal{O} = \{z_{[k]}\}_{k=a}^{b} O = { z [ k ] } k = a b is defined by
z [ k ] = Φ h / l k − 1 , k l k − 1 , k ( z [ k − 1 ] ) , l k − 1 , k = L ( z [ k − 1 ] , h , δ ) , k = 1 , … , b , z_{[k]} = \Phi_{h/l_{k-1,k}}^{l_{k-1,k}}(z_{[k-1]}), \qquad l_{k-1,k} = \mathcal{L}(z_{[k-1]},h,\delta), \qquad k=1,\ldots,b, z [ k ] = Φ h / l k − 1 , k l k − 1 , k ( z [ k − 1 ] ) , l k − 1 , k = L ( z [ k − 1 ] , h , δ ) , k = 1 , … , b ,
z [ k ] = F ∘ Φ h / l k , k + 1 l k , k + 1 ∘ F ( z [ k + 1 ] ) , l k , k + 1 = L ( F ( z [ k + 1 ] ) , h , δ ) , k = − 1 , … , a , z_{[k]} = F \circ\Phi_{h/l_{k,k+1}}^{l_{k,k+1}} \circ F(z_{[k+1]}), \qquad l_{k,k+1} = \mathcal{L}(F(z_{[k+1]}),h,\delta), \qquad k=-1,\ldots,a, z [ k ] = F ∘ Φ h / l k , k + 1 l k , k + 1 ∘ F ( z [ k + 1 ] ) , l k , k + 1 = L ( F ( z [ k + 1 ] ) , h , δ ) , k = − 1 , … , a ,
with reversibility indicators w [ k − 1 , k ] ′ = 1 { L ( z [ k − 1 ] , h , δ ) = L ( F ( z [ k ] ) , h , δ ) } w'_{[k-1,k]} = \mathbf{1}\{\mathcal{L}(z_{[k-1]},h,\delta) = \mathcal{L}(F(z_{[k]}),h,\delta)\} w [ k − 1 , k ] ′ = 1 { L ( z [ k − 1 ] , h , δ ) = L ( F ( z [ k ] ) , h , δ )} , k = a + 1 , … , b k=a+1,\ldots,b k = a + 1 , … , b , reversibility weights r [ k ] r_{[k]} r [ k ] as in (27), and
C 0 : = { k ∈ { a , … , b } : r [ k ] = 1 } . C_0 := \{k \in\{a,\ldots,b\}: r_{[k]} = 1\}. C 0 := { k ∈ { a , … , b } : r [ k ] = 1 } .
Since the indicators are attached to consecutive pairs, C 0 C_0 C 0 is an interval of integers containing 0 0 0 ; it is the set of indices that can be reached from index zero without crossing a macro step that fails its reversibility check. For conventional multinomial HMC, the window is a = b − L a=b-L a = b − L with b b b uniformly distributed on { 0 , … , L } \{0,\ldots,L\} { 0 , … , L } , and the next state is z [ J ] z_{[J]} z [ J ] , where
P ( J = k ∣ O ) = r [ k ] exp ( − H ( z [ k ] ) ) S ( O ) , S ( O ) : = ∑ n = a b r [ n ] exp ( − H ( z [ n ] ) ) . (33) \mathbb{P}(J=k \mid\mathcal{O}) = \frac{r_{[k]}\exp\left(-H(z_{[k]})\right)}{S(\mathcal{O})}, \qquad S(\mathcal{O}) := \sum_{n=a}^{b} r_{[n]}\exp\left(-H(z_{[n]})\right). \tag*{(33)} P ( J = k ∣ O ) = S ( O ) r [ k ] exp ( − H ( z [ k ] ) ) , S ( O ) := n = a ∑ b r [ n ] exp ( − H ( z [ n ] ) ) . (33)
Lemma 2 (Re-indexing). Let O = { z [ k ] } k = a b \mathcal{O}=\{z_{[k]}\}_{k=a}^{b} O = { z [ k ] } k = a b be an orbit with origin z [ 0 ] z_{[0]} z [ 0 ] and let j ∈ C 0 j\in C_0 j ∈ C 0 . Let O ∗ = { z [ s ] ∗ } s = a ∗ b ∗ \mathcal{O}^*=\{z^*_{[s]}\}_{s=a^*}^{b^*} O ∗ = { z [ s ] ∗ } s = a ∗ b ∗ be the orbit with origin z [ 0 ] ∗ : = F ( z [ j ] ) z^*_{[0]}:=\mathcal{F}(z_{[j]}) z [ 0 ] ∗ := F ( z [ j ] ) and window ( a ∗ , b ∗ ) = ( j − b , j − a ) (a^*,b^*)=(j-b,j-a) ( a ∗ , b ∗ ) = ( j − b , j − a ) . Then
z [ s ] ∗ = F ( z [ j − s ] ) , w [ s − 1 , s ] ′ ∗ = w [ j − s , j − s + 1 ] ′ , r [ s ] ∗ = r [ j − s ] , s = a ∗ , … , b ∗ , z^*_{[s]}=\mathcal{F}(z_{[j-s]}),\qquad w^{\prime*}_{[s-1,s]}=w'_{[j-s,j-s+1]},\qquad r^*_{[s]}=r_{[j-s]},\qquad s=a^*,\ldots,b^*, z [ s ] ∗ = F ( z [ j − s ] ) , w [ s − 1 , s ] ′ ∗ = w [ j − s , j − s + 1 ] ′ , r [ s ] ∗ = r [ j − s ] , s = a ∗ , … , b ∗ , and in particular C 0 ∗ = { j − k : k ∈ C 0 } C^*_0=\{j-k:k\in C_0\} C 0 ∗ = { j − k : k ∈ C 0 } and S ( O ∗ ) = S ( O ) S(\mathcal{O}^*)=S(\mathcal{O}) S ( O ∗ ) = S ( O ) .
Proof. Assume j ≥ 1 j\geq1 j ≥ 1 ; the case j ≤ − 1 j\leq-1 j ≤ − 1 is symmetric and the case j = 0 j=0 j = 0 is trivial. Since j ∈ C 0 j\in C_0 j ∈ C 0 , w [ k − 1 , k ] ′ = 1 w'_{[k-1,k]}=1 w [ k − 1 , k ] ′ = 1 for k = 1 , … , j k=1,\ldots,j k = 1 , … , j , that is,
L ( F ( z [ k ] ) , h , δ ) = l k − 1 , k , k = 1 , … , j . (34) \mathcal{L}(\mathcal{F}(z_{[k]}),h,\delta)=l_{k-1,k},\qquad k=1,\ldots,j. \tag*{(34)} L ( F ( z [ k ] ) , h , δ ) = l k − 1 , k , k = 1 , … , j . (34)
Recall also that time reversibility of the leapfrog integrator gives Φ h / l l ∘ F = F ∘ ( Φ h / l l ) − 1 \Phi^l_{h/l}\circ\mathcal{F}=\mathcal{F}\circ(\Phi^l_{h/l})^{-1} Φ h / l l ∘ F = F ∘ ( Φ h / l l ) − 1 for every l l l .
Indices 0 ≤ s ≤ j 0\leq s\leq j 0 ≤ s ≤ j . z [ s ] ∗ = F ( z [ j − s ] ) z^*_{[s]}=\mathcal{F}(z_{[j-s]}) z [ s ] ∗ = F ( z [ j − s ] ) can be shown by induction on s s s . For s = 0 s=0 s = 0 , this is the definition of O ∗ \mathcal{O}^* O ∗ . If it holds for s − 1 s-1 s − 1 , then the forward count from z [ s − 1 ] ∗ = F ( z [ j − s + 1 ] ) z^*_{[s-1]}=\mathcal{F}(z_{[j-s+1]}) z [ s − 1 ] ∗ = F ( z [ j − s + 1 ] ) is L ( F ( z [ j − s + 1 ] ) , h , δ ) = l j − s , j − s + 1 \mathcal{L}(\mathcal{F}(z_{[j-s+1]}),h,\delta)=l_{j-s,j-s+1} L ( F ( z [ j − s + 1 ] ) , h , δ ) = l j − s , j − s + 1 by (35), and with l = l j − s , j − s + 1 l=l_{j-s,j-s+1} l = l j − s , j − s + 1 ,
z [ s ] ∗ = Φ h / l l ( F ( z [ j − s + 1 ] ) ) = F ( ( Φ h / l l ) − 1 ( z [ j − s + 1 ] ) ) = F ( z [ j − s ] ) . z^*_{[s]}=\Phi^l_{h/l}(\mathcal{F}(z_{[j-s+1]}))=\mathcal{F}((\Phi^l_{h/l})^{-1}(z_{[j-s+1]}))=\mathcal{F}(z_{[j-s]}). z [ s ] ∗ = Φ h / l l ( F ( z [ j − s + 1 ] )) = F (( Φ h / l l ) − 1 ( z [ j − s + 1 ] )) = F ( z [ j − s ] ) .
Indices s < 0 s<0 s < 0 (original indices k = j − s > j k=j-s>j k = j − s > j ). Backward steps of O ∗ \mathcal{O}^* O ∗ from z [ s + 1 ] ∗ = F ( z [ j − s − 1 ] ) z^*_{[s+1]}=\mathcal{F}(z_{[j-s-1]}) z [ s + 1 ] ∗ = F ( z [ j − s − 1 ] ) use the count L ( F ( z [ s + 1 ] ∗ ) , h , δ ) = L ( z [ j − s − 1 ] , h , δ ) = l j − s − 1 , j − s \mathcal{L}(\mathcal{F}(z^*_{[s+1]}),h,\delta)=\mathcal{L}(z_{[j-s-1]},h,\delta)=l_{j-s-1,j-s} L ( F ( z [ s + 1 ] ∗ ) , h , δ ) = L ( z [ j − s − 1 ] , h , δ ) = l j − s − 1 , j − s , which is the original forward count, and produce F ∘ Φ h / l l ∘ F ( F ( z [ j − s − 1 ] ) ) = F ( Φ h / l l ( z [ j − s − 1 ] ) ) = F ( z [ j − s ] ) \mathcal{F}\circ\Phi^l_{h/l}\circ\mathcal{F}(\mathcal{F}(z_{[j-s-1]}))=\mathcal{F}(\Phi^l_{h/l}(z_{[j-s-1]}))=\mathcal{F}(z_{[j-s]}) F ∘ Φ h / l l ∘ F ( F ( z [ j − s − 1 ] )) = F ( Φ h / l l ( z [ j − s − 1 ] )) = F ( z [ j − s ] ) .
Indices s > j s>j s > j (original indices k = j − s < 0 k=j-s<0 k = j − s < 0 ). Forward steps of O ∗ \mathcal{O}^* O ∗ from z [ s − 1 ] ∗ = F ( z [ j − s + 1 ] ) z^*_{[s-1]}=\mathcal{F}(z_{[j-s+1]}) z [ s − 1 ] ∗ = F ( z [ j − s + 1 ] ) use the count L ( F ( z [ j − s + 1 ] ) , h , δ ) = l j − s , j − s + 1 \mathcal{L}(\mathcal{F}(z_{[j-s+1]}),h,\delta)=l_{j-s,j-s+1} L ( F ( z [ j − s + 1 ] ) , h , δ ) = l j − s , j − s + 1 , which is the original backward count, and produce Φ h / l l ( F ( z [ j − s + 1 ] ) ) = F ( Φ h / l l ) − 1 ( z [ j − s + 1 ] ) = F ( z [ j − s ] ) \Phi^l_{h/l}(\mathcal{F}(z_{[j-s+1]}))=\mathcal{F}(\Phi^l_{h/l})^{-1}(z_{[j-s+1]})=\mathcal{F}(z_{[j-s]}) Φ h / l l ( F ( z [ j − s + 1 ] )) = F ( Φ h / l l ) − 1 ( z [ j − s + 1 ] ) = F ( z [ j − s ] ) .
Thus, only the macro steps between indices 0 0 0 and j j j are traversed in the opposite direction in O ∗ \mathcal{O}^* O ∗ ; all other macro steps are traversed in the same direction as in O \mathcal{O} O , with the same micro step counts. For the indicators,
w [ s − 1 , s ] ′ ∗ = 1 { L ( z [ s − 1 ] ∗ , h , δ ) = L ( F ( z [ s ] ∗ ) , h , δ ) } = 1 { L ( F ( z [ j − s + 1 ] ) , h , δ ) = L ( z [ j − s ] , h , δ ) } = w [ j − s , j − s + 1 ] ′ , w^{\prime*}_{[s-1,s]}=\mathbf{1}\{\mathcal{L}(z^*_{[s-1]},h,\delta)=\mathcal{L}(\mathcal{F}(z^*_{[s]}),h,\delta)\}=\mathbf{1}\{\mathcal{L}(\mathcal{F}(z_{[j-s+1]}),h,\delta)=\mathcal{L}(z_{[j-s]},h,\delta)\}=w'_{[j-s,j-s+1]}, w [ s − 1 , s ] ′ ∗ = 1 { L ( z [ s − 1 ] ∗ , h , δ ) = L ( F ( z [ s ] ∗ ) , h , δ )} = 1 { L ( F ( z [ j − s + 1 ] ) , h , δ ) = L ( z [ j − s ] , h , δ )} = w [ j − s , j − s + 1 ] ′ ,
where the last equality uses only that the indicator is a symmetric function of the pair of states. Hence, r [ s ] ∗ r^*_{[s]} r [ s ] ∗ is the product of the original indicators over the macro steps between indices j − s j-s j − s and j j j , while r [ j − s ] r_{[j-s]} r [ j − s ] is the product over the macro steps between j − s j-s j − s and 0 0 0 . Now, when s > j s>j s > j , r [ j − s ] = ∏ n = j − s + 1 0 w [ n − 1 , n ] ′ r_{[j-s]}=\prod_{n=j-s+1}^{0}w'_{[n-1,n]} r [ j − s ] = ∏ n = j − s + 1 0 w [ n − 1 , n ] ′ as k = j − s < 0 k=j-s<0 k = j − s < 0 . On the other hand,
r [ s ] ∗ = ∏ n ∗ = 1 s w [ n ∗ − 1 , n ∗ ] ′ ∗ = ∏ n ∗ = 1 s w [ j − n ∗ , j − n ∗ + 1 ] ′ = ∏ n = j − s + 1 j w [ n − 1 , n ] ′ = ∏ n = 1 j w [ n − 1 , n ] ′ ∏ n = j − s + 1 0 w [ n − 1 , n ] ′ = ( ∏ n = 1 j w [ n − 1 , n ] ′ ) r [ j − s ] , \begin{aligned}
r^{*}_{[s]}=\prod_{n^{*}=1}^{s}w^{\prime*}_{[n^{*}-1,n^{*}]}=\prod_{n^{*}=1}^{s}w^{\prime}_{[j-n^{*},j-n^{*}+1]}=\prod_{n=j-s+1}^{j}w^{\prime}_{[n-1,n]} \\
&=\prod_{n=1}^{j}w^{\prime}_{[n-1,n]}\prod_{n=j-s+1}^{0}w^{\prime}_{[n-1,n]} \\
&=\left(\prod_{n=1}^{j}w^{\prime}_{[n-1,n]}\right)r_{[j-s]},
\end{aligned} r [ s ] ∗ = n ∗ = 1 ∏ s w [ n ∗ − 1 , n ∗ ] ′ ∗ = n ∗ = 1 ∏ s w [ j − n ∗ , j − n ∗ + 1 ] ′ = n = j − s + 1 ∏ j w [ n − 1 , n ] ′ = n = 1 ∏ j w [ n − 1 , n ] ′ n = j − s + 1 ∏ 0 w [ n − 1 , n ] ′ = ( n = 1 ∏ j w [ n − 1 , n ] ′ ) r [ j − s ] ,
where the order of the product in the first line from n ∗ n^{*} n ∗ to n n n is due to s > j s>j s > j and j > 0 j>0 j > 0 . Because all indicators between 0 0 0 and j j j are equal to one, one arrives at r [ j − s ] = r [ s ] ∗ r_{[j-s]}=r^{*}_{[s]} r [ j − s ] = r [ s ] ∗ as the two differ by the product of the weights between 0 0 0 and j j j . If 0 ≤ s ≤ j 0\le s\le j 0 ≤ s ≤ j , both contain weights between 0 0 0 and j j j , so r [ j − s ] = r [ s ] ∗ = 1 r_{[j-s]}=r^{*}_{[s]}=1 r [ j − s ] = r [ s ] ∗ = 1 . In a similar manner, when s < 0 s<0 s < 0 ,
r [ j − s ] = ∏ n = 1 j − s w [ n − 1 , n ] ′ = ∏ n = 1 j w [ n − 1 , n ] ′ ∏ n = s + 1 0 w [ j − n , j − n + 1 ] ′ r_{[j-s]}=\prod_{n=1}^{j-s}w^{\prime}_{[n-1,n]}=\prod_{n=1}^{j}w^{\prime}_{[n-1,n]}\prod_{n=s+1}^{0}w^{\prime}_{[j-n,j-n+1]} r [ j − s ] = n = 1 ∏ j − s w [ n − 1 , n ] ′ = n = 1 ∏ j w [ n − 1 , n ] ′ n = s + 1 ∏ 0 w [ j − n , j − n + 1 ] ′
since s < 0 s<0 s < 0 corresponds to k = j − s > j k=j-s>j k = j − s > j . However,
r [ s ] ∗ = ∏ n ∗ = s + 1 0 w [ n ∗ − 1 , n ∗ ] ′ ∗ = ∏ n ∗ = s + 1 0 w [ j − n ∗ , j − n ∗ + 1 ] ′ . r^{*}_{[s]}=\prod_{n^{*}=s+1}^{0}w^{\prime*}_{[n^{*}-1,n^{*}]}=\prod_{n^{*}=s+1}^{0}w^{\prime}_{[j-n^{*},j-n^{*}+1]}. r [ s ] ∗ = n ∗ = s + 1 ∏ 0 w [ n ∗ − 1 , n ∗ ] ′ ∗ = n ∗ = s + 1 ∏ 0 w [ j − n ∗ , j − n ∗ + 1 ] ′ .
Therefore, r [ j − s ] = r [ s ] ∗ r_{[j-s]}=r^{*}_{[s]} r [ j − s ] = r [ s ] ∗ as they differ again by the products of weights between 0 0 0 and j j j . In any case, both reduce either to 1 1 1 or the product over the macro steps between j − s j-s j − s and the nearest endpoint of the interval [ 0 , j ] [0,j] [ 0 , j ] , so r [ j − s ] = r [ s ] ∗ r_{[j-s]}=r^{*}_{[s]} r [ j − s ] = r [ s ] ∗ overall. Finally, the statements about C 0 ∗ C^{*}_{0} C 0 ∗ and S S S follow, the latter using H ∘ F = H H\circ\mathcal{F}=H H ∘ F = H .
Proposition 5. The locally adaptive multinomial HMC transition, defined by refreshing ρ ∼ N ( 0 , M ) \rho\sim\mathcal{N}(0,M) ρ ∼ N ( 0 , M ) , drawing b b b uniformly on { 0 , … , L } \{0,\ldots,L\} { 0 , … , L } , building O \mathcal{O} O with a = b − L a=b-L a = b − L , drawing J J J from (33) and returning θ [ J ] \theta_{[J]} θ [ J ] , is a π \pi π -reversible Markov kernel on R d \mathbb{R}^{d} R d .
Proof. Fix b ∈ { 0 , … , L } b\in\{0,\ldots,L\} b ∈ { 0 , … , L } and j ∈ { b − L , … , b } j\in\{b-L,\ldots,b\} j ∈ { b − L , … , b } . For an initial state z ∈ R 2 d z\in\mathbb{R}^{2d} z ∈ R 2 d , write O b ( z ) \mathcal{O}_{b}(z) O b ( z ) for the orbit with origin z z z and window ( b − L , b ) (b-L,b) ( b − L , b ) , and let E b , j : = { z : r [ j ] = 1 in O b ( z ) } E_{b,j}:=\{z:r_{[j]}=1\text{ in }\mathcal{O}_{b}(z)\} E b , j := { z : r [ j ] = 1 in O b ( z )} . Define Ψ b , j : E b , j → R 2 d \Psi_{b,j}:E_{b,j}\to\mathbb{R}^{2d} Ψ b , j : E b , j → R 2 d by Ψ b , j ( z ) : = F ( z [ j ] ) . \Psi_{b,j}(z):=\mathcal{F}(z_{[j]}). Ψ b , j ( z ) := F ( z [ j ] ) . Let b ∗ : = L + j − b b^{*}:=L+j-b b ∗ := L + j − b ; then b ↦ b ∗ b\mapsto b^{*} b ↦ b ∗ is a bijection of { b : b − L ≤ j ≤ b } \{b:b-L\le j\le b\} { b : b − L ≤ j ≤ b } onto itself, and ( b ∗ − L , b ∗ ) = ( j − b , j − ( b − L ) ) (b^{*}-L,b^{*})=(j-b,j-(b-L)) ( b ∗ − L , b ∗ ) = ( j − b , j − ( b − L )) is exactly the window of Lemma 2. By that lemma, Ψ b , j ( E b , j ) ⊂ E b ∗ , j \Psi_{b,j}(E_{b,j})\subset E_{b^{*},j} Ψ b , j ( E b , j ) ⊂ E b ∗ , j and Ψ b ∗ , j ∘ Ψ b , j = id \Psi_{b^{*},j}\circ\Psi_{b,j}=\operatorname{id} Ψ b ∗ , j ∘ Ψ b , j = id on E b , j E_{b,j} E b , j , because F ( z [ j ] ∗ ) = F ( F ( z [ 0 ] ) ) = z \mathcal{F}(z^{*}_{[j]})=\mathcal{F}(\mathcal{F}(z_{[0]}))=z F ( z [ j ] ∗ ) = F ( F ( z [ 0 ] )) = z . Hence Ψ b , j \Psi_{b,j} Ψ b , j is a bijection of E b , j E_{b,j} E b , j onto E b ∗ , j E_{b^{*},j} E b ∗ , j with inverse Ψ b ∗ , j \Psi_{b^{*},j} Ψ b ∗ , j . Moreover, E b , j E_{b,j} E b , j is the countable disjoint union of the measurable sets on which the vector of micro step counts of O b ( z ) \mathcal{O}_{b}(z) O b ( z ) is constant. Since L \mathcal{L} L is measurable, and on each such set, Ψ b , j \Psi_{b,j} Ψ b , j is the restriction of a fixed composition of leapfrog maps and F \mathcal{F} F , hence of a volume preserving map, Ψ b , j \Psi_{b,j} Ψ b , j preserves the Lebesgue measure.
Let P P P be the phase-space kernel that maps z z z to F ( z [ J ] ) ; \mathcal{F}(z_{[J]}); F ( z [ J ] ) ; the momentum flip does not affect the position and is included so that the maps Ψ b , j \Psi_{b,j} Ψ b , j are involutive in the above sense. Explicitly,
P ( z , B ) = ∑ b = 0 L 1 L + 1 ∑ j = b − L b 1 E b , j ( z ) exp ( − H ( z [ j ] ) ) S ( O b ( z ) ) 1 B ( Ψ b , j ( z ) ) . P(z,B)=\sum_{b=0}^{L}\frac{1}{L+1}\sum_{j=b-L}^{b}\mathbf{1}_{E_{b,j}}(z)\frac{\exp(-H(z_{[j]}))}{S(\mathcal{O}_{b}(z))}\mathbf{1}_{B}(\Psi_{b,j}(z)). P ( z , B ) = b = 0 ∑ L L + 1 1 j = b − L ∑ b 1 E b , j ( z ) S ( O b ( z )) exp ( − H ( z [ j ] )) 1 B ( Ψ b , j ( z )) .
For measurable A , B ⊂ R 2 d A, B \subset\mathbb{R}^{2d} A , B ⊂ R 2 d ,
∫ A e − H ( z ) P ( z , B ) d z = ∑ b ∑ j 1 L + 1 ∫ A ∩ E b , j ∩ Ψ b , j − 1 ( B ) e − H ( z ) e − H ( z [ j ] ) S ( O b ( z ) ) d z . \int_A e^{-H(z)}P(z,B)\,dz = \sum_b \sum_j \frac{1}{L+1}\int_{A\cap E_{b,j}\cap\Psi_{b,j}^{-1}(B)} \frac{e^{-H(z)}e^{-H(z_{[j]})}}{S(O_b(z))}\,dz. ∫ A e − H ( z ) P ( z , B ) d z = b ∑ j ∑ L + 1 1 ∫ A ∩ E b , j ∩ Ψ b , j − 1 ( B ) S ( O b ( z )) e − H ( z ) e − H ( z [ j ] ) d z .
First, substitute z ′ = Ψ b , j ( z ) z'=\Psi_{b,j}(z) z ′ = Ψ b , j ( z ) in the ( b , j ) (b,j) ( b , j ) term. The Jacobian is one; e − H ( z ) e − H ( z [ j ] ) = e − H ( z ′ ) e − H ( z [ j ] ′ ) e^{-H(z)}e^{-H(z_{[j]})}=e^{-H(z')}e^{-H(z'_{[j]})} e − H ( z ) e − H ( z [ j ] ) = e − H ( z ′ ) e − H ( z [ j ] ′ ) because H ( z ′ ) = H ( F ( z [ j ] ) ) = H ( z [ j ] ) H(z')=H(F(z_{[j]}))=H(z_{[j]}) H ( z ′ ) = H ( F ( z [ j ] )) = H ( z [ j ] ) and z [ j ] ′ = F ( z ) z'_{[j]}=F(z) z [ j ] ′ = F ( z ) by Lemma 2; S ( O b ( z ) ) = S ( O b ∗ ( z ′ ) ) S(O_b(z))=S(O_{b^*}(z')) S ( O b ( z )) = S ( O b ∗ ( z ′ )) by the same lemma; and the domain of integration becomes B ∩ E b ∗ , j ∩ Ψ b ∗ , j − 1 ( A ) B\cap E_{b^*,j}\cap\Psi_{b^*,j}^{-1}(A) B ∩ E b ∗ , j ∩ Ψ b ∗ , j − 1 ( A ) . Summing over ( b , j ) (b,j) ( b , j ) is the same as summing over ( b ∗ , j ) (b^*,j) ( b ∗ , j ) . Hence
∫ A e − H ( z ) P ( z , B ) d z = ∫ B e − H ( z ) P ( z , A ) d z , \int_A e^{-H(z)}P(z,B)\,dz=\int_B e^{-H(z)}P(z,A)\,dz, ∫ A e − H ( z ) P ( z , B ) d z = ∫ B e − H ( z ) P ( z , A ) d z ,
that is, P P P satisfies detailed balance with respect to μ ∝ e − H \mu\propto e^{-H} μ ∝ e − H on R 2 d \mathbb{R}^{2d} R 2 d .
Finally, the position kernel is K ( θ , d θ ′ ) = ∫ N ( d ρ ; 0 , M ) P ( ( θ , ρ ) , d θ ′ × R d ) K(\theta,d\theta')=\int N(d\rho;0,M)P((\theta,\rho),d\theta'\times\mathbb{R}^d) K ( θ , d θ ′ ) = ∫ N ( d ρ ; 0 , M ) P (( θ , ρ ) , d θ ′ × R d ) . Since μ ( d θ d ρ ) = π ( d θ ) N ( d ρ ; 0 , M ) \mu(d\theta\,d\rho)=\pi(d\theta)N(d\rho;0,M) μ ( d θ d ρ ) = π ( d θ ) N ( d ρ ; 0 , M ) , integrating the phase-space detailed balance identity over ρ \rho ρ and ρ ′ \rho' ρ ′ gives π ( d θ ) K ( θ , d θ ′ ) = π ( d θ ′ ) K ( θ ′ , d θ ) \pi(d\theta)K(\theta,d\theta')=\pi(d\theta')K(\theta',d\theta) π ( d θ ) K ( θ , d θ ′ ) = π ( d θ ′ ) K ( θ ′ , d θ ) .
Remark. Dead ends require no special treatment: an index k ∉ C 0 k\notin\mathcal{C}_0 k ∈ / C 0 has r [ k ] = 0 r_{[k]}=0 r [ k ] = 0 , is never selected, and does not contribute to S ( O ) S(O) S ( O ) . The implementation may therefore stop building the orbit at the first failing macro step in each direction.
Comments regarding Table 1
For the Hamiltonian criterion, if c ∗ c^* c ∗ is indeed the smallest value such that the criterion is satisfied for a given threshold δ \delta δ , the criterion must not be satisfied for c = 0 , … , c ∗ − 1 c=0,\ldots,c^*-1 c = 0 , … , c ∗ − 1 . This implies that for each value of c c c , l = 2 c l=2^c l = 2 c gradient evaluations are done in order to perform l l l leapfrog micro steps. Thus, the forward pass will evaluate the gradient a total of ∑ c = 0 c ∗ 2 c = 2 c ∗ + 1 − 1 \sum_{c=0}^{c^*}2^c=2^{c^*+1}-1 ∑ c = 0 c ∗ 2 c = 2 c ∗ + 1 − 1 times. In a similar manner, because of Proposition 1, to satisfy the reversibility condition, the backward pass must perform ∑ c = 0 c ∗ − 1 2 c = 2 c ∗ − 1 \sum_{c=0}^{c^*-1}2^c=2^{c^*}-1 ∑ c = 0 c ∗ − 1 2 c = 2 c ∗ − 1 gradient evaluations.
For the MRF criterion, if c ∗ = 1 c^*=1 c ∗ = 1 , then it is easy to see that the required number of gradient evaluations for the forward pass is 4. However, for c ∗ > 1 c^*>1 c ∗ > 1 , the finer state from c − 1 c-1 c − 1 can then be reused as the coarser state when checking the criterion for a given value of c = 2 , … , c ∗ c=2,\ldots,c^* c = 2 , … , c ∗ . Therefore, based on Figure 2 , which corresponds to the case of c = 2 c=2 c = 2 , the upper path is the finer state from c = 1 c=1 c = 1 and has therefore been computed. Thus, only 4 + 2 = 6 4+2=6 4 + 2 = 6 evaluations are needed and the total number of gradient evaluations for the forward pass when c ∗ = 2 c^*=2 c ∗ = 2 is 4 + 6 = 10 4+6=10 4 + 6 = 10 . More generally, for a given c ∗ c^* c ∗ , the number of gradient evaluations for the forward pass becomes 3 ( 2 c ∗ ) − 2 3(2^{c^*})-2 3 ( 2 c ∗ ) − 2 .
Regarding the backward pass, if c ∗ = 1 c^*=1 c ∗ = 1 , it is clear from Proposition 1 (using the reversibility of κ M R F \kappa_{\mathrm{MRF}} κ MRF stated in Proposition 3 ) that one does not need to compute the backward pass as the step is naturally reversible, i.e., the number of gradient evaluations for the backward pass is zero in this case. For c ∗ = 2 c^*=2 c ∗ = 2 , Proposition 1 states that it is only necessary to compute the backward pass for c = 1 c=1 c = 1 . In that case, one can observe that the finer forward state during the backward pass is indeed the backward state from the forward pass for c = c ∗ = 2 c = c^{*} = 2 c = c ∗ = 2 . Consequently, reusing this computed path, one only needs to compute the coarser forward state and the backward state of this backward pass, where each one corresponds to a single gradient evaluation. The total number of gradient evaluations during this specific backward pass is therefore 2. For a general c ∗ > 2 c^{*} > 2 c ∗ > 2 , one needs to compute the backward pass for c = 1 , … , c ∗ − 1 c = 1,\ldots,c^{*} - 1 c = 1 , … , c ∗ − 1 without any early termination in order to obtain a valid reversible macro step. Thus, when performing the backward pass for the values c = 1 , … , c ∗ − 2 c = 1,\ldots,c^{*} - 2 c = 1 , … , c ∗ − 2 , the total number of gradient evaluations is 3 ( 2 c ∗ − 2 ) − 2 3(2^{c^{*}-2}) - 2 3 ( 2 c ∗ − 2 ) − 2 . For c = c ∗ − 1 c = c^{*} - 1 c = c ∗ − 1 , since c ∗ > 2 c^{*} > 2 c ∗ > 2 , both the coarser and finer forward state of the backward pass for this value of c c c have already been computed from the previous backward pass of c = c ∗ − 2 c = c^{*} - 2 c = c ∗ − 2 and the backward state from the final forward pass, respectively. Thus, only the backward state must be computed, which requires 2 c ∗ − 2 2^{c^{*}-2} 2 c ∗ − 2 gradient evaluations. The total number of gradient evaluations during the backward pass is then 3 ( 2 c ∗ − 2 ) − 2 + 2 c ∗ − 2 = 4 ( 2 c ∗ − 2 ) − 2 = 2 2 ( 2 c ∗ − 2 ) − 2 = 2 c ∗ − 2 3(2^{c^{*}-2}) - 2 + 2^{c^{*}-2} = 4(2^{c^{*}-2}) - 2 = 2^{2}(2^{c^{*}-2}) - 2 = 2^{c^{*}} - 2 3 ( 2 c ∗ − 2 ) − 2 + 2 c ∗ − 2 = 4 ( 2 c ∗ − 2 ) − 2 = 2 2 ( 2 c ∗ − 2 ) − 2 = 2 c ∗ − 2 .
Finally, for the RKNF criterion, the computation can be terminated early if an early micro step has already violated the criterion. This process is of course situation-dependent so that computing the exact number of gradient evaluations for both the forward and backward pass is not possible. However, it is possible to derive an upper bound of this cost. Given c ∗ c^{*} c ∗ , it is assumed that when computing the forward pass for c = 0 , … , c ∗ − 1 c = 0,\ldots,c^{*} - 1 c = 0 , … , c ∗ − 1 , the criterion is violated at the very last micro step. Then, if c ∗ = 0 c^{*} = 0 c ∗ = 0 , the number of gradient evaluations for the forward pass is simply 1 + 1 = 2 1 + 1 = 2 1 + 1 = 2 . Because of Proposition 1 (with Proposition 2), there is no need to perform the backward pass in this case. Given a general c ∗ > 0 c^{*} > 0 c ∗ > 0 , for c = 0 , … , c ∗ − 1 c = 0,\ldots,c^{*} - 1 c = 0 , … , c ∗ − 1 , the maximum number of gradient evaluations performed while still violating the desired criterion is 2 c + 2 c = 2 c + 1 2^{c} + 2^{c} = 2^{c+1} 2 c + 2 c = 2 c + 1 , where the first term corresponds to the number of gradient evaluations due to the standard leapfrog step while the second term represents the number of gradient evaluations due to (18). Thus, the maximum number of gradient evaluations becomes ∑ c = 0 c ∗ 2 c + 1 = 2 c ∗ + 2 − 2 \sum_{c=0}^{c^{*}} 2^{c+1} = 2^{c^{*}+2} - 2 ∑ c = 0 c ∗ 2 c + 1 = 2 c ∗ + 2 − 2 . Using the same assumption and following the identical strategy, the upper bound of the number of gradient evaluations for the backward pass is 2 c ∗ + 1 − 2 2^{c^{*}+1} - 2 2 c ∗ + 1 − 2 . The final results of the computational cost analysis for the three criteria are summarized in Table 1 .
Strategies of tuning h h h and δ \delta δ
As mentioned in Section 3.5.1 and in some of the examples related to the multinomial HMC methods, the macro step size h h h and the error threshold δ \delta δ can be tuned to obtain a desired combination of P ( c = c min ) P(c = c_{\min}) P ( c = c m i n ) and P ( Δ < Δ t h r e s h o l d ) P(\Delta< \Delta_{\mathrm{threshold}}) P ( Δ < Δ threshold ) . Now, further details regarding the tuning strategy similar to Bou-Rabee et al. [6 ] are discussed.
Tuning δ \delta δ
Recall that for a general criterion, δ \delta δ controls the number of micro steps needed to cover a full macro step. For a given iteration/orbit, this implies that it will also affect the largest deviation in the energy of the reachable states. within an orbit, i.e., Δ \Delta Δ . Thus, similar to Bou-Rabee et al. [6 ] , this variation in the energy is here modeled as Δ ≈ λ δ \Delta\approx\lambda\delta Δ ≈ λ δ .
Now, the goal is to choose δ \delta δ such that P ( Δ ≤ Δ t h r e s h o l d ) = β ∈ ( 0 , 1 ) P(\Delta\le\Delta_{\mathrm{threshold}}) = \beta\in(0, 1) P ( Δ ≤ Δ threshold ) = β ∈ ( 0 , 1 ) . Based on the assumption above, during the warmup phase, the observed Δ \Delta Δ is recorded for each iteration to compute the observed λ \lambda λ corresponding to Δ o b s / δ \Delta_{\mathrm{obs}}/\delta Δ obs / δ . Then, δ \delta δ is updated by Δ t h r e s h o l d / q λ ( β ) \Delta_{\mathrm{threshold}}/q_{\lambda}(\beta) Δ threshold / q λ ( β ) , where q λ ( β ) q_{\lambda}(\beta) q λ ( β ) corresponds to the empirical β \beta β -quantile of the recorded values of λ \lambda λ .
Tuning h h h
With a given δ \delta δ and criterion, one can tune h h h by relating it to P ( c = c min ) = ω P(c = c_{\min}) = \omega P ( c = c m i n ) = ω . Because the leapfrog is a second-order integrator, it is plausible that for the coarsest step given δ \delta δ , δ = O ( h 3 ) \delta= O(h^3) δ = O ( h 3 ) ([6 ] ). Setting δ ≈ C h 3 \delta\approx Ch^3 δ ≈ C h 3 for some positive constant C C C and similar to the above, one can record the observed value of C C C in each iteration by κ o b s / h 3 \kappa_{\mathrm{obs}}/h^3 κ obs / h 3 , where κ o b s \kappa_{\mathrm{obs}} κ obs is the observed value of the chosen error criterion during a single macro step with c = c min c = c_{\min} c = c m i n . Then, h h h is updated according to ( δ / q C ( ω ) ) 1 / 3 (\delta/q_C(\omega))^{1/3} ( δ / q C ( ω ) ) 1/3 with q C ( ω ) q_C(\omega) q C ( ω ) representing the empirical ω \omega ω -quantile of the recorded values of C C C .