Initializing HMC with Pathfinder

The MCMC warm-up phase

When using MCMC to draw samples from some target distribution, there is often a lengthy warm-up phase with 2 phases:

  1. converge to the typical set (the region of the target distribution where the bulk of the probability mass is located)
  2. adapt any tunable parameters of the MCMC sampler (optional)

While (1) often happens fairly quickly, (2) usually requires a lengthy exploration of the typical set to iteratively adapt parameters suitable for further exploration. An example is the widely used windowed adaptation scheme of Hamiltonian Monte Carlo (HMC) in Stan, where a step size and positive definite metric (aka mass matrix) are adapted.[1] For posteriors with complex geometry, the adaptation phase can require many evaluations of the gradient of the log density function of the target distribution.

Pathfinder can be used to initialize MCMC, and in particular HMC, in 3 ways:

  1. Initialize MCMC from one of Pathfinder's draws (replace phase 1 of the warm-up).
  2. Initialize an HMC metric adaptation from the inverse of the covariance of the multivariate normal approximation (replace the first window of phase 2 of the warm-up).
  3. Use the inverse of the covariance as the metric without further adaptation (replace phase 2 of the warm-up).

This tutorial demonstrates all three approaches with DynamicHMC.jl and AdvancedHMC.jl. Both of these packages have standalone implementations of adaptive HMC (aka NUTS) and can be used independently of any probabilistic programming language (PPL). Both the Turing and Soss PPLs have some DynamicHMC integration, while Turing also integrates with AdvancedHMC.

For demonstration purposes, we'll use the following dummy data:

using LinearAlgebra, Pathfinder, Random, StatsFuns, StatsPlots

Random.seed!(91)

x = 0:0.01:1
y = @. sin(10x) + randn() * 0.2 + x

scatter(x, y; xlabel="x", ylabel="y", legend=false, msw=0, ms=2)
Example block output

We'll fit this using a simple polynomial regression model:

\[\begin{aligned} \sigma &\sim \text{Half-Normal}(\mu=0, \sigma=1)\\ \alpha, \beta_j &\sim \mathrm{Normal}(\mu=0, \sigma=1)\\ \hat{y}_i &= \alpha + \sum_{j=1}^J x_i^j \beta_j\\ y_i &\sim \mathrm{Normal}(\mu=\hat{y}_i, \sigma=\sigma) \end{aligned}\]

We just need to implement the log-density function of the resulting posterior.

struct RegressionProblem{X,Z,Y}
    x::X
    J::Int
    z::Z
    y::Y
end
function RegressionProblem(x, J, y)
    z = x .* (1:J)'
    return RegressionProblem(x, J, z, y)
end

function (prob::RegressionProblem)(θ)
    σ = θ.σ
    α = θ.α
    β = θ.β
    z = prob.z
    y = prob.y
    lp = normlogpdf(σ) + logtwo
    lp += normlogpdf(α)
    lp += sum(normlogpdf, β)
    y_hat = muladd(z, β, α)
    lp += sum(eachindex(y_hat, y)) do i
        return normlogpdf(y_hat[i], σ, y[i])
    end
    return lp
end

J = 3
dim = J + 2
model = RegressionProblem(x, J, y)
ndraws = 1_000;

DynamicHMC.jl

To use DynamicHMC, we first need to transform our model to an unconstrained space using TransformVariables.jl and wrap it in a type that implements the LogDensityProblems.jl interface:

using DynamicHMC, ForwardDiff, LogDensityProblems, LogDensityProblemsAD, TransformVariables
using TransformedLogDensities: TransformedLogDensity

transform = as((σ=asℝ₊, α=asℝ, β=as(Array, J)))
P = TransformedLogDensity(transform, model)
∇P = ADgradient(:ForwardDiff, P)
ForwardDiff AD wrapper for TransformedLogDensity of dimension 5, w/ chunk size 5

Pathfinder can take any object that implements this interface.

result_pf = pathfinder(∇P)
Single-path Pathfinder result
  tries: 1
  draws: 5
  fit iteration: 18 (total: 18)
  fit ELBO: -117.22 ± 0.37
  fit distribution: Distributions.MvNormal{Float64, Pathfinder.WoodburyPDMat{Float64, LinearAlgebra.Diagonal{Float64, Vector{Float64}}, Matrix{Float64}, Matrix{Float64}, Pathfinder.WoodburyPDFactorization{Float64, LinearAlgebra.Diagonal{Float64, Vector{Float64}}, LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}, LinearAlgebra.UpperTriangular{Float64, Matrix{Float64}}}}, Vector{Float64}}(
dim: 5
μ: [-0.3519374273204284, 0.24690059981721027, 0.05827588220628821, 0.11655176441259646, 0.17482764661887396]
Σ: [0.004949933747296435 -2.955898427968866e-5 … 2.557166652262828e-5 -8.25304682314839e-7; -2.955898427968866e-5 0.018880305102344737 … -0.0040284933725784 -0.006029641542657347; … ; 2.557166652262828e-5 -0.0040284933725784 … 0.7150984372075433 -0.42600764382195383; -8.25304682314839e-7 -0.006029641542657347 … -0.42600764382195383 0.2593643591486953]
)
init_params = result_pf.draws[:, 1]
5-element Vector{Float64}:
 -0.33885229886417645
  0.08296406563474051
 -0.23485564908890078
  1.8064111488326986
 -0.7840474133072876
inv_metric = result_pf.fit_distribution.Σ
5×5 Pathfinder.WoodburyPDMat{Float64, LinearAlgebra.Diagonal{Float64, Vector{Float64}}, Matrix{Float64}, Matrix{Float64}, Pathfinder.WoodburyPDFactorization{Float64, LinearAlgebra.Diagonal{Float64, Vector{Float64}}, LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}, LinearAlgebra.UpperTriangular{Float64, Matrix{Float64}}}}:
  0.00494993  -2.9559e-5   -1.02566e-5   2.55717e-5  -8.25305e-7
 -2.9559e-5    0.0188803   -0.00200533  -0.00402849  -0.00602964
 -1.02566e-5  -0.00200533   0.0340865   -0.144119     0.0860645
  2.55717e-5  -0.00402849  -0.144119     0.715098    -0.426008
 -8.25305e-7  -0.00602964   0.0860645   -0.426008     0.259364

