Skip to main content
Springer logoLink to Springer
. 2026 Sep 23;36(5):222. doi: 10.1007/s11222-026-10972-z

Faster Hamiltonian Monte Carlo by learning leapfrog scale: an offline randomized solution

Changye Wu 1,#, Pierre Pudlo 2, Christian P Robert 1,3,✉,#, Julien Stoehr 1,4,#
PMCID: PMC13601133  PMID: 42787110

Abstract

We introduce a Hamiltonian Monte Carlo (HMC) methodology based on an offline empirical calibration of randomized leapfrog parameters. The approach, referred to as eHMC, where e stands for empirical, leverages importance sampling to construct an empirical distribution on discretization parameters, thereby eliminating the need for manual burn-in diagnostics and online adaptation. The proposal distribution used in the calibration stage is obtained via a Population Monte Carlo scheme with tempering and relies on flexible parametric variational families such as normalizing flows. Once the calibration stage complete, the resulting algorithm defines a homogeneous Markov chain via a mixture of HMC kernels with a fixed mixing distribution, and hence preserves the target distribution. Numerical experiments indicate that eHMC can achieve competitive or improved sampling efficiency compared to the No-U-Turn Sampler (NUTS) in the case useful integration times can be summarized by the offline distribution. The comparison is assessed by standard efficiency metrics normalized by the number of leapfrog steps during the post-calibration sampling phase.

Keywords: Hamiltonian Monte Carlo, Randomized accelerated method, Population Monte Carlo

Introduction

Hamiltonian Monte Carlo (HMC, Duane et al. 1987; Neal 2011) has emerged as an efficient Markov Chain Monte Carlo (MCMC) sampling method, which is particularly adept at dealing with high-dimensional target distributions. The method relies on a deterministic differential flow stemming from Hamiltonian mechanics to produce transitions across the parameter space of an augmented distribution, referred to as Hamiltonian. Such time-continuous dynamics leave the augmented distribution invariant; however, in practice, the latter must be discretized. The transitions are hence computed using a gradient-based symplectic integrator, the most popular of which is the second-order Störmer-Verlet also known as the leapfrog integrator (Hairer et al. 2003). A Metropolis-Hastings acceptance ratio must furthermore be added towards correcting the approximate numerical solution and hence preserving the intended target measure.

Whilst the algorithm theoretically benefits from a fast exploration of the parameter space by accepting large transitions with high probability, this efficiency is marred by its high sensitivity to hand-tuned parameters. These include the step size ε of the discretization scheme, the number of steps L of the integrator, and the covariance matrix M of the auxiliary variables. Indeed, the discretization error resulting from a poorly tuned step size often leads to a low acceptance rate, since the latter is governed by the variation of the Hamiltonian between the initial and final states of the leapfrog path, which is of order ε2. Furthermore, calibrating the number of steps of the integrator is paramount to avoid slow mixing chains or to save some computation cost. More specifically, if the value of L is not large enough, HMC may exhibit a random walk behaviour similar to that of standard Metropolis Hastings algorithms, and may thus struggle to properly explore the support of the target. Conversely, if the value of L is too large the associated dynamic may retrace its steps back to a neighbourhood of the initial state (Betancourt et al. 2015). This may result in the algorithm wasting computation efforts and diminishing mixing. Finally, the choice of a well-suited covariance matrix for the auxiliary variable can enhance both the speed and the mixing of HMC. One proposal in this regard is the Riemann manifold approach of Girolami and Calderhead (2011) that adapts the covariance matrix of the auxiliary variables to the curvature of the target distribution, followed by the automatic tuning strategy of Wang et al. (2013).

In terms of calibration concerns, the popular No-U-Turn Sampler (NUTS, Hoffman and Gelman 2014) automatically adjusts both the step size and the number of integration steps. This algorithm achieves at least the same efficiency in terms of effective sample size and expected squared jump distance as compared to the standard HMC, albeit at the cost of increased computational complexity. After selecting the step size ε by primal-dual averaging (Nesterov 2009) during a burn-in phase, NUTS dynamically adapts L at each iteration to determine an integration length adapted to the local Hamiltonian dynamics. This trajectory is obtained through a recursive doubling scheme that follows the Hamiltonian flow forward and backward until a no-U-turn condition is satisfied. The symmetric trajectory construction and proposal random selection yields a valid reversible transition.

Although NUTS dynamically constructs a trajectory whose length is adapted to the local geometry, the proposal is not obtained by deterministically selecting the endpoint of this trajectory. Instead, the next state is sampled from the set of candidate states generated along the trajectory using slice sampling in the original formulation (Hoffman and Gelman 2014) and multinomial sampling in the current Stan implementation. Consequently, the principal computational cost of NUTS lies in constructing the trajectory online at every iteration in order to determine an appropriate integration length. Recent work by Bou-Rabee et al. (2025) has also investigated adaptive calibration within NUTS. They introduce local step-size adaptation steps into NUTS using a Gibbs self-tuning mechanism. Their approach performs local adaptation during the construction of the Hamiltonian trajectory while preserving the reversibility property.

The present work explores the opportunity of learning offline a distribution of integration lengths and exploiting it to define a randomized HMC scheme that recovers part of the benefits of dynamic trajectory adaptation while avoiding the systematic construction of extended trajectories during the sampling phase. Therefore, the proposal potentially reduces the online computational cost, whenever a suitable distribution of integration lengths can be learned from a preliminary, exploratory stage. However, it is not intended to provide a universal replacement for NUTS but rather stands as a mostly automated offline calibration mechanism for randomized HMC in some settings. These cover targets where a reusable distribution of integration parameters offers an adequate summary of the trajectory lengths encountered across the typical set.

The idea of randomizing elements of the Hamiltonian dynamics has already been investigated in the literature. For instance, Bou-Rabee and Sanz-Serna (2017) propose to randomize the integration time according to a continuous distribution, yielding a Markov process with ergodicity properties and avoiding pathological periodic trajectories of standard Hamiltonian-based samplers. Their convergence results establish that randomization of the integration time can fundamentally alter the long-time behavior of the sampler. While they focus on theoretical guarantees for continuous-time randomization mechanisms, our approach targets a practical, offline, calibration of randomized discrete-time HMCs.

In this paper, we construct an empirical joint distribution on the discretization parameters (ε,L). Our finite calibration phase is exploiting the U-turn criterion of NUTS on the level sets associated with a sample of points that are approximately distributed according to the target distribution. This sample is then used in a second phase to jointly simulate (ε,L) at each iteration of a regular HMC scheme. This strategy allows us to exploit information on admissible trajectory lengths to randomize the integration parameters directly, rather than targetting the Hamiltonian flow primarily as an intermediate object for proposal selection. Finally, as a by-product of the initial sample points and the ones obtained when visiting the level sets, we can derive a matrix M adapted to the target distribution.

Unlike calibration schemes that leverage a Markovian algorithmic structure (see, e.g., Bou-Rabee et al. 2026) the empirical distribution used in our method is based on independent weighted samples obtained through a Population Monte Carlo method (Cappé et al. 2004), a particular instance of adaptive importance sampling. As a result, the calibration stage is embarrassingly parallel and can readily be distributed across CPU cores. Furthermore, it does not require finding the scale of a burn-in period. The proposals used along this algorithm are adapted to align with an annealing sequence of distributions following Koblents and Míguez (2015). Most crucially, the temperature schedule of this annealing sequence is itself determined automatically by relying on an effective sample size criterion, which avoids the delicate tuning of additional annealing parameters. Our method shares a common feature with other adaptive importance sampling approaches, namely an exponentiation of the importance weights, which enables the transition from an initial proposal distribution to a distribution well fitted to the problem at hand. It therefore relates to annealed importance sampling (Neal 2001), sequential Monte Carlo samplers (Del Moral et al. 2006), and more recent Entropic Mirror Descent approaches (Korba and Portier 2022; Chopin et al. 2024; Cherradi et al. 2026). These methods generally pursue the more ambitious objective of constructing highly efficient proposal distributions. In contrast, the Population Monte Carlo stage in eHMC does not aim at optimizing the proposal as accurately. Our method only needs to produce a sufficiently representative weighted sample from which informative initial points and a pertinent empirical distribution over (ϵ,L) can be learned for the subsequent randomized HMC algorithm.

The plan of the paper is as follows. We begin with a brief description of HMC and NUTS in Sect. 3. We then proceed to expose our method in Sect. 4. We first detail the construction of the joint empirical distribution on (ε,L) in Sect. 4.1, before introducing a Population Monte Carlo solution to generate the initial weighted sample paramount to our solution. We illustrate the efficiency of the proposed algorithm compared to the NUTS version implemented in Stan Development Team (2024a) on several benchmark examples in Sect. 5.

Notations and conventions

In what follows, we assume that the random variables take values in Rd, possibly after a reparametrization, and admit a density with respect to the Lebesgue measure Leb. We denote by M1 the set of probability measures on Rd and by M1+ the subset of those that are positive almost everywhere. Given a probability measure π∈M1, we denote as Mπ the set of probability measures that dominates π. Given two measures μ and ν in M1, the product measure is denoted by μ⊗ν. We use the same notation to refer to a measure and its associated density, meaning that if π is absolutely continuous with respect to Leb, π(dx)=π(x)Leb(dx). We denote δθ the Dirac measure centered on a point θ∈Rd.