Initializing from Pathfinder's draws

Here we just need to pass one of the draws as the initial point q:

result_dhmc1 = mcmc_with_warmup(
    Random.GLOBAL_RNG,
    ∇P,
    ndraws;
    initialization=(; q=init_params),
    reporter=NoProgressReport(),
)
(posterior_matrix = [-0.4871433358107486 -0.304939214797314 … -0.4173078272827865 -0.3324828762821189; 0.21902713036163574 0.12706382318073242 … 0.18832126990820922 0.30965529936443187; … ; 1.1362464443877025 1.462726531992034 … -1.4486641911682598 -0.5112897086358994; -0.1011926396582225 -0.6198973626718197 … 0.4682457137207655 0.3749036250861982], tree_statistics = DynamicHMC.TreeStatisticsNUTS[DynamicHMC.TreeStatisticsNUTS(-119.33221584516926, 6, turning at positions -49:14, 0.9997247851841101, 63, DynamicHMC.Directions(0xb2494cce)), DynamicHMC.TreeStatisticsNUTS(-117.529012775356, 6, turning at positions -48:15, 0.9955945876921096, 63, DynamicHMC.Directions(0x40e6d64f)), DynamicHMC.TreeStatisticsNUTS(-115.36976857020235, 7, turning at positions -77:50, 0.9353171433381163, 127, DynamicHMC.Directions(0x07269cb2)), DynamicHMC.TreeStatisticsNUTS(-121.95023658789651, 5, turning at positions 28:59, 0.9997038016655886, 63, DynamicHMC.Directions(0x9626f83b)), DynamicHMC.TreeStatisticsNUTS(-123.16709262548116, 7, turning at positions -14:113, 0.9894783709970929, 127, DynamicHMC.Directions(0x00008971)), DynamicHMC.TreeStatisticsNUTS(-121.62528583553679, 6, turning at positions -63:0, 0.9884487252447438, 63, DynamicHMC.Directions(0xeadde540)), DynamicHMC.TreeStatisticsNUTS(-120.35434099088623, 6, turning at positions -25:38, 0.9281900734307157, 63, DynamicHMC.Directions(0xbd72bfa6)), DynamicHMC.TreeStatisticsNUTS(-117.18631540983344, 6, turning at positions -32:-95, 0.9892536862092006, 127, DynamicHMC.Directions(0x6fadb320)), DynamicHMC.TreeStatisticsNUTS(-115.8115311541635, 6, turning at positions -58:-121, 0.9892237971821295, 127, DynamicHMC.Directions(0xd6413f86)), DynamicHMC.TreeStatisticsNUTS(-117.16592397049423, 7, turning at positions -50:77, 0.9372320440621519, 127, DynamicHMC.Directions(0x243efa4d))  …  DynamicHMC.TreeStatisticsNUTS(-117.77290968222333, 6, turning at positions -55:8, 0.9077875694457378, 63, DynamicHMC.Directions(0xd4e36d08)), DynamicHMC.TreeStatisticsNUTS(-117.43665379044967, 7, turning at positions -102:25, 0.9700035315780252, 127, DynamicHMC.Directions(0x59946719)), DynamicHMC.TreeStatisticsNUTS(-115.94814629152911, 6, turning at positions -48:15, 0.9924751050747589, 63, DynamicHMC.Directions(0x20d9530f)), DynamicHMC.TreeStatisticsNUTS(-114.90139563020665, 6, turning at positions -11:52, 0.999932597180859, 63, DynamicHMC.Directions(0x8a58b6b4)), DynamicHMC.TreeStatisticsNUTS(-114.51606885927121, 5, turning at positions -10:21, 0.974707506961418, 31, DynamicHMC.Directions(0x73b8a515)), DynamicHMC.TreeStatisticsNUTS(-115.54328984078619, 6, turning at positions -3:60, 0.9998728142596766, 63, DynamicHMC.Directions(0xd118247c)), DynamicHMC.TreeStatisticsNUTS(-116.2266184857082, 6, turning at positions -61:-68, 0.8108132397298926, 71, DynamicHMC.Directions(0x7a662503)), DynamicHMC.TreeStatisticsNUTS(-119.21324315395375, 3, turning at positions -1:-4, 0.695613266604538, 11, DynamicHMC.Directions(0x9621a2b7)), DynamicHMC.TreeStatisticsNUTS(-122.01190004528222, 6, turning at positions -42:21, 0.9960329075002314, 63, DynamicHMC.Directions(0x22a35015)), DynamicHMC.TreeStatisticsNUTS(-118.77826173793892, 5, turning at positions -2:-17, 0.989222575112662, 47, DynamicHMC.Directions(0x400b2b1e))], κ = Gaussian kinetic energy (Diagonal), √diag(M⁻¹): [0.10238662813298723, 0.15514114930958273, 1.0208094116556004, 0.8545399039394352, 0.6476299324148389], ϵ = 0.03949439550973489)

Initializing metric adaptation from Pathfinder's estimate

To start with Pathfinder's inverse metric estimate, we just need to initialize a GaussianKineticEnergy object with it as input:

result_dhmc2 = mcmc_with_warmup(
    Random.GLOBAL_RNG,
    ∇P,
    ndraws;
    initialization=(; q=init_params, κ=GaussianKineticEnergy(inv_metric)),
    warmup_stages=default_warmup_stages(; M=Symmetric),
    reporter=NoProgressReport(),
)
(posterior_matrix = [-0.44260039014973507 -0.35567477878398246 … -0.5140036241672554 -0.39141105734228987; 0.39042895612072304 0.34076321892452777 … 0.25404257228008437 0.31468934960619505; … ; 0.04989603936002368 0.2282248526526212 … -0.12853421886937266 0.43119977691478206; -0.10617025354166564 0.05463805681470104 … 0.7506587763926053 0.19033688229110463], tree_statistics = DynamicHMC.TreeStatisticsNUTS[DynamicHMC.TreeStatisticsNUTS(-114.67001256567424, 3, turning at positions -7:0, 0.9884103285537247, 7, DynamicHMC.Directions(0xe15f4f70)), DynamicHMC.TreeStatisticsNUTS(-114.9171649494172, 3, turning at positions -4:3, 0.9794096178185457, 7, DynamicHMC.Directions(0x6ea8d5a3)), DynamicHMC.TreeStatisticsNUTS(-114.26962894783777, 3, turning at positions -4:3, 0.93772978511384, 7, DynamicHMC.Directions(0xaa99921b)), DynamicHMC.TreeStatisticsNUTS(-114.83242212038887, 3, turning at positions -1:6, 0.9886942635448407, 7, DynamicHMC.Directions(0x4d30d626)), DynamicHMC.TreeStatisticsNUTS(-115.13390836032549, 3, turning at positions -3:4, 0.8449724043388774, 7, DynamicHMC.Directions(0x76861d94)), DynamicHMC.TreeStatisticsNUTS(-114.46707852932569, 3, turning at positions -2:5, 0.9885840419123554, 7, DynamicHMC.Directions(0xcbb133f5)), DynamicHMC.TreeStatisticsNUTS(-114.89398574787083, 3, turning at positions -7:0, 0.9911488995744564, 7, DynamicHMC.Directions(0xbc449928)), DynamicHMC.TreeStatisticsNUTS(-116.64015811318046, 3, turning at positions -3:4, 0.9467907518079901, 7, DynamicHMC.Directions(0x75afb2ac)), DynamicHMC.TreeStatisticsNUTS(-115.05060208114294, 3, turning at positions -4:3, 0.9999999999999999, 7, DynamicHMC.Directions(0x5a93ce0b)), DynamicHMC.TreeStatisticsNUTS(-116.36536456441196, 3, turning at positions -6:1, 0.9635741785669218, 7, DynamicHMC.Directions(0xa78d3b41))  …  DynamicHMC.TreeStatisticsNUTS(-116.7771019124503, 4, turning at positions -12:3, 1.0, 15, DynamicHMC.Directions(0x9578f273)), DynamicHMC.TreeStatisticsNUTS(-116.869390849553, 3, turning at positions 8:15, 0.9687685431148193, 15, DynamicHMC.Directions(0x9b4ce5af)), DynamicHMC.TreeStatisticsNUTS(-116.82127759534364, 3, turning at positions -4:3, 0.9300949282423179, 7, DynamicHMC.Directions(0x1c375c53)), DynamicHMC.TreeStatisticsNUTS(-116.82198491459629, 3, turning at positions -1:6, 0.9691749877377026, 7, DynamicHMC.Directions(0xe3be85e6)), DynamicHMC.TreeStatisticsNUTS(-115.20166682348874, 3, turning at positions -2:5, 0.9718008245471259, 7, DynamicHMC.Directions(0xbb4f9e65)), DynamicHMC.TreeStatisticsNUTS(-115.8398623947669, 3, turning at positions -7:0, 0.8735774801065063, 7, DynamicHMC.Directions(0x9b9d58c8)), DynamicHMC.TreeStatisticsNUTS(-114.87313875303768, 3, turning at positions -6:1, 0.9343118694006938, 7, DynamicHMC.Directions(0x03173d39)), DynamicHMC.TreeStatisticsNUTS(-116.87387120050671, 2, turning at positions 1:4, 0.8901181568378264, 7, DynamicHMC.Directions(0xdd4da0d4)), DynamicHMC.TreeStatisticsNUTS(-118.57242904684819, 3, turning at positions -6:1, 0.8569699655810622, 7, DynamicHMC.Directions(0x042cf939)), DynamicHMC.TreeStatisticsNUTS(-117.8405153839087, 3, turning at positions -4:3, 0.9999999999999999, 7, DynamicHMC.Directions(0x1a9f004b))], κ = Gaussian kinetic energy (Symmetric), √diag(M⁻¹): [0.08969865399740508, 0.16258344295878005, 0.8918236246177853, 0.8029216577868522, 0.5634519943441314], ϵ = 0.38950046178306047)

We also specified that DynamicHMC should tune a dense Symmetric matrix. However, we could also have requested a Diagonal metric.

Use Pathfinder's metric estimate for sampling

To turn off metric adaptation entirely and use Pathfinder's estimate, we just set the number and size of the metric adaptation windows to 0.