Hamiltonian Monte Carlo

Consider a probability measure π∈M1+ with continuously differentiable log-density on Rd, and let π~ denote an unnormalized and tractable version of π. HMC (Neal 2011) generates a Markov chain on an augmented parameter space (θ,v) where v∈Rd is an auxiliary momentum variable (as opposed to θ being called the position) independent of θ and distributed according to a d-dimensional normal distribution, N(0,M). The positive definite matrix M∈S++(Rd) is referred to as the mass matrix. We refer the reader to Betancourt (2018) for a discussion on the choice of other momentum distributions. The Hamiltonian is then defined as the unnormalized negative log-version of the joint π⊗N(0,M), namely

H(θ,v)=12vTM-1v-logπ~(θ),

and the transitions of the chain derive from Hamilton’s equations applied to the latter, namely

dθdt=∂H∂v=M-1v,dvdt=-∂H∂θ=∇logπ~(θ). 1

Such a mechanism aims at efficiently exploring the parameter space Rd×Rd as compared to standard random-walk Metropolis-Hastings proposals while yielding a marginal chain in θ with the distribution of interest. Since the dynamic preserves the Hamiltonian, the momentum and the target density increase together and conversely, facilitating moves between low and high probability regions.

In practice, the above differential equations cannot be solved analytically and HMC samplers resort to time reversible and symplectic numerical integrators. Among these, the leapfrog integrator is commonly used for its trade-off between second order accuracy and computational cost. Given a discretization time-step ε, it yields a mapping Fε:(θ,v)↦(θ⋆,v⋆) defined by

θ⋆=θ+εM-1r,v⋆=r+ε2∇logπ~(θ⋆),wherer=v+ε2∇logπ~(θ).

In order to approximate the solution θ⋆,v⋆ at time t, the integrator applies the mapping L=⌊tε⌋ times. L is referred to as the number of leapfrog steps. This discrete scheme serves as a proposal kernel for (θ,v) but no longer leaves the measure π⊗N(0,M) invariant. To account for the discretization bias and to preserve the target measure, a Metropolis-Hastings correction is introduced. A transition from (θ,v) to the proposal θ⋆,-v⋆ is accepted with probability

ρθ,v,θ⋆,v⋆=1∧expH(θ,v)-Hθ⋆,-v⋆. 2

which implies that detailed balance is satisfied for the target π⊗N(0,M). The solution of (1) keeps the Hamiltonian constant, meaning proposals are always accepted for the exact dynamic. After discretization, the deviation to H(θ,v) can be bounded (Leimkuhler and Reich 2005),

H(θ,v)-Hθ⋆,-v⋆<Cε2.

Hence, the acceptance rate (2) still tends to be high even for a proposal θ⋆,-v⋆ quite far from (θ,v), provided ε remains moderate. In practice, the choice of ε can be done on the basis of the global acceptance rate of the sampler using the primal-dual averaging method (Nesterov 2009). The latter provides an adaptive MCMC scheme which aims at a targeted acceptance probability p0∈(0,1). Under mild conditions, Beskos et al. (2013) have shown that the optimal scaling for HMC yields an acceptance probability of around 0.65. Though it is not necessarily a suitable choice for p0 in complex models, it can serve as a useful benchmark value.

When it comes to choosing the number L of integration steps, NUTS (Hoffman and Gelman 2014) is arguably the most commonly used version of HMC sampler. It eliminates the need to specify the number L of integration steps by adaptively choosing the locally largest value at each iteration of the algorithm. More precisely, given a step size ϵ, the current value of θ and a momentum v, an iteration of NUTS begins with mimicking the Hamiltonian dynamics by recursively doubling the leapfrog path, either forward or backward with equal probability, until the path begins to retrace towards the starting point. For the Euclidean version, this means that the backward and forward end points of the path, (θ-,v-) and (θ+,v+), satisfy

(θ+-θ-)⊤M-1v-<0or(θ+-θ-)⊤M-1v+<0. 3

For an extension of the aforementioned termination criterion to the non-Euclidean case, we refer the reader to Betancourt (2018). The second step of NUTS consists in randomly picking one of the position-momentum pairs visited along the forward and backward leapfrog path, each pair being weighted according to the target density. In its original version, the latter was done by a slice sampling move, but most recent versions implemented in Stan (Stan Development Team 2024b) rely on a multinomial sampling strategy. The overall process allows for detailed balance to hold and thus validates NUTS.

Compared with the standard HMC sampler, which uses a fixed length L across iterations, NUTS relies on an adaptive scheme while requiring an evaluation of the Hamiltonian along its entire leapfrog path. Even though this leapfrog path is locally the longest possible in terms of Equation (3), the final proposal is not obtained by deterministically taking the last point of the trajectory, but is picked at random among the states generated along the trajectory using slice-sampling in the original version or multinomial sampling in current Stan implementation. Progressive sampling mechanisms increase the probability of selecting states from recently built subtrees, but the distance between the proposed position and the current one may be significantly smaller than the maximal one achieved during the construction, so part of the computational effort does not translate directly into transitions of the Markov chain. This online construction is essential in targets where useful integration times vary strongly across the typical set, but may be unnecessary when a reusable distribution of integration times can be learned offline.

Empirical Hamiltonian Monte Carlo

Following the observation that the systematic construction of the longest admissible Hamiltonian trajectories may be unnecessary, we propose a two-stage procedure, referred to as the eHMC sampler (see Algorithm 1), that (i) learns a distribution over the corresponding integration parameters and (ii) reuses the latter to define a randomized version of the Hamiltonian kernel.

graphic file with name 11222_2026_10972_Figa_HTML.webp

Calibration stage

The first stage of eHMC relies on importance sampling (Kahn 1949; Kahn and Harris 1951) to approximate the target distribution π. Given N independent samples (ϑ1,⋯,ϑN) sampled from a proposal distribution μ∈Mπ, the target measure π is estimated by the empirical measure associated with the weighted sample {(ϑ1,ω1),…,(ϑN,ωN)}, where the weights are derived from the Radon–Nikodym derivative of π with respect to the proposal distribution μ, namely

π^N=∑i=1Nωiδϑi,ωi∝π~(ϑi)μ(ϑi)(i=1,…,N).

Empirical distribution of the integration time The randomization of parameters L and ε in eHMC is based on the empirical distribution of the longest integration time associated with each position. Given an augmented parameter (θ,v) and a step size ε>0, the maximal integration length in the direction v is given by the first occurrence of a U-turn, analogous to Equation (3), along the discretized Hamiltonian trajectory

L(θ,v,ε)=infℓ∈N(θℓ⋆,vℓ⋆)=Fεℓ(θ,v):(θℓ⋆-θ)⊤M-1vℓ⋆<0. 4

Lemma 1

Assume that the potential U:θ↦-logπ~(θ) is coercive, i.e., ‖U(θ)‖2→∞ as ‖θ‖2→∞. Then, for all positive definite matrices M, there exists ε⋆>0, such that for all 0<ε≤ε⋆, L(θ,v,ε) is finite π⊗N(0,M)-almost surely.

We refer the reader to Appendix A for details. Considering a set of local step sizes εi≤ε⋆ associated with each pair (ϑi,vi), i=1,…,N, we thus define an empirical measure on the induced set of maximal numbers of leapfrog steps

L={L(ϑ1,v1,ε1),…,L(ϑN,vN,εN),L(ϑ1,-v1,ε1),…,L(ϑN,-vN,εN)},

namely,

μ^L=12∑i=1NωiδL(ϑi,vi,εi)+12∑i=1NωiδL(ϑi,-vi,εi).

However, our aim is to further select the step size at random within the HMC scheme. We thus build an empirical distribution that accounts for a local adaptation of the step size for each realisation ϑi.

Consider an excursion on the discretized level set starting from a point (θ,v). The leapfrog integrator generates a sequence of pairs (θℓ,vℓ)=Fεℓ(θ,v), ℓ∈N∗. Each of these defines a valid Metropolis–Hastings proposal for the augmented target distribution based on the acceptance probability ρ(θ,v,θℓ,vℓ) as defined in Equation (2). Hence, we can locally adapt the step size by monitoring the average acceptance probability along the leapfrog path. Namely, given a user-specified target probability p0∈(0,1), we calibrate the step size from

ε¯(θ,v,p0)=sup{0<ε≤ε⋆:∑ℓ=1L(θ,v,ε)ρθ,v,θℓ,vℓL(θ,v,ε)≥p0}. 5

The probability p0 plays a role similar to target acceptance probability in the primal-dual averaging algorithm. The latter set is non empty. Indeed, for any time interval, the deviation to H(θ,v) is of order O(ε2) (Leimkuhler and Reich 2005), which ensures that for ε small enough the acceptance probability (2) becomes larger than p0. Setting εi+=ε¯(ϑi,vi,p0) and εi-=ε¯(ϑi,-vi,p0), the empirical measure on the discretization parameters is then defined as

μ^T=12∑i=1Nωiδ(εi+,L(ϑi,vi,εi+))+12∑i=1Nωiδ(εi-,L(ϑi,-vi,εi-)). 6

The U-turn criterion in (3) is chosen here as a practical device for constructing the empirical distribution (6). Its validity is theoretically motivated by Lemma 1, which establishes that the corresponding stopping time is almost surely finite and therefore induces a well-defined empirical distribution over (ε,L). Note that the U-turn criterion is not essential to the proposed methodology. Any alternative offline stopping criterion could be used, provided an analogous result holds, namely that this criterion defines an almost surely finite stopping time and hence induces a well-defined distribution over (ε,L). Once such a distribution is obtained, the validity of the final sampler no longer depends on the particular criterion at its core (see Sect. 4.2 for the stationarity argument). Alternative criteria satisfying the above requirement may then prove useful, especially in settings where the first U-turn time is not the most informative proxy for a suitable integration length, such as highly oscillatory Hamiltonian dynamics. They may further bring an assessment of convergence by comparing the resulting outcomes.

Adapting the mass matrix The Hamiltonian dynamic and consequently the empirical distribution μ^T depend on the choice of the mass matrix M. It is well known that tuning M so that M-1 accounts for the covariance structure of the target distribution π can substantially improve the efficiency of the sampler. Accordingly, we first estimate M-1 by the sample covariance of the weighted particles {(ϑ1,ω1),…,(ϑN,ωN)}, namely

M-1=∑i=1Nωiϑi-ϑ¯ϑi-ϑ¯⊤,ϑ¯=∑i=1Nωiϑi,

which corresponds to the minimizer of the Kullback–Leibler divergence over Gaussian momentum distributions (Girolami and Calderhead 2011). The latter can then be refined by exploiting the additional information provided by all the positions traced out by the integrator during the construction of the empirical measure (6). Indeed, for each initial pair (ϑi,vi), consider the sequences of position-momentum (ϑi,ℓ+,vi,ℓ+)=Fεi+ℓ(ϑi,vi) and (ϑi,ℓ-,vi,ℓ-)=Fεi-ℓ(ϑi,-vi) generated along the leapfrog trajectory. In the continuous-time, ideal, setting, these intermediate positions are distributed according to the same marginal distribution as ϑi. In the discretized setting, we account for integration error by weighting each position according to its corresponding Metropolis–Hastings acceptance probability (2). The discrete measure

ν∝∑i=1Nωi[∑ℓ=1L(ϑi,vi,εi+)δϑi,ℓ-1++ρ(ϑi,vi,ϑi,ℓ+,vi,ℓ+)δϑi,ℓ+-δϑi,ℓ-1++∑ℓ=1L(ϑi,-vi,εi-)δϑi,ℓ-1-+ρ(ϑi,-vi,ϑi,ℓ-,vi,ℓ-)δϑi,ℓ--δϑi,ℓ-1-]. 7

yields a Rao–Blackwellized empirical covariance associated with the Metropolis–Hastings transitions along each trajectory that we used to estimate M-1 (see Appendix B).

The calibration scheme thus consists of a series of adaptation epochs that alternate between updating first the mass matrix and then constructing the empirical measure (6) of the discretization parameters. For the sake of simplicity, we have described the Rao–Blackwellization based on the positions of the last excursion of each trajectory. In practice, the computation of εi, as defined in Equation (5) typically involves multiple excursions on the same level set, and all intermediate positions can be incorporated in the estimator in the same manner.

Sampling stage

In standard MCMC methods, a preliminary burn-in phase is typically required to ensure that the chain has moved sufficiently far from its initial distribution toward its invariant distribution. This transient regime is often difficult to diagnose and may incur a non-negligible computational cost. In standard NUTS implementations, this warmup phase is used to tune algorithmic parameters such as the step size and mass matrix. In eHMC, this role is transferred to the offline calibration stage. The latter provides an importance-weighted sample that yields an empirical approximation of π, removing the reliance on a transient Markov-chain phase for parameter adaptation and initialization.

Once both μ^T and M are set, they are used to define a homogeneous Markov chain. At each iteration, say k, a pair (εk,Lk) is sampled from μ^T and an HMC proposal is generated using the leapfrog integrator with mass matrix M and integration length Lkεk (see Algorithm 1). The resulting algorithm yields a randomized HMC kernel that does not belong to the class of adaptive MCMC methods with online parameter updates. Instead, it defines a mixture of Markov transition kernels with fixed mixing distribution μ^T. Since, for any fixed (ε,L), the corresponding HMC kernel leaves the target distribution π invariant (Neal 2011), it follows that the mixture kernel defined by sampling (ε,L) from μ^T also preserves π (Tierney 1994; Roberts and Rosenthal 2007).

Construction of the importance sampling proposal

The eHMC sampler relies on having an initial proposal distribution μ to derive a weighted sample approximately distributed according to π. Finding a well suited proposal μ is paramount to guarantee good statistical properties of importance sampling estimators (e.g., Agapiou et al. 2017; Chatterjee and Diaconis 2018, ), but this may prove challenging. Numerous adaptive strategies have been proposed over the past two decades to design efficient proposal distributions, and we refer the reader to Elvira and Martino (2021) for a broad overview. However the objective here differs from standard importance sampling. Rather than seeking highly accurate approximations of the target distribution in order to control bias and variance, our goal is to obtain a weighted sample that captures sufficient diversity in regions of non-negligible probability mass.

In what follows, we rely on a Population Monte Carlo (PMC) scheme (Cappé et al. 2004) to construct the proposal μ (see Algorithm 2). PMC is an adaptive importance sampling framework that generates a sequence (μt)t≥0 in Mπ by iteratively updating the proposal μt+1 using weighted samples drawn from μt. We adopt a tempering strategy inspired by Koblents and Míguez (2015) and Aufort et al. (2022), which improves robustness in complex or multimodal settings. The PMC procedure described below should be viewed as one possible solution for the offline calibration stage rather than as an essential component of the proposed methodology. More generally, any procedure yielding a representative weighted sample of the target distribution could be used to estimate the empirical distribution (6). The purpose of the calibration stage is to transfer the adaptation effort outside the final Markov chain, not to advocate a particular adaptive importance sampling method. This does not, however, eliminate all calibration choices: the quality of the initial proposal, the PMC settings (or those of any alternative calibration procedure), and the size of the calibration sample remain important practical considerations, as it is generally the case for adaptive importance sampling methods.

Proposal adaptation The initial proposal μ0 is set by the user. In a Bayesian context, a natural choice is the prior distribution. Subsequent proposals are chosen from a parametric family F⊂Mπ from which we can sample and evaluate the density. To progressively bridge the gap between μt and π, we introduce a sequence (πt)t≥1 of annealed target distributions defined, for all t≥0, as

πt+1∝π~βt+1μt1-βt+1, 8

where (βt)t≥1∈[0,1]N is a non-decreasing sequence such that β1=0 and limt→∞βt=1. This construction defines a continuum of intermediate distributions connecting μ0 to π that has been extensively used in the tempering literature (Chopin and Papaspiliopoulos 2021) and helps to uncover regions of Rd where π has non-negligible mass. At iteration t≥0, given a sample (ϑt,1,…,ϑt,N0) from μt, the annealed target πt+1 is approximated by the self-normalized importance sampling measure

π^t+1∝∑i=1N0ω~t,it+1δϑt,i,ω~t,i=π~(ϑt,i)μt(ϑt,i). 9

The next proposal is then obtained as the projection of π^t+1 onto F

μt+1=argminμ∈FKL(π^t+1‖μ)=argminμ∈F-∑i=1N0ω~t,it+1logμ(ϑt,i). 10

When F is parametric, this corresponds to computing a maximum likelihood estimate of the family parameter based on the weighted sample.

Temperature scheduling A standard strategy to define the sequence (βt)t≥1 consists in selecting βt+1 to control the effective sample size (ESS) of the importance weights (Gramacy et al. 2010; Beskos et al. 2016; Elvira and Martino 2021). Assume that at iteration t, for all β∈[0,1], π~/μt∈L2β(μt). Then, the ESS associated with proposal μt and unnormalized target μt1-βπ~β is

ESSπ~βμt1-β,μt=N∫Rdω~t(ϑ)βμt(dϑ)2∫Rdω~t(ϑ)2βμt(dϑ),ω~t(·)=π~(·)μt(·).

Its estimate

ESS^π~βμt1-β,μt=∑i=10ω~t,iβ2∑i=10ω~t,i2β, 11

quantifies the discrepancy between the weighted and unweighted empirical measures, or, equivalently, the degeneracy of the importance weights: a higher effective sample size indicates a better empirical approximation of the target distribution. In our setting, βt+1 is chosen to ensure that the reweighted sample provides a sufficiently accurate approximation of the annealed target πt+1, and avoids overfitting to the current sample. More precisely, we set

βt+1=supβ∈[0,1]:ESS^π~βμt1-β,μt≥λ0N0, 12

where λ0∈(0,1) is a user-specified parameter. Under the assumption π~/μt∈L2β(μt), the function β↦ESS(πβμt1-β,μt) is continuous and non-increasing (see Appendix D), which ensures that this update is well-defined. The adaptation stops when we obtain ESS^π~,μt≥Δ, where Δ≤λ0N0 is a user-specified threshold.