result_dhmc3 = mcmc_with_warmup(
    Random.GLOBAL_RNG,
    ∇P,
    ndraws;
    initialization=(; q=init_params, κ=GaussianKineticEnergy(inv_metric)),
    warmup_stages=default_warmup_stages(; middle_steps=0, doubling_stages=0),
    reporter=NoProgressReport(),
)
(posterior_matrix = [-0.33084386145400063 -0.3528979796549558 … -0.28367855482146836 -0.33402215509096833; 0.5586589033362924 -0.02442154629361218 … 0.1843057422190534 0.36275659240661035; … ; -0.12985616453085547 -0.44585844805993224 … -1.1192235506148331 -0.040525931574812546; 0.366009913848098 0.8215454221560039 … 1.4419689761771572 0.5257967360893915], tree_statistics = DynamicHMC.TreeStatisticsNUTS[DynamicHMC.TreeStatisticsNUTS(-117.04784407544645, 3, turning at positions -1:6, 0.965545288895804, 7, DynamicHMC.Directions(0xe87a2c7e)), DynamicHMC.TreeStatisticsNUTS(-116.11424704733518, 3, turning at positions -2:5, 0.9982956476067487, 7, DynamicHMC.Directions(0xb0ebb91d)), DynamicHMC.TreeStatisticsNUTS(-119.51070878653819, 3, turning at positions -5:2, 0.8336509463340473, 7, DynamicHMC.Directions(0x3b3fbb62)), DynamicHMC.TreeStatisticsNUTS(-119.24674809480798, 3, turning at positions 5:12, 0.9687903024090777, 15, DynamicHMC.Directions(0xd4b96aec)), DynamicHMC.TreeStatisticsNUTS(-114.87001361313786, 3, turning at positions -3:4, 0.9985494556998671, 7, DynamicHMC.Directions(0x3a76ddfc)), DynamicHMC.TreeStatisticsNUTS(-114.4287887814617, 3, turning at positions 0:7, 0.9749121748811856, 7, DynamicHMC.Directions(0xca822bff)), DynamicHMC.TreeStatisticsNUTS(-113.99580177355784, 5, turning at positions 32:39, 0.93619878867697, 39, DynamicHMC.Directions(0xa8dc6b7f)), DynamicHMC.TreeStatisticsNUTS(-114.5218761655301, 4, turning at positions 27:30, 0.9849913791453966, 31, DynamicHMC.Directions(0xe7af043e)), DynamicHMC.TreeStatisticsNUTS(-114.78186362629005, 2, turning at positions 0:3, 0.8761953621748427, 3, DynamicHMC.Directions(0x8c425feb)), DynamicHMC.TreeStatisticsNUTS(-115.65695463347338, 4, turning at positions -16:-23, 0.9701926584521389, 31, DynamicHMC.Directions(0x0ce744c8))  …  DynamicHMC.TreeStatisticsNUTS(-115.47840560107599, 3, turning at positions -7:0, 0.8605785461572621, 7, DynamicHMC.Directions(0x20b53e98)), DynamicHMC.TreeStatisticsNUTS(-114.79393237838103, 2, turning at positions -1:2, 0.9150301880739988, 3, DynamicHMC.Directions(0x3a347a56)), DynamicHMC.TreeStatisticsNUTS(-116.92263177406357, 3, turning at positions 4:11, 0.9381353460966203, 15, DynamicHMC.Directions(0xe5b60a0b)), DynamicHMC.TreeStatisticsNUTS(-122.37124567134737, 4, turning at positions -16:-23, 0.6964694314710561, 23, DynamicHMC.Directions(0x7e727c40)), DynamicHMC.TreeStatisticsNUTS(-119.21689483902684, 4, turning at positions 4:11, 0.9785348230068085, 23, DynamicHMC.Directions(0xb7997953)), DynamicHMC.TreeStatisticsNUTS(-118.06121128191349, 3, turning at positions -1:6, 0.9965537921107794, 7, DynamicHMC.Directions(0x0d3366b6)), DynamicHMC.TreeStatisticsNUTS(-116.0592366912723, 3, turning at positions -2:5, 0.9982603774410743, 7, DynamicHMC.Directions(0x8b2e8a1d)), DynamicHMC.TreeStatisticsNUTS(-117.44611463582619, 3, turning at positions -6:1, 0.8703677347874471, 7, DynamicHMC.Directions(0x9e50fcc1)), DynamicHMC.TreeStatisticsNUTS(-116.88284726807424, 3, turning at positions 5:8, 0.9301048045367757, 15, DynamicHMC.Directions(0x157b3698)), DynamicHMC.TreeStatisticsNUTS(-116.253278076592, 3, turning at positions 2:9, 0.9999868831425851, 15, DynamicHMC.Directions(0x4c630cb9))], κ = Gaussian kinetic energy (WoodburyPDMat), √diag(M⁻¹): [0.07035576555831399, 0.13740562252813654, 0.18462519775721625, 0.8456349314021646, 0.5092782728024979], ϵ = 0.7412372651059731)

AdvancedHMC.jl

Similar to Pathfinder and DynamicHMC, AdvancedHMC can also work with a LogDensityProblem:

using AdvancedHMC

nadapts = 500;

Initializing from Pathfinder's draws