graphic file with name 11222_2026_10972_Figb_HTML.webp

Practical implementation Unlike standard adaptive importance sampling methods, where the effective sample size is controlled to ensure that a large proportion of particles carry significant weight, our objective is more modest. The threshold Δ is chosen only to guarantee a minimal level of effectiveness, sufficient to capture regions of non-negligible probability mass. The importance weights may then exhibit substantial variability. To mitigate the resulting weight degeneracy, we can perform a resampling step from the empirical measure π^t+1, possibly followed by a Markov kernel perturbation that preserves πt+1 in order to prevent sample impoverishment (see Algorithm 2). This resample-move strategy, commonly used in sequential Monte Carlo methods (Chopin and Papaspiliopoulos 2021), produces a set of unweighted particles while preserving consistency with respect to the target πt+1. Consequently, the proposal update step (10) consists in fitting μt+1 to the sample that has undergone this transformation, rather than to the original weighted sample.

In practice, this procedure can also be applied at the final iteration of the adaptation, that is once we get μ such that ESS^π~,μ≥Δ, so that the sample used in the calibration phase consists of independent and equally weighted particles, namely

π^N=1N∑i=1Nδϑi.

Numerical experiments

In this section, we assess the performance of the proposed eHMC algorithm, in comparison to NUTS, on four target distributions chosen to illustrate different challenges, including strong nonlinearity, correlation structure and multiscale geometry. All experiments were implemented using a combination of R and Python, with Stan models used to define the target distributions. We used the version of NUTS implemented in Rstan (Stan Development Team 2024a). The codes for eHMC and the experiments are available on https://github.com/jstoehr/eHMC.

Models

Banana-shaped distribution(banana) We first consider a two-dimensional nonlinear target distribution defined by

θ1∼N(0,σ12),θ2∣θ1∼Nλ(θ12-ℓ),σ22,

with σ1=10, λ=0.03, ℓ=100 and σ2=1. This distribution is commonly used as a benchmark for testing the robustness of sampling algorithms to nonlinear dependencies (Naderi et al. 2026).

Within the eHMC calibration stage, the initial proposal is set to a multivariate Gaussian distribution with mean (0,-λℓ)⊤ and diagonal covariance matrix σ12I2. The latter centers the proposal along the main curvature of the target while maintaining isotropic variability.

Multivariate Normal distribution(MVNorm) We next consider a 100-dimensional Gaussian target distribution with density

π(θ)∝exp-12θ⊤A-1θ,Ai,j=0.99|i-j|,i,j=1,⋯,100.

The covariance matrix is taken as the AR(1) correlation matrix with autoregressive parameter ρ=0.99. The resulting matrix exhibits a condition number of approximately 7.6×103, indicating a moderately ill-conditioned geometry with strong anisotropy due to strong dependence between neighboring coordinates.

The initial proposal for eHMC is set to a mixture of two Gaussian distributions centered at zero,

μ0=αN(0,Σ1)+(1-α)N(0,Σ2),α=0.1,

where the covariance matrices Σ1 and Σ2 are constructed from the eigendecomposition A=QDQ⊤ of the target covariance matrix. Specifically, Σ1 and Σ2 are defined as

Σ1=Qdiag(d1,…,d100)Q⊤,Σ2=Qdiag(λ1,…,λ100)Q⊤,

with for j=1,…,100

dj=log(Djj),Djj>1,Djj,Djj≤1,λj=0.6Djj,Djj>1,1.1Djj,Djj≤1.

This construction yields a dispersed proposal that captures different scales of the target distribution.

Bayesian logistic regression(BLP) We also consider a Bayesian logistic regression model with

θ∼N(0,I),yi∼Bernoullilogit-1(xi⊤θ),i=1,…,n.

This model yields a posterior distribution that is log-concave but may exhibit strong correlations between parameters depending on the design matrix. The inference is based on the German Credit dataset from the UCI Machine Learning Repository (Dua and Graff 2019), which consists of n=1000 observations. The design matrix includes an intercept term and 24 covariates.

The initial proposal distribution is constructed as a Gaussian approximation centered around a ridge-regularized least-squares estimate of the posterior mode. Specifically, we define the approximate precision matrix as A=X⊤X+σ-2IK. The proposal mean is then given by A-1X⊤y, with covariance matrix cA-1, where c>1 is an inflation factor introduced to broaden the proposal and improve coverage of the posterior tails. In what follows, we set c=4. This construction provides a computationally inexpensive Laplace-style initialization that is substantially better adapted to the posterior than an isotropic prior proposal.

Neal’s funnel distribution(funnel) To assess limitations of the eHMC solution, we consider Neal’s funnel distribution. For dimension d=10, the target is defined by

y∼N(0,32),xi∣y∼N(0,exp(y)),i=1,…,d-1.

Equivalently, up to an additive constant,

logπ(y,x)∝-12y29-d-12y-12exp(-y)∑i=1d-1xi2.

This target is a standard challenge for randomized HMC methods since the curvature varies strongly with the value of y. For some parts of the distribution, small changes in x require small integration time, whereas for other parts much larger moves are possible. We therefore expect dynamic trajectory construction to be more important on this target than on the previous benchmarks.

The initial proposal distribution uses the correct conditional structure but inflated conditional variance,

y∼N(0,32),xi∣y∼N(0,4exp(y)).

Although this proposal captures the characteristic funnel geometry, it remains a poor approximation of the target distribution. In particular, the variance inflation produces a substantial mismatch with the target, resulting in an effective sample size close to one particle in some experiments.).

Experimental design

For each model, the experiments were repeated over 20 seeds. For each seed, we ran 50 parallel chains and set the target acceptance probability p0∈{0.651,0.80} for both methods.

NUTS setting We use the NUTS implementation in Stan. Following the default choice, we used a diagonal mass matrix M. Each chain then consists of 4000 iterations in total, including 2000 warmup iterations during which we used the default dual averaging adaptation for the step size, and T=2000 kept samples. The computational cost of NUTS is measured by the number of gradient evaluations, or equivalently, up to a constant factor, by the total number of leapfrog steps performed during the sampling phase. The warmup phase is not included in this cost.

eHMC setting For each seed, the calibration phase of eHMC was performed using the PMC procedure described in Sect. 4.3 with an initial sample size N0=50000, λ0=0.8 and an effective sample size threshold Δ∈{0.05N0,0.1N0}. The parametric family F was defined through a normalizing flow, which provides a flexible class of tractable distributions based on an invertible and differentiable transformation that maps a simple base distribution to the distribution of (ϑt,1,…,ϑt,N0). More precisely, let {fξ:Rd→Rd}η∈Ξ be a family of bijective and differentiable mappings and p be a base distribution. The family F is defined as

F=θ↦pfξ-1(θ)detDfξ-1(θ);ξ∈Ξ,

where Dfξ-1 is the Jacobian of fξ-1. In our setting, the base distribution was set to a multivariate Gaussian N(0,Σt), where Σt denotes the covariance matrix associated with the empirical measure (9). The normalizing flow was implemented as a Masked Autoregressive Flow (MAF, Papamakarios et al. 2017, ) with 5 transformations, each parameterized by neural networks with 2 hidden layers of 32 units. The model was trained using mini-batches of size 2048 and a learning rate of 10-3. Early stopping was used with a patience of 20 epochs without validation improvement, reserving 20% of the data for validation. The procedure was implemented using zuko v1.4.0 (Rozet et al. 2022).

We stress anew that the fitted normalizing flow is not intended to serve as a transport map for running HMC on a transformed target density. Within the PMC tempering scheme, the flow is successively fitted to a sequence of annealed target distributions to improve the efficiency of the importance sampler. However, the calibration procedure stops as soon as the proposal yields a sufficiently large importance sampling ESS with respect to the target π. Consequently, the annealing sequence does not need to reach β=1, and the fitted flow approximates the last annealed distribution visited by the algorithm rather than the target distribution π.

After the proposal adaptation step, we resampled N∈{2000,5000} particles, without applying a Markov kernel perturbation. This equally weighted sample was then used to construct the empirical distribution μ^T, as defined in (6), with K=1 adaptation epoch. To match the default choice in Rstan, we used a diagonal mass matrix obtained from the diagonal of the empirical covariance estimate based on the empirical measure (7). The final eHMC chains are then run for T=2000 iterations without further online adaptation. The computational cost of eHMC is measured by the number of gradient evaluations, or equivalently, up to a constant factor, by the total number of leapfrog steps performed during the sampling phase. The offline calibration stage is not included in this cost.

Performance metrics

For each model, we compare eHMC and NUTS in terms of the effective sample size associated with the Markov chain and the expected squared jump distance. To account for differences in computational cost across samplers, performances are assessed by normalizing both metrics by the number of gradient evaluations of the log-target density, or equivalently the total number of leapfrog steps performed. This normalization reflects the fact that the evaluation of ∇logπ~ generally dominates the overall computational cost.

Markov chain effective sample size(ESSMC) We recall that the standard effective sample size associated with a Markov chain {θ(1),…,θ(T)} and a measurable function f is defined as