metric = DiagEuclideanMetric(dim)
hamiltonian = Hamiltonian(metric, ∇P)
ϵ = find_good_stepsize(hamiltonian, init_params)
integrator = Leapfrog(ϵ)
kernel = HMCKernel(Trajectory{MultinomialTS}(integrator, GeneralisedNoUTurn()))
adaptor = StepSizeAdaptor(0.8, integrator)
samples_ahmc1, stats_ahmc1 = sample(
    hamiltonian,
    kernel,
    init_params,
    ndraws + nadapts,
    adaptor,
    nadapts;
    drop_warmup=true,
    progress=false,
)
([[-0.3068506352622478, 0.5322081486442665, -0.7532022976814177, -0.5371782184220575, 0.6754121986394384], [-0.27641230910373066, 0.3130861232274694, -0.4896111827051109, -0.42530906903891397, 0.7240115127714151], [-0.3256001180900675, 0.32263484785906704, 0.2101724805473446, 0.8181087639307709, -0.42034109890090826], [-0.3020140478609222, 0.3323583550646776, -2.9549532283048183, 0.48834787842368355, 0.9280533700194684], [-0.3784297203886223, 0.523913833075221, -2.470365128854885, 0.3896401991241877, 0.7062288239180603], [-0.41262106195053017, 0.3920773532782258, -2.5044371132060927, 0.40763282871102763, 0.7481499970908728], [-0.27665921409848393, 0.4651464810257185, -2.5221565781856543, 0.38723108305971654, 0.7537613718363787], [-0.30743030201885135, 0.10005747976364122, -1.6451356351887094, 0.8051995033328685, 0.39437635807521076], [-0.3269834398209993, 0.13333742262529277, 1.3155786242907155, 0.42529998250089485, -0.4109970922562559], [-0.34986589508839655, 0.1251337785931998, -0.4853502775580961, 0.11402825003942577, 0.4323860671888641]  …  [-0.35248272486446053, 0.3608560977345118, -0.05675436622138258, 0.3917729424847587, -0.0580476732718008], [-0.39240339589098133, 0.21919881453122203, -0.16794814839497138, 0.47959386645331475, 0.00813684343328036], [-0.3493821317485589, 0.17362547925922978, -0.38557986309293674, -0.3195743782309389, 0.6375111791162523], [-0.3403342612887765, 0.13474630171254917, 0.15169193507715764, -0.9601938042010439, 0.7736157509097352], [-0.28730348533411404, 0.3356382186384734, 0.16058935937206895, -0.8741210134985228, 0.8622485455470144], [-0.27130717876538146, 0.2971447656237911, 2.3898699706489337, 0.44342338251001373, -0.7900875677213332], [-0.37301238066851017, 0.4402082770246576, 2.336948323681262, 0.43693904760225094, -0.8968915840551177], [-0.3343009540981135, 0.028201800244372376, -1.6138476002228421, 0.3524143101339522, 0.6963871783269217], [-0.41056180874132786, 0.31127501117405376, 1.6782082346573655, -2.395952937892904, 1.2927965188215536], [-0.3297735855319491, 0.2929655409523523, 2.263949653283074, -0.6920579093513504, -0.0696780825450929]], NamedTuple[(n_steps = 7, is_accept = true, acceptance_rate = 0.3895514871279057, log_density = -116.0517247437837, hamiltonian_energy = 120.02125666336381, hamiltonian_energy_error = 0.7846732688702502, max_hamiltonian_energy_error = 1.3555322812828479, tree_depth = 3, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.9726033932073755, log_density = -113.55481622273697, hamiltonian_energy = 117.56884045058736, hamiltonian_energy_error = -0.17825927384022577, max_hamiltonian_energy_error = -0.37239896819599494, tree_depth = 3, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 127, is_accept = true, acceptance_rate = 0.9698676250030321, log_density = -113.1648250762182, hamiltonian_energy = 116.75406592461636, hamiltonian_energy_error = -0.11301122113255246, max_hamiltonian_energy_error = -0.24921632828164775, tree_depth = 7, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 63, is_accept = true, acceptance_rate = 0.9865355861806328, log_density = -117.81043908459132, hamiltonian_energy = 118.5926925237228, hamiltonian_energy_error = 0.053547153277378357, max_hamiltonian_energy_error = -0.1585473539786051, tree_depth = 6, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 31, is_accept = true, acceptance_rate = 0.9864043470424361, log_density = -117.6717849325681, hamiltonian_energy = 122.48049023284166, hamiltonian_energy_error = -0.15892320992777798, max_hamiltonian_energy_error = -0.23010201345755377, tree_depth = 4, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 15, is_accept = true, acceptance_rate = 0.8354683365849419, log_density = -116.64592140408979, hamiltonian_energy = 119.46870507012868, hamiltonian_energy_error = -0.037987371922255875, max_hamiltonian_energy_error = 0.38986391176064217, tree_depth = 4, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.9599818770048574, log_density = -117.254383685135, hamiltonian_energy = 118.58125972094327, hamiltonian_energy_error = 0.01720060606733398, max_hamiltonian_energy_error = 0.09251743913600308, tree_depth = 2, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 127, is_accept = true, acceptance_rate = 0.6262024310601311, log_density = -114.89822455397274, hamiltonian_energy = 121.76016648897311, hamiltonian_energy_error = 0.007367346998890412, max_hamiltonian_energy_error = 1.428884973429021, tree_depth = 6, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 127, is_accept = true, acceptance_rate = 0.8061711501686325, log_density = -113.55281364740117, hamiltonian_energy = 116.56198557462085, hamiltonian_energy_error = -0.13144501355185412, max_hamiltonian_energy_error = 0.6953271489454664, tree_depth = 6, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 63, is_accept = true, acceptance_rate = 1.0, log_density = -112.70153482183467, hamiltonian_energy = 114.98645058694045, hamiltonian_energy_error = -0.03406364614524193, max_hamiltonian_energy_error = -0.05614018533800902, tree_depth = 5, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false)  …  (n_steps = 7, is_accept = true, acceptance_rate = 0.9580894620865293, log_density = -112.78132165266523, hamiltonian_energy = 116.33133228436051, hamiltonian_energy_error = -0.14838054257278088, max_hamiltonian_energy_error = 0.3367751765243838, tree_depth = 3, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 31, is_accept = true, acceptance_rate = 0.9753713521181395, log_density = -112.4313320421759, hamiltonian_energy = 114.31336018481069, hamiltonian_energy_error = -0.08622794111860799, max_hamiltonian_energy_error = -0.1170051366165552, tree_depth = 4, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 63, is_accept = true, acceptance_rate = 0.992413355546989, log_density = -112.55945386358995, hamiltonian_energy = 113.22495341529877, hamiltonian_energy_error = -0.008834180518988433, max_hamiltonian_energy_error = 0.040926949805026425, tree_depth = 6, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 63, is_accept = true, acceptance_rate = 0.29254001620055325, log_density = -119.38029764269409, hamiltonian_energy = 121.57774447662167, hamiltonian_energy_error = 2.8208791187473707, max_hamiltonian_energy_error = 3.6886890322323467, tree_depth = 5, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 9, is_accept = true, acceptance_rate = 1.0, log_density = -116.38810080008109, hamiltonian_energy = 118.88653314075466, hamiltonian_energy_error = -1.328980014786822, max_hamiltonian_energy_error = -2.754275018114342, tree_depth = 3, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 63, is_accept = true, acceptance_rate = 0.6490807250529794, log_density = -116.78720274841291, hamiltonian_energy = 123.15789339274829, hamiltonian_energy_error = -0.8248884129541381, max_hamiltonian_energy_error = 2.3702253255562056, tree_depth = 6, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 15, is_accept = true, acceptance_rate = 0.9214150918420267, log_density = -116.36562312606004, hamiltonian_energy = 118.2583632936941, hamiltonian_energy_error = -0.44515131569666266, max_hamiltonian_energy_error = -0.4464315016177949, tree_depth = 4, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 63, is_accept = true, acceptance_rate = 0.9069416103791818, log_density = -114.92849190006486, hamiltonian_energy = 118.59615462989807, hamiltonian_energy_error = 0.029843944631338104, max_hamiltonian_energy_error = 0.1828673428942551, tree_depth = 6, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 63, is_accept = true, acceptance_rate = 0.965020984311108, log_density = -117.72251634912949, hamiltonian_energy = 120.8750792142703, hamiltonian_energy_error = 0.0018541480891656192, max_hamiltonian_energy_error = 0.09410990453440604, tree_depth = 6, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false), (n_steps = 63, is_accept = true, acceptance_rate = 0.991985272314974, log_density = -115.15200285364986, hamiltonian_energy = 119.88378732214362, hamiltonian_energy_error = 0.008875015174353962, max_hamiltonian_energy_error = -0.04553752159038993, tree_depth = 6, numerical_error = false, step_size = 0.039195148610453784, nom_step_size = 0.039195148610453784, is_adapt = false)])

Initializing metric adaptation from Pathfinder's estimate

We can't start with Pathfinder's inverse metric estimate directly. Instead we need to first extract its diagonal for a DiagonalEuclideanMetric or make it dense for a DenseEuclideanMetric:

metric = DenseEuclideanMetric(Matrix(inv_metric))
hamiltonian = Hamiltonian(metric, ∇P)
ϵ = find_good_stepsize(hamiltonian, init_params)
integrator = Leapfrog(ϵ)
kernel = HMCKernel(Trajectory{MultinomialTS}(integrator, GeneralisedNoUTurn()))
adaptor = StepSizeAdaptor(0.8, integrator)
samples_ahmc2, stats_ahmc2 = sample(
    hamiltonian,
    kernel,
    init_params,
    ndraws + nadapts,
    adaptor,
    nadapts;
    drop_warmup=true,
    progress=false,
)
([[-0.33288623392204164, 0.26207136723939045, -0.6534510862614651, 0.9657796397492985, -0.18927932841905887], [-0.45283911597009996, 0.21022001863576947, -0.0812560188001536, 0.038319271855512205, 0.3060199501937827], [-0.2952972684446198, 0.508668741192217, -0.20342749702610807, 0.2483803022038653, 0.058259290126392055], [-0.3868332421488647, 0.16857025360193184, -0.3162729306034868, 1.0673726560989807, -0.2874729394192419], [-0.5104896384077988, 0.05406078671483465, -0.07698411483939224, 0.29328922887212616, 0.2380811696172881], [-0.4573294665180908, 0.04825894102396453, 0.011734881382429577, -0.21790132701947795, 0.539132050264021], [-0.3705564221054496, 0.09164906872971026, 0.7475627092921187, -0.13031871314738497, 0.1738737752629186], [-0.45724383410989994, 0.01311960057015163, 0.45739369767649474, 1.3533852481122564, -0.7097790475871915], [-0.24924729463190298, 0.30149454569050127, 0.6292342088121841, 0.1873309153190299, -0.1880080514941571], [-0.27138595843643404, 0.4019102000100871, 0.6224021954896704, -0.040136610368389, -0.03227517123816842]  …  [-0.345085191496607, 0.27373426986214444, -0.38658174908345266, 0.016991153275516035, 0.36815000631414463], [-0.17121243866694089, 0.21784121959232827, 1.4315380260274395, -1.5546096563748522, 0.8234117379952991], [-0.22292673981245795, 0.12512942724381632, 1.620218181989284, -2.4619437958296695, 1.4769398136722764], [-0.44969485808464726, 0.07211683593133128, 0.044250123352429685, 1.586562158108304, -0.7479634834045598], [-0.23737624103413976, 0.43959378494199514, 0.501926939371316, -1.334641779700463, 0.9369274529064184], [-0.4397764154136172, 0.09478485768566672, 0.1386506140754594, 1.6035595586063327, -0.798790051217262], [-0.31642462307081604, 0.3378092269738986, 0.49685489727569937, -0.5939322302529039, 0.4726499672995809], [-0.3888164888113257, 0.3544130084948931, 0.6092953224833887, -1.3275809706071384, 0.9426004811002201], [-0.3296585768523262, 0.0165429008627188, 0.030028585533679097, -0.948980955515367, 1.0294245941325992], [-0.32701832381897283, 0.12765700186107348, -0.2455332410018446, 0.5421086905577019, 0.10714452138181207]], NamedTuple[(n_steps = 3, is_accept = true, acceptance_rate = 0.8984895786997941, log_density = -113.01814929351904, hamiltonian_energy = 113.84234973673945, hamiltonian_energy_error = 0.07154435186996011, max_hamiltonian_energy_error = 0.1383370779933557, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 15, is_accept = true, acceptance_rate = 0.8911677408779668, log_density = -113.31206676920543, hamiltonian_energy = 114.63618853362446, hamiltonian_energy_error = 0.0619872075288157, max_hamiltonian_energy_error = 0.34252636184221785, tree_depth = 3, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.3963628131741854, log_density = -114.11164752188671, hamiltonian_energy = 116.91690936484628, hamiltonian_energy_error = 0.5369083522205642, max_hamiltonian_energy_error = 1.5060406253430756, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.8906633655219501, log_density = -113.01857847122575, hamiltonian_energy = 115.84020452431824, hamiltonian_energy_error = -0.46741219249844335, max_hamiltonian_energy_error = -0.46741219249844335, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.5924185563221885, log_density = -116.95162460299547, hamiltonian_energy = 117.83956784746947, hamiltonian_energy_error = 1.3925433811465382, max_hamiltonian_energy_error = 1.3925433811465382, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 1.0, log_density = -114.96194903068222, hamiltonian_energy = 117.13726359961565, hamiltonian_energy_error = -0.8411152570123761, max_hamiltonian_energy_error = -1.0392641577431476, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 31, is_accept = true, acceptance_rate = 0.9989936083034753, log_density = -113.08818904551971, hamiltonian_energy = 115.9938832183638, hamiltonian_energy_error = -0.6867764527412561, max_hamiltonian_energy_error = -0.7329301823407093, tree_depth = 4, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.5063542620130855, log_density = -117.00591268672797, hamiltonian_energy = 117.64538990127107, hamiltonian_energy_error = 1.2875852466245448, max_hamiltonian_energy_error = 1.2875852466245448, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.58117329313274, log_density = -115.77557253753953, hamiltonian_energy = 121.39345659807253, hamiltonian_energy_error = -0.020056771798181217, max_hamiltonian_energy_error = 1.0864015632546682, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 1.0, log_density = -113.99252883798289, hamiltonian_energy = 116.20409958437007, hamiltonian_energy_error = -0.3165253687309786, max_hamiltonian_energy_error = -0.6197080058185378, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false)  …  (n_steps = 3, is_accept = true, acceptance_rate = 0.9891789334419173, log_density = -112.23499028204157, hamiltonian_energy = 113.45923358078169, hamiltonian_energy_error = -0.28416936364075696, max_hamiltonian_energy_error = -0.28416936364075696, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 19, is_accept = true, acceptance_rate = 0.5244907642783726, log_density = -117.67660468241364, hamiltonian_energy = 119.0570815284279, hamiltonian_energy_error = 1.2377997924852622, max_hamiltonian_energy_error = 1.3199820688299724, tree_depth = 4, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.8658823275850797, log_density = -119.75280020926164, hamiltonian_energy = 121.81668397797621, hamiltonian_energy_error = 0.5147550291855083, max_hamiltonian_energy_error = -0.6478379472471119, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 31, is_accept = true, acceptance_rate = 0.9964806502512369, log_density = -116.03456300412219, hamiltonian_energy = 124.16112797830004, hamiltonian_energy_error = -0.8187539827663812, max_hamiltonian_energy_error = -1.2243300303136522, tree_depth = 4, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 1.0, log_density = -115.89384437285813, hamiltonian_energy = 116.40109831413854, hamiltonian_energy_error = -0.15042390342615874, max_hamiltonian_energy_error = -0.8689202664088782, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.9870371423308543, log_density = -115.56696129292251, hamiltonian_energy = 117.35202832902921, hamiltonian_energy_error = -0.19531126407230204, max_hamiltonian_energy_error = -0.7762097947086346, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 1.0, log_density = -112.86123253869154, hamiltonian_energy = 115.08191854776007, hamiltonian_energy_error = -0.6994129700420899, max_hamiltonian_energy_error = -0.868298619642303, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.8291129452391007, log_density = -114.61533990462075, hamiltonian_energy = 115.08257258531684, hamiltonian_energy_error = 0.479651337724718, max_hamiltonian_energy_error = 0.479651337724718, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 27, is_accept = true, acceptance_rate = 0.8342682616345867, log_density = -114.51224402920333, hamiltonian_energy = 118.28263048980047, hamiltonian_energy_error = 0.1174486315127723, max_hamiltonian_energy_error = 0.5212795416287719, tree_depth = 4, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 1.0, log_density = -113.52688158683762, hamiltonian_energy = 115.54328910203913, hamiltonian_energy_error = -0.25289864974952536, max_hamiltonian_energy_error = -0.25289864974952536, tree_depth = 2, numerical_error = false, step_size = 1.0208205832841977, nom_step_size = 1.0208205832841977, is_adapt = false)])