ESSMC(f)=T/1+2∑k=1∞ρk(f),

where ρk(f) is the lag k auto-correlation of the Markov chain {f(θ(1)),…,f(θ(T))}. Informally, the ESSMC of an MCMC output is interpretable as providing the equivalent number of independent simulations from the target distribution, where equivalent means with equivalent variance, as a function of the target acceptance probability p0. Hence, the more efficient a sampler is in its approximation to i.i.d. sampling from the target, the larger the associated ESSMC should be. In the following examples, we focus on the ESSMC for the estimation of the mean and the variance, i.e., ESSMC(θ) and ESSMC(θ2), using the monitor function from the Rstan package.

Figure 1 displays, for all configurations, the distribution of ESSMC(θ) and ESSMC(θ2) per gradient evaluation across dimensions and runs. Figure 2 reports, over runs, the distribution of their minimum taken over all components of the parameter of the model. This metric captures the least efficient direction of the sampler (see Tables 2 and 3 in Appendix E for numerical summaries).

Fig. 1.

Fig. 1

Distribution of the Markov chain effective sample size per number of leapfrog steps for mean (left panel) and variance (right panel) estimation, aggregated across dimensions and 20 independent runs of 50 parallel chains of length T=2000. For eHMC, the proposal is trained using λ0=0.8, N0=50000, from which N∈{2000,5000} resampled particles are used to construct the empirical measure on the integration parameters. Results are shown for Δ/N0∈{0.05,0.10} in the x-axis

Fig. 2.

Fig. 2

Distribution of the minimum across dimensions of the Markov chain effective sample size per number of leapfrog steps for mean (left panel) and variance (right panel) estimation, aggregated over 20 independent runs of 50 parallel chains of length T=2000. For eHMC, the proposal is trained using λ0=0.8, N0=50000, from which N∈{2000,5000} resampled particles are used to construct the empirical measure on the integration parameters. Results are shown for Δ/N0∈{0.05,0.10} in the x-axis

Table 2.

Minimum across dimensions of the Markov chain effective sample size per leapfrog step, averaged over 20 independent runs of 50 parallel chains of length T=2000, for the estimation of the mean. For eHMC, the proposal is trained using λ0=0.8, N0=50000, from which N resampled particles are used to construct the empirical measure on the integration parameters. Values are reported as mean ±2 standard errors, scaled by a factor 104. Values in bold indicate the best performance across the methods and experimental configurations

eHMC
Model NUTS Δ/N0=5% Δ/N0=10%
N=2000 N=5000 N=2000 N=5000
(a) Results for a target Metropolis–Hastings acceptance probability p0=0.651.
Banana 5.26±8.7 13.6±18 13.1±18.4 11.7±17 12.8±16
MVNorm 7.81±0.67 11.6±0.91 11.5±0.87 11.6±0.91 11.5±0.87
BLP 151±3.3 202±8.0 202±8.1 202±10 201±7.9
Funnel 0.902±0.38 2.15±2.8 2.35±2.7 1.86±1.9 2.63±2.9
(b) Results for a target Metropolis–Hastings acceptance probability p0=0.8.
Banana 10.3±16 15.2±16 18.5±19 17.3±18 19±19
MVNorm 6.73±0.42 11.3±0.81 11.4±0.42 11.3±0.81 11.4±0.42
BLP 116±5.4 232±10 232±12 234±11 232±9.3
Funnel 0.887±0.63 1.83±2.2 1.89±2.8 2.85±3.6 2.04±3.1

Table 3.

Minimum across dimensions of the Markov chain effective sample size per leapfrog step, averaged over 20 independent runs of 50 parallel chains of length T=2000, for the estimation of the variance. For eHMC, the proposal is trained using λ0=0.8, N0=50000, from which N resampled particles are used to construct the empirical measure on the integration parameters. Values are reported as mean ±2 standard errors, scaled by a factor 104. Values in bold indicate the best performance across the methods and experimental configurations

eHMC
Model NUTS Δ/N0=5% Δ/N0=10%
N=2000 N=5000 N=2000 N=5000
(a) Results for a target Metropolis–Hastings acceptance probability p0=0.651.
Banana 3.39±6.3 7.29±10 7.46±11 6.36±9.8 7.36±10
MVNorm 10.9±0.81 12.5±1.6 12.5±1.4 12.5±1.3 12.5±1.4
BLP 97.9±5.5 70.3±4.8 69.8±5.1 70.5±5.1 70.0±4.8
Funnel 6.09±5.4 2.14±3.0 1.9±1.9 1.83±2.4 2.29±3.0
(b) Results for a target Metropolis–Hastings acceptance probability p0=0.8
Banana 6.61±13 7.79±9.4 10.1±11 9.28±11 10.3±11
MVNorm 8.28±0.69 12.1±1.2 12.2±1.2 12.1±1.2 12.2±1.2
BLP 85.7±3.2 75.4±5.7 75.0±5.3 75.7±6.0 73.7±5.0
Funnel 6.77±4.7 1.53±2.0 1.57±2.0 2.27±2.6 1.92±3.0

For the banana, MVNorm, and BLP targets, eHMC generally yields larger ESSMC(θ) per gradient evaluation than NUTS across the configurations considered, with only modest sensitivity to N and Δ/N0. The largest improvements are observed for the banana distribution, where eHMC achieves a median ESSMC(θ) approximately 2 times larger than NUTS, while it is around 1.5 times larger for both BLP and MVNorm targets. On these model, between the configurations, eHMC generally provides a modest but consistent additional gain when p0 increases. Furthermore, Fig. 2 shows that for these models eHMC exhibits improved sampling efficiency even along the least efficient direction of the sampler, although we observe a higher variability for the banana target. The funnel distribution exhibits a more nuanced pattern. Although eHMC retains a larger minimum coordinate-wise ESSMC(θ) for mean estimation than NUTS (see Table 2), this metric does not capture movement between narrower and broader parts of the target (see results on ESJD). Overall, NUTS outperforms eHMC in terms of ESSMC(θ) on this example. Increasing p0 produces only modest and non-uniform changes across the funnel experiments.

Results for variance estimation are slightly more nuanced. For the banana, MVNorm, and BLP targets, although eHMC achieves competitive or improved efficiency compared to NUTS in terms of the median ESSMC(θ2) when accounting for the number of leapfrog steps performed, performance in the least efficient direction of the sampler deteriorates for the BLP target, as illustrated in Fig. 2. The contrast is stronger for the funnel example: NUTS yields a minimum variance ESS approximately three to four times larger than eHMC, depending on p0 and the calibration configuration. Overall NUTS provides an ESSMC(θ2) that overseeds eHMC performance on this multiscale target.

The expected squared jump distance (ESJD) Furthermore, considering that the ESSMC criterion only reflects on the marginal efficiency of a sampler, we report in addition the standard expected squared jump distance. While depending on the measure of the jump, this quantity appears as a global mixing assessment that expresses another aspect of the efficiency of a sampler. We recall that, given generated samples {θ(1),…,θ(T)}, its estimated ESJD is defined as

EJSD=1T-1∑t=1T-1θ(t+1)-θ(t)22.

Table 1 summarizes the ESJD per gradient evaluation averaged over 20 independent runs (see Fig. 3 in  Appendix E for the full distribution). For the banana, MVNorm, and BLP targets, eHMC yields larger ESJD per gradient evaluation than NUTS. The funnel shows the opposite behavior: NUTS has an ESJD approximately 54 times larger for p0=0.651 and 19 times larger for p0=0.8 than the best-performing eHMC configuration. The funnel example shows a substantially larger ESJD for NUTS, approximately 54 times larger for p0=0.651 and 19 times larger for p0=0.8, than the best-performing eHMC configuration. This indicates that eHMC makes much shorter effective moves through the state space. This behavior is consistent with the strong spatial heterogeneity of the funnel geometry, where the integration lengths required for efficient exploration vary considerably across the distribution support. Consequently, a single offline distribution of integration lengths is less able to accommodate these local changes than the online adaptation performed by NUTS.

Table 1.

Expected squared jump distance averaged over 20 independent runs of 50 parallel chains of length T=2000. For eHMC, the proposal is trained using λ0=0.8, N0=50000, from which N resampled particles are used to construct the empirical measure on the integration parameters. Values are reported as mean ±2 standard errors, scaled by a factor 106. Values in bold indicate the best performance across the methods and experimental configurations

eHMC
Model NUTS Δ/N0=5% Δ/N0=10%
N=2000 N=5000 N=2000 N=5000
(a) Results for a target Metropolis–Hastings acceptance probability p0=0.651.
Banana 44.2±2.7 54.6±2.9 54.4±2.6 54.9±2.5 54.7±2.1
MVNorm 3.88±0.062 5.59±0.094 5.60±0.12 5.59±0.094 5.60±0.12
BLP 0.742±0.0053 1.15±0.026 1.15±0.019 1.16±0.016 1.15±0.018
Funnel 1610±930 30.1±42 27.8±47 28.3±40 27±50
(b) Results for a target Metropolis–Hastings acceptance probability p0=0.8.
Banana 37.7±2.9 58.6±3.5 58.2±2.9 58.3±2.6 58.0±2.1
MVNorm 3.2±0.064 5.27±0.093 5.27±0.080 5.27±0.093 5.27±0.080
BLP 0.648±0.012 1.19±0.024 1.19±0.015 1.19±0.017 1.19±0.016
Funnel 599±310 31.6±44 28.1±49 27.8±39 25.1±46

Fig. 3.

Fig. 3

Distribution of the expected squared jump distance aggregated over 20 independent runs of 50 parallel chains of length T=2000. For eHMC, the proposal is trained using λ0=0.8, N0=50000, from which N∈{2000,5000} resampled particles are used to construct the empirical measure on the integration parameters. Results are shown for Δ/N0∈{0.05,0.10} in the x-axis

Taken together, the experiments expose settings in which our approach is useful. On the banana, MVNorm, and BLP examples, our empirical distribution of integration parameters yields higher sampling efficiency than NUTS for several of the considered metrics. The funnel provides a contrasting result. Because the appropriate integration scale varies strongly with position, the empirical distribution cannot reproduce the benefits of local trajectory adaptation, and NUTS performs substantially better in terms of both sampling efficiency and global movement of the Markov chain. In conclusion, and rather unsurprisingly, eHMC constitutes a relevant, automated, approach to randomized HMC that is well suited to targets whose relevant integration scales can be learned and reused offline. However, it is not intended to replace locally adaptive methods such as NUTS in settings where the appropriate integration time varies substantially across the state space.

Extensions

While the proposed approach focuses on learning a distribution over integration parameters to improve sampling efficiency, it can be naturally extended in several directions. In particular, we could introduce a partial refreshment of the momentum variable v, as commonly considered in persistent HMC methods (Neal 2001). Rather than fully resampling the momentum at each iteration, the idea is to retain it with probability η∈[0,1], thereby inducing correlation between successive trajectories and potentially improving exploration efficiency. This partial refreshment also enables trajectory reuse and can be combined with Rao–Blackwellization strategies. This modification can be exploited in the empirical distribution of integration parameters. The resulting algorithm is referred to as prHMC.

More formally, for any (ε,L), let Pε,L denote the HMC transition kernel with step size ε and L leapfrog steps, and let μ^T be a probability measure on (0,∞)×N such as (6). We then introduce a refreshment kernel that updates the auxiliary variables (v,ε,L). At each iteration, the momentum is refreshed with probability η∈[0,1]. Two variants can be considered. In the first variant, the integration parameters (ε,L) are kept fixed as long as the momentum is not refreshed. The corresponding kernel writes as

Rη(1)(v,ε,L),dv′dε′dL′=(1-η)δ(v,ε,L)(dv′dε′dL′)+ηN(0,M)(dv′)μ^T(dε′,dL′).

In the second variant, the step size ε is kept fixed when the momentum is not refreshed, while the number of leapfrog steps L is resampled at each iteration according to the marginal empirical distribution

μ^L⋆=12∑i=1NωiδL(ϑi,vi,εi+)+12∑i=1NωiδL(ϑi,-vi,εi-),

while the step size ε is resampled only when the momentum is refreshed. The corresponding kernel then writes as

Rη(2)(v,ε,L),dv′dε′dL′=(1-η)δv(dv′)δε(dε′)μ^L⋆(dL′)+ηN(0,M)(dv′)μ^T(dε′,dL′).

Keeping the step size fixed when the momentum is not refreshed enables the reuse of points previously computed along the discretized trajectory. This is achieved thanks to a flipping mechanism: the momentum is negated when a HMC proposal is rejected and left unchanged otherwise.

Q(θ,v),dθ′dv′=δθ(dθ′)δ-v(dv′).

As a result, the sampler can explore a given level set both forward and backward, thereby reusing previously generated points when the direction of the momentum flips.

The prHMC kernel is then defined for any η∈[0,1] as the mixture kernel obtained by composing the refreshment kernel and the flipping kernel with the HMC kernel, i.e.,

Pη(i)((θ,v,ε,L),dθ′dv′dε′dL′)=∫Q((θ¯,v¯),dθ′dv′)Pε′,L′(θ,v~),dθ¯dv¯Rη(i)(v,ε,L),dv~dε′dL′.

Since the Gaussian momentum distribution is invariant under the map v↦-v, the flipping kernel Q preserves the augmented target π⊗N(0,M). Moreover, the refreshment kernel Rη(i) preserves N(0,M)⊗μ^T by construction. In conclusion, since the HMC kernel leaves π⊗N(0,M) invariant, the prHMC kernel leaves the augmented measure π⊗N(0,M)⊗μ^T invariant.

While this extension is theoretically appealing and naturally complements the proposed framework by leveraging intermediate proposals along the leapfrog path to reduce the computational cost, the empirical results obtained on the set of examples considered in this paper remain inconclusive in terms of sampling efficiency (Figs. 4 and 5 in Appendix E). In particular, significant improvements are observed only on the banana distribution (Fig. 4). In terms of ESJD, performances slightly deteriorate compared with eHMC, although it remains superior to NUTS (Fig. 6 in Appendix E). This suggests that the benefits of partial refreshment may depend sensitively on the geometry of the target distribution and the interaction with the learned integration parameters. Further investigation is therefore required to better understand the regimes in which this approach is most effective.

Fig. 4.

Fig. 4

Distribution of the Markov chain effective sample size per number of leapfrog steps for mean (left panel) and variance (right panel) estimation, aggregated across dimensions and 20 independent runs of 50 parallel chains of length T=2000. prHMC denotes the variant Pη(1), where (v,ε,L) are partially refreshed with probability η=0.75. The same proposal is used for both eHMC and prHMC, trained with λ0=0.8, N0=50000 samples, from which N∈{2000,5000} particles are resampled to construct the empirical distribution on integration parameters. Results are shown for Δ/N0∈{0.05,0.10} in the x-axis

Fig. 5.

Fig. 5

Distribution of the Markov chain effective sample size per number of leapfrog steps for mean (left panel) and variance (right panel) estimation, aggregated across dimensions and 20 independent runs of 50 parallel chains of length T=2000. prHMC denotes the variant Pη(2), where (v,ε) are partially refreshed with probability η=0.75. The same proposal is used for both eHMC and prHMC, trained with λ0=0.8, N0=50000 samples, from which N∈{2000,5000} particles are resampled to construct the empirical distribution on integration parameters. Results are shown for Δ/N0∈{0.05,0.10} in the x-axis

Fig. 6.

Fig. 6

Distribution of the expected squared jumping distance over 20 independent runs of 50 parallel chains of length T=2000. The left panel shows the prHMC variant Pη(1), where (v,ε,L) are partially refreshed, and the right panel shows Pη(2), where (v,ε) are partially refreshed, with η=0.75. Both methods use the same proposal, trained with λ0=0.8, N0=50000 samples, from which N∈{2000,5000} particles are resampled to form the empirical distribution on integration parameters. Results are shown for Δ/N0∈{0.05,0.10} in the x-axis

Acknowledgements

The early version of this paper was a component of Changye Wu’s PhD thesis at Université Paris Dauphine, with which he is no longer affiliated. Christian P Robert is partially supported by the European Union under the ERC Synergy Grant 101071601 (OCEAN, 2023–2030). Views and opinions expressed are solely those of the authors and do not necessarily reflect those of the European Union or the European Research Council Executive Agency. Neither the European Union nor the granting authority can be held responsible for them. Christian P Robert is also partially supported by a PR[AI]RIE-PSAI Chair funded by the Agence Nationale de la Recherche (ANR-23-IACL-0008). Part of this paper was written while Christian P Robert was a visiting professor at Ca’ Foscari University of Venice.

Finitness of the U-turn condition

Notation 1

In what follows, let denote (θ(t),v(t)) the solution of the Hamilton’s equations (1) at time t.

Preliminary result

Lemma 2

Assume that the target distribution π admits a continuously differentiable density on Rd, and that the potential U:θ↦-logπ~(θ). Then, given (θ(0),v(0))∼π⊗N(0,M), there exists t⋆>0 such that the continuous-time Hamiltonian trajectory at time t⋆ satisfies

(θ(t⋆)-θ(0))⊤M-1v(t⋆)<0,

almost surely.

Proof

In continuous-time Hamiltonian dynamics, the conservation of the Hamiltonian and coercivity of U yield that the level sets {(θ,v):H(θ,v)≤c} are compact. Otherwise, given v∈Rd, we could find a sequence (θn)n≥1 such that limn→∞θn=∞ and for all n≥1, U(θn)≤c, which contradicts the coercivity assumption. Consequently, for all t≥0, the trajectory (θ(t),v(t)) remains in a compact set C.

Let define for all t≥0, g(t)=‖θ(t)-θ(0)‖22. Then, using Hamiltonian’s equations,

g′(t)=2(θ(t)-θ(0))⊤M-1v(t).

Hence, to prove the result, we establish that g is a decreasing function.

Assume that, for all t≥0, g′(t)≥0. Then g is non-decreasing, and, since (θ(t),v(t)) remain in a compact set, g(t) is bounded. It follows that limt→∞g(t) is finite. Since the Hamiltonian flow preserves the Lebesgue measure and the Lebesgue measure is finite on the compact set C, the Poincaré recurrence theorem implies that, for almost every initial condition (θ(0),v(0)), the trajectory returns arbitrarily close to its starting point infinitely often, i.e., there exists a sequence (tn)n≥0 such that