Use Pathfinder's metric estimate for sampling

To use Pathfinder's metric with no metric adaptation, we need to use Pathfinder's own RankUpdateEuclideanMetric type, which just wraps our inverse metric estimate for use with AdvancedHMC:

nadapts = 75
metric = Pathfinder.RankUpdateEuclideanMetric(inv_metric)
hamiltonian = Hamiltonian(metric, ∇P)
ϵ = find_good_stepsize(hamiltonian, init_params)
integrator = Leapfrog(ϵ)
kernel = HMCKernel(Trajectory{MultinomialTS}(integrator, GeneralisedNoUTurn()))
adaptor = StepSizeAdaptor(0.8, integrator)
samples_ahmc3, stats_ahmc3 = sample(
    hamiltonian,
    kernel,
    init_params,
    ndraws + nadapts,
    adaptor,
    nadapts;
    drop_warmup=true,
    progress=false,
)
([[-0.2898888657507224, 0.10314730266620688, 1.3248065913278861, -0.20908169019086298, -0.004976315539089782], [-0.3862246612199871, 0.28331316950186464, 1.4160509131301673, -0.8426613024047709, 0.35857687882858624], [-0.36420835426785353, 0.18912231053174483, 1.678374686821354, -2.1867234322823608, 1.2610296040904823], [-0.39337943346924736, 0.2051563320492994, 0.9180429312191216, -0.9287054557688026, 0.666241798963476], [-0.3308560902853441, 0.2893043954528126, 0.9193525430058921, 0.6098784079648223, -0.5271827251606933], [-0.3303712387242465, 0.31249391930574383, 1.4241856060330889, -1.3499634201061357, 0.7021029633943583], [-0.38330086349443054, 0.05400791863456017, 1.0106405268218177, -1.1288639825524251, 0.7651532482289487], [-0.37908859043775467, 0.12323669456190013, 0.8058821882419007, -0.049010351271636, 0.0816627500062288], [-0.3194668367688959, 0.42612340616672095, 0.5082245983937876, -0.1488569950212918, 0.1169752464613521], [-0.3361846018716687, 0.38049115646030607, 0.612411142047273, -1.4749325300486895, 0.9333656295571855]  …  [-0.3521163256810297, 0.10965137670256718, 1.0805190751472742, 1.3398206161648178, -0.9332259485946219], [-0.35123295513190106, 0.11808657410711586, -0.6793939692502993, 1.5445191200913087, -0.4391266667968314], [-0.3193844921864334, -0.028248899677803543, -0.19682600602764483, -0.5493054306002771, 0.8683875238220913], [-0.29887319365386905, 0.16370916033375693, -0.42469712942770294, 0.577457035317549, 0.09052856519455843], [-0.27316303440681966, 0.2960815482119393, -0.3109016246244381, -0.1819853243280264, 0.46042354281521597], [-0.28614117852561055, 0.21323032741846748, -0.49812372640631775, 0.6646737955721919, -0.03365933955549866], [-0.4281789160226034, 0.2445309824655545, 0.2251298963526093, -0.7874179910278235, 0.751841340448584], [-0.38590735103293655, 0.21036017000560667, 0.9648545067997216, 1.1634399156651578, -0.802748986483839], [-0.27831050553447484, 0.27416374970335067, 1.3159521336904743, -0.41646408970481286, 0.1084862474787478], [-0.3635782151368845, 0.1501806164125848, 1.0413661806569738, 1.0132377403597774, -0.7111436135146191]], NamedTuple[(n_steps = 23, is_accept = true, acceptance_rate = 0.905528625054863, log_density = -114.37483081600051, hamiltonian_energy = 119.44430046272612, hamiltonian_energy_error = -0.08113111127016737, max_hamiltonian_energy_error = 0.2624094218423778, tree_depth = 4, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.8207150617100091, log_density = -113.70050524355518, hamiltonian_energy = 116.9128971949453, hamiltonian_energy_error = -0.2740461282223521, max_hamiltonian_energy_error = 0.32888017381621637, tree_depth = 2, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.588289289023059, log_density = -117.94141861217521, hamiltonian_energy = 118.89453246490065, hamiltonian_energy_error = 0.8604922395476109, max_hamiltonian_energy_error = 0.8604922395476109, tree_depth = 2, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 15, is_accept = true, acceptance_rate = 0.9998077599444452, log_density = -114.5538063605045, hamiltonian_energy = 118.83734976344327, hamiltonian_energy_error = -0.5288645849028057, max_hamiltonian_energy_error = -0.8247097993442054, tree_depth = 3, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 23, is_accept = true, acceptance_rate = 0.999705159255928, log_density = -114.1448741753568, hamiltonian_energy = 116.6373712817102, hamiltonian_energy_error = -0.16860415758094405, max_hamiltonian_energy_error = -0.3128835415306668, tree_depth = 4, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.6330199433887019, log_density = -114.78798313834625, hamiltonian_energy = 119.31467218300399, hamiltonian_energy_error = 0.10957199327971523, max_hamiltonian_energy_error = 0.8307509306341103, tree_depth = 2, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 19, is_accept = true, acceptance_rate = 0.8613254693197934, log_density = -114.73293086569223, hamiltonian_energy = 118.09806463185865, hamiltonian_energy_error = -0.05480224791136834, max_hamiltonian_energy_error = 0.4315934842910565, tree_depth = 4, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 1.0, log_density = -112.95172187508753, hamiltonian_energy = 114.81675612719575, hamiltonian_energy_error = -0.36665134209961536, max_hamiltonian_energy_error = -0.36665134209961536, tree_depth = 2, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 27, is_accept = true, acceptance_rate = 0.9338322586240629, log_density = -113.11496850942025, hamiltonian_energy = 114.65688813705016, hamiltonian_energy_error = 0.05899701954112402, max_hamiltonian_energy_error = 0.1499921682477776, tree_depth = 4, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 15, is_accept = true, acceptance_rate = 0.7996282308009586, log_density = -115.04340012250678, hamiltonian_energy = 117.10483719535718, hamiltonian_energy_error = 0.3826072768386979, max_hamiltonian_energy_error = 0.534710655786995, tree_depth = 3, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false)  …  (n_steps = 3, is_accept = true, acceptance_rate = 0.9852150604757743, log_density = -114.57574936738364, hamiltonian_energy = 116.92774193446132, hamiltonian_energy_error = -0.20687780288304225, max_hamiltonian_energy_error = -0.40011215037995385, tree_depth = 2, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 43, is_accept = true, acceptance_rate = 0.9627234219539237, log_density = -114.22893060836698, hamiltonian_energy = 116.12182603537552, hamiltonian_energy_error = 0.07712544283262446, max_hamiltonian_energy_error = -0.1765562763438311, tree_depth = 5, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.7285565083522246, log_density = -114.76362006048757, hamiltonian_energy = 118.25548073447554, hamiltonian_energy_error = 0.08025476258768549, max_hamiltonian_energy_error = 0.5771002817754152, tree_depth = 2, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.9499051518857865, log_density = -112.85165128645536, hamiltonian_energy = 115.67044900755792, hamiltonian_energy_error = -0.3183659386119615, max_hamiltonian_energy_error = -0.3183659386119615, tree_depth = 2, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.8951572237130281, log_density = -112.91190927393335, hamiltonian_energy = 114.05284867164306, hamiltonian_energy_error = 0.026733192010752305, max_hamiltonian_energy_error = 0.17944284613568584, tree_depth = 2, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.9362991777973377, log_density = -113.39326068922867, hamiltonian_energy = 114.04364271486521, hamiltonian_energy_error = 0.07763467975314597, max_hamiltonian_energy_error = 0.1237563112019302, tree_depth = 2, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 31, is_accept = true, acceptance_rate = 0.9714350881277357, log_density = -113.57311963811844, hamiltonian_energy = 114.62592673668057, hamiltonian_energy_error = 0.06396019602671288, max_hamiltonian_energy_error = 0.10969782393198102, tree_depth = 4, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 39, is_accept = true, acceptance_rate = 0.9558557406892157, log_density = -113.6697773524378, hamiltonian_energy = 115.56777617850331, hamiltonian_energy_error = -0.10642911210383943, max_hamiltonian_energy_error = 0.15101570730290348, tree_depth = 5, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.9191549238077265, log_density = -113.57705397061044, hamiltonian_energy = 114.9938720126423, hamiltonian_energy_error = -0.016386900340975785, max_hamiltonian_energy_error = 0.18766432139669575, tree_depth = 2, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.8221652759053301, log_density = -113.6374534232258, hamiltonian_energy = 115.87357912103522, hamiltonian_energy_error = -0.03703637773662649, max_hamiltonian_energy_error = 0.5138911528011505, tree_depth = 1, numerical_error = false, step_size = 0.8787939884057987, nom_step_size = 0.8787939884057987, is_adapt = false)])
  • 1https://mc-stan.org/docs/reference-manual/hmc-algorithm-parameters.html