limn→∞tn=∞,limn→∞(θ(tn),v(tn))=(θ(0),v(0)).

It follows, in particular, that limn→∞g(tn)=0.

Since g is non-decreasing and g(0)=0, this implies that for all t≥0, g(t)=0. Thus, for all t≥0, we have θ(t)=θ(0). By the first Hamiltonian equation, we get that for all t≥0, v(t)=0. Therefore, the trajectories for which (θ(t),v(t)) remains constant belong to the set of trajectories such that v(0)=0, a set with zero measure under π⊗N(0,M).

In conclusion, for almost every initial condition, there exists t⋆>0 such that

12g′(t⋆)=(θ(t⋆)-θ(0))⊤M-1v(t⋆)<0.

□

Proof of Lemma 1

Let define for all (θ,v), and all t≥0,

g(t)=(θ(t)-θ)⊤M-1v(t⋆).

From Lemma 2, for π⊗N(0,M)-almost every initial condition (θ,v), there exists a finite time t⋆>0 such that g(t⋆)<0. Since g is continuous, for all α<0, there exists η>0 such that

∀t∈(t⋆-η,t⋆+η),g(t)≤α. A1

Let α<0. Given ε>0, the leapfrog integrator approximates the true solution with error O(ε2) on any fixed finite time interval (Leimkuhler and Reich 2005), i.e., there exists a constant C1>0 such that for all ℓ with εℓ≤t⋆+η

(θℓ,vℓ)-(θ(εℓ),v(εℓ))2≤C1ε2,(θℓ,vℓ)=Fεℓ(θ,v).

Moreover, in the proof of Lemma 2 we have seen that the level sets of the Hamiltonian {(θ,v):H(θ,v)≤c} are compact. From the approximation error of the leapfrog integrator, there exists C2>0 such that for all ℓ with εℓ≤t⋆+η,

H(θℓ,vℓ)-H(θ,v)≤C2ε2.

It follows that

(θℓ,vℓ)∈(θ′,v′):H(θ′,v′)≤H(θ,v)+C2ε2.

which is compact. The function ψ:(θ~,v)↦(θ~-θ)⊤M-1v is infinitely differentiable on R2d and therefore Lipschitz on any compact set. We thus have that there exists a constant C3 such that for all ℓ with εℓ≤t⋆+η

ψ(θℓ,vℓ)-g(εℓ)≤C3(θℓ,vℓ)-(θ(εℓ),v(εℓ))2≤C1C3ε2. A2

Let set

ε0=-αC1C3.

For all ε≤ε0, it follows from (A1) and (A2) that for all ℓ such that |εℓ-t⋆|≤η

ψ(θℓ,vℓ)=(θℓ-θ)⊤M-1vℓ≤C1C3ε2+g(εℓ)≤2α<0. A3

To conclude, there exists ε⋆≤ε0 such that {ℓ∈N:|ε⋆ℓ-t⋆|≤η} is non empty. Thus, for all ε≤ε⋆, there exists ℓ∈N that satisfies (A3), which implies that L(θ,v,ε)<∞.

Formula for the mass matrix update

Using the same notations as in Sect. 4.1, let denote for 1≤i≤N

Li+=L(ϑi,vi,εi+),ρi,ℓ+=ρ(ϑi,vi,ϑi,ℓ+,vi,ℓ+),Li-=L(ϑi,-vi,εi-),ρi,ℓ-=ρ(ϑi,-vi,ϑi,ℓ-,vi,ℓ-).

The normalizing constant of the measure ν as defined in (7) is

Z=∑i=1NωiLi++Li-.

Mean of the measure ν

m=1Z∑i=1Nωi∑ℓ=1Li+(1-ρi,ℓ+)θi,ℓ-1++ρi,ℓ+θi,ℓ++∑ℓ=1Li-(1-ρi,ℓ-)θi,ℓ-1-+ρi,ℓ-θi,ℓ-,

Variance of the measure ν Let denote

Vi+=∑ℓ=1Li+(1-ρi,ℓ+)(θi,ℓ-1+-m)(θi,ℓ-1+-m)⊤,Si+=∑ℓ=1Li+ρi,ℓ+(θi,ℓ+-m)(θi,ℓ+-m)⊤, B4
Vi-=∑ℓ=1Li-(1-ρi,ℓ-)(θi,ℓ-1--m)(θi,ℓ-1--m)⊤,Si-=∑ℓ=1Li-ρi,ℓ-(θi,ℓ--m)(θi,ℓ+-m)⊤. B5

Then the variance is given by

Varν(θ)=1Z∑i=1NωiVi++Si++Vi-+Si-.

Invariance of the randomized kernel

Lemma 3

Let μ^T be a probability measure on (0,∞)×N constructed during the calibration stage and kept fixed during the sampling phase. For any (ε,L), let Pε,L denote the Hamiltonian Monte Carlo transition kernel with step size ε and L leapfrog steps. Define the Markov transition kernel

P(x,dx′)=∫Pε,L(x,dx′)μ^T(dε,dL).

Then P leaves π invariant.

Proof

For any fixed (ε,L), the Hamiltonian Monte Carlo kernel Pε,L preserves the target distribution π, that is

∫π(dx)Pε,L(x,dx′)=π(dx′).

Then, by Fubini’s theorem,

∫π(dx)P(x,dx′)=∫π(dx)∫Pε,L(x,dx′)μ^T(dε,dL)=∫∫π(dx)Pε,L(x,dx′)μ^T(dε,dL)=∫π(dx′)μ^T(dε,dL)=π(dx′).

Therefore π is invariant for P. □

Monotonicity of the effective sample size

Lemma 4

Let μ∈Mπ. Assume that for all β∈[0,1], π/μ∈L2β(μ). Then, the function β↦ESSπ~βμ1-β,μ is continuous and non-increasing on [0, 1].

Proof

Assume ϑ∼μ. Let define the random variable X=log(π(ϑ)/μ(ϑ)). Then we can write

ESSπ~βμ1-β,μ=Eμ[exp(βX)]2Eμ[exp(2βX)].

Continuity The mapping β↦exp(βX) is continuous on [0, 2]. Moreover, for all β∈[0,2], exp(βX)≤1+exp(2X). Since, by assumption, Eμ[exp(2X)]<∞, we have that 1+exp(2X) is integrable with respect to μ. Therefore, by the dominated convergence theorem, β↦Eμ[exp(βX)] is continuous on [0, 2]. It follows that β↦ESSπ~βμ1-β,μ is continuous on [0, 1] as ratio of positive and continuous functions.

Monotonicity Define for all β∈[0,1]

g(β)=logESSπ~βμ1-β,μ=2κ(b)-κ(2β),κ:β↦logEμ[exp(βX)].

The function κ is the cumulant generating function associated with X. It is twice differentiable on the interior of the set D={β∈R:Eμ[exp(βX)]<∞}. Since, for all β∈[0,1], π/μ∈L2β(μ), we have that [0,2]⊆D. Thus κ is twice differentiable on (0, 2). If, for all β∈(0,2), we define the exponentially tilted measure

μβ(dϑ)=exp(βX)Eμ[exp(βX)μ(dϑ),

we have

κ′(β)=Eμβ[X],κ′′(β)=Varμβ[X]≥0.

It follows that κ′ is non-decreasing on (0, 2) and for all β∈(0,1),

g′(β)=2κ′(b)-2κ′(2β)≤0.

Therefore, g is non-increasing on (0, 1). Since g is continuous on [0, 1], we get that g, and consequently β↦ESSπ~βμ1-β,μ, is non-increasing on [0, 1]. □

Additional numerical results

prHMC denotes the variant Pη(1), where (v,ε,L) are partially refreshed with probability η=0.75. The same proposal is used for both eHMC and prHMC, trained with N0=50000 samples, from which N∈{2000,5000} particles are resampled to construct the empirical distribution on integration parameters. Results are shown for Δ/N0∈{0.05,0.10} in the x-axis.

Author Contributions

Changye Wu, Julien Stoehr and Christian P Robert contributed to the creation and development of the method and to the redaction of the paper. Changye Wu then Julien Stoehr wrote successive versions of the code behind the experiments. Pierre Pudlo suggested a significant improvement to the approach that led to the current version and reviewed the manuscript.

Data Availability

The code used in this article is available at https://github.com/jstoehr/eHMC

Code availability

The code used in this article is available at https://github.com/jstoehr/eHMC.

Footnotes

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Changye Wu, Christian P. Robert and Julien Stoehr have contributed equally to this work.

References

  1. Aufort, G., Pudlo, P., Burgarella, D.: Tempered, anti-trunctated, multiple importance sampling (2022). https://arxiv.org/abs/2205.01501
  2. Agapiou, S., Papaspiliopoulos, O., Sanz-Alonso, D., Stuart, A.M.: Importance sampling: intrinsic dimension and computational cost. Stat. Sci. 32(3), 405–431 (2017). 10.1214/17-STS611 [DOI] [Google Scholar]
  3. Betancourt, M.J., Byrne, S., Girolami, M.: Optimizing the integrator step size for Hamiltonian Monte Carlo (2015). https://arxiv.org/abs/1411.6669
  4. Betancourt, M.J.: A conceptual introduction to Hamiltonian Monte Carlo (2018). https://arxiv.org/abs/1701.02434
  5. Beskos, A., Jasra, A., Kantas, N., Thiery, A.: On the convergence of adaptive sequential Monte Carlo methods. Ann. Appl. Probab. 26(2), 1111–1146 (2016). 10.1214/15-AAP1113 [DOI] [Google Scholar]
  6. Beskos, A., Pillai, N., Roberts, G., Sanz-Serna, J.-M., Stuart, A.: Optimal tuning of the hybrid Monte Carlo algorithm. Bernoulli 19(5A), 1501–1534 (2013). 10.3150/12-BEJ414 [DOI] [Google Scholar]
  7. Bou-Rabee, N., Carpenter, B., Kleppe, T.S., Liu, S.: The within-orbit adaptive leapfrog no-u-turn sampler. Journal of Machine Learning Research 27(113), 1–64 (2026). http://jmlr.org/papers/v27/25-1452.html
  8. Bou-Rabee, N., Carpenter, B., Kleppe, T.S., Marsden, M.: Incorporating local step-size adaptivity into the no-u-turn sampler using Gibbs self-tuning. J. Chem. Phys. 163(8), 084119 (2025). 10.1063/5.0280793 [DOI] [PubMed] [Google Scholar]
  9. Bou-Rabee, N., Sanz-Serna, J.M.: Randomized Hamiltonian Monte Carlo. Ann. Appl. Probab. 27(4), 2159–2194 (2017). 10.1214/16-AAP1255 [DOI] [Google Scholar]
  10. Chopin, N., Crucinio, F.R., Korba, A.: A connection between tempering and entropic mirror descent (2024). https://arxiv.org/abs/2310.11914
  11. Chatterjee, S., Diaconis, P.: The sample size required in importance sampling. Ann. Appl. Probab. 28(2), 1099–1135 (2018). 10.1214/17-AAP1326 [DOI] [Google Scholar]
  12. Cappé, O., Guillin, A., Marin, J.-M., Robert, C.P.: Population Monte Carlo. J. Comput. Graph. Stat. 13(4), 907–929 (2004). 10.1198/106186004X12803 [DOI] [Google Scholar]
  13. Cherradi, A., Janati, Y., Durmus, A., Le Corff, S., Petetin, Y., Stoehr, J.: Entropic mirror Monte Carlo (2026). https://arxiv.org/abs/2602.03165
  14. Chopin, N., Papaspiliopoulos, O.: An Introduction to Sequential Monte Carlo. Springer Series in Statistics. Springer, Cham (2021). 10.1007/978-3-030-47845-2 [DOI]
  15. Dua, D., Graff, C.: UCI machine learning repository (2019). http://archive.ics.uci.edu/ml
  16. Duane, S., Kennedy, A.D., Pendleton, B.J., Roweth, D.: Hybrid Monte Carlo. Phys. Lett. B 195(2), 216–222 (1987). 10.1016/0370-2693(87)91197-X [DOI] [Google Scholar]
  17. Del Moral, P., Doucet, A., Jasra, A.: Sequential Monte Carlo samplers. J. R. Stat. Soc. Ser. B (Stat. Methodol.) 68(3), 411–436 (2006). 10.1111/j.1467-9868.2006.00553.x [DOI]
  18. Elvira, V., Martino, L.: Advances in Importance Sampling, pp. 1–14. Wiley (2021). 10.1002/9781118445112.stat08284 [DOI]
  19. Girolami, M., Calderhead, B.: Riemann manifold Langevin and Hamiltonian Monte Carlo methods. J. R. Stat. Soc. Ser. B (Stat. Methodol.) 73(2), 123–214 (2011). 10.1111/j.1467-9868.2010.00765.x [DOI] [Google Scholar]
  20. Gramacy, R., Samworth, R., King, R.: Importance tempering. Stat. Comput. 20(1), 1–7 (2010). 10.1007/s11222-008-9108-5 [DOI] [Google Scholar]
  21. Hoffman, M.D., Gelman, A.: The No-U-turn sampler: adaptively setting path lengths in Hamiltonian Monte Carlo. J. Mach. Learn. Res. 15(1), 1593–1623 (2014). (https://jmlr.org/papers/v15/hoffman14a.html) [Google Scholar]
  22. Hairer, E., Lubich, C., Wanner, G.: Geometric numerical integration illustrated by the Störmer-Verlet method. Acta Numer 12, 399–450 (2003). 10.1017/S0962492902000144 [DOI]
  23. Kahn, H.: Stochastic (Monte Carlo) Attenuation Analysis: June 14, 1949. R-163. R (Rand Corporation). Rand Corporation, Santa Monica (1949)
  24. Kahn, H., Harris, T.E.: Estimation of particle transmission by random sampling. Natl. Bureau Stand. Appl. Math. Ser. 12, 27–30 (1951) [Google Scholar]
  25. Koblents, E., Míguez, J.: A population Monte Carlo scheme with transformed weights and its application to stochastic kinetic models. Stat. Comput. 25(2), 407–425 (2015). 10.1007/s11222-013-9440-2 [DOI]
  26. Korba, A., Portier, F.: Adaptive importance sampling meets mirror descent: a bias-variance tradeoff. In: Singh, A., Zhu, J. (eds.) Proceedings of The 25th International Conference on Artificial Intelligence and Statistics. Proceedings of Machine Learning Research, vol. 151, pp. 11503–11527. PMLR, Virtual Event (2022). https://proceedings.mlr.press/v151/korba22a.html
  27. Leimkuhler, B., Reich, S.: Simulating Hamiltonian Dynamics. Cambridge Monographs on Applied and Computational Mathematics. Cambridge University Press, Cambridge (2005). 10.1017/CBO9780511614118 [DOI]
  28. Neal, R.M.: Annealed importance sampling. Stat. Comput. 11(2), 125–139 (2001). 10.1023/A:1008923215028 [DOI] [Google Scholar]
  29. Neal, R.M.: MCMC using Hamiltonian dynamics. In: S. Brooks, A. Gelman, G. Jones, and X.L. Meng (eds.) Handbook of Markov Chain Monte Carlo, pp. 113–162. CRC Press, (2011). 10.1201/b10905 [DOI]
  30. Nesterov, Y.: Primal-dual subgradient methods for convex problems. Math. Program. 120(1), 221–259 (2009). 10.1007/s10107-007-0149-x [DOI] [PMC free article] [PubMed] [Google Scholar]
  31. Naderi, D., Robert, C.P., Kamary, K., Wraith, D.: Approximating evidence via bounded harmonic means. Stat. Comput. 36, 120 (2026). 10.1007/s11222-026-10875-z [DOI] [PMC free article] [PubMed] [Google Scholar]
  32. Papamakarios, G., Pavlakou, T., Murray, I.: Masked Autoregressive Flow for Density Estimation. In: Guyon, I., Luxburg, U.V., Bengio, S., Wallach, H., Fergus, R., Vishwanathan, S., Garnett, R. (eds.) Advances in Neural Information Processing Systems 30, pp. 2338–2347. Curran Associates, Inc., Red Hook, NY, USA (2017). https://proceedings.neurips.cc/paper_files/paper/2017/file/6c1da886822c67822bcf3679d04369fa-Paper.pdf
  33. Rozet, F., et al.: Zuko: Normalizing flows in PyTorch. Software package, MIT License (2022). 10.5281/zenodo.7625672 . https://pypi.org/project/zuko [DOI]
  34. Roberts, G.O., Rosenthal, J.S.: Coupling and ergodicity of adaptive Markov Chain Monte Carlo algorithms. J. Appl. Probab. 44(2), 458–475 (2007). 10.1239/jap/1183667414 [DOI] [Google Scholar]
  35. Stan Development Team: RStan: the R interface to Stan. R package version 2.32.6 (2024a). https://mc-stan.org/
  36. Stan Development Team: Stan Modeling Language Users Guide and Reference Manual. (2024b). Version 2.34.0. https://mc-stan.org/
  37. Tierney, L.: Markov Chains for exploring posterior distributions. Ann. Stat. 22, 1701–1762 (1994). 10.1214/aos/1176325750 [DOI] [Google Scholar]
  38. Wang, Z., Mohamed, S., De Freitas, N.: Adaptive Hamiltonian and Riemann manifold Monte Carlo samplers. In: Dasgupta, S., McAllester, D. (eds.) Proceedings of the 30th International Conference on Machine Learning. Proceedings of Machine Learning Research, vol. 28, pp. 1462–1470. PMLR, Atlanta, Georgia, USA (2013). https://proceedings.mlr.press/v28/wang13e.html

Associated Data

This section collects any data citations, data availability statements, or supplementary materials included in this article.

Data Availability Statement

The code used in this article is available at https://github.com/jstoehr/eHMC

The code used in this article is available at https://github.com/jstoehr/eHMC.


Articles from Statistics and Computing are provided here courtesy of Springer

RESOURCES