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: 17 (total: 18)
  fit ELBO: -117.48 ± 0.26
  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.3519374273204352, 0.24690059981721146, 0.05827588220627803, 0.11655176441277385, 0.17482764661876085]
Σ: [0.0049591224099863095 -3.311398423331392e-5 … -0.00010842041610912824 8.502868810829432e-5; -3.311398423331392e-5 0.018881672968748812 … -0.003976761689243613 -0.006062662647727625; … ; -0.00010842041610912824 -0.003976761689243613 … 0.7170576790755043 -0.427267718387669; 8.502868810829432e-5 -0.006062662647727625 … -0.427267718387669 0.2601283251145933]
)
init_params = result_pf.draws[:, 1]
5-element Vector{Float64}:
 -0.2224935031067182
  0.46141802142532895
 -0.27508471907321225
  1.1420276998152994
 -0.5639123902280768
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.00495912  -3.3114e-5   -4.65522e-6  -0.00010842   8.50287e-5
 -3.3114e-5    0.0188817   -0.0020078   -0.00397676  -0.00606266
 -4.65522e-6  -0.0020078    0.0336821   -0.144189     0.0862468
 -0.00010842  -0.00397676  -0.144189     0.717058    -0.427268
  8.50287e-5  -0.00606266   0.0862468   -0.427268     0.260128

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.3412405459909631 -0.4170851197347787 … -0.46041371698459743 -0.4011603493166512; 0.3045707128956131 0.36467453355341306 … 0.27952068416732595 0.2597608612778835; … ; -0.35806509302276385 -0.20611394131828942 … 1.07417718022727 1.016601764789458; 0.5394336857197687 0.5075169542357757 … 0.0009875550506012881 -0.01788564159116815], tree_statistics = DynamicHMC.TreeStatisticsNUTS[DynamicHMC.TreeStatisticsNUTS(-114.14525485484648, 4, turning at positions -16:-19, 0.9862205522569161, 27, DynamicHMC.Directions(0x032d8048)), DynamicHMC.TreeStatisticsNUTS(-113.98301761792177, 5, turning at positions -29:2, 0.9902777158948429, 31, DynamicHMC.Directions(0x507be662)), DynamicHMC.TreeStatisticsNUTS(-114.9064794028293, 6, turning at positions 18:81, 0.9408375430433219, 127, DynamicHMC.Directions(0xb54ba851)), DynamicHMC.TreeStatisticsNUTS(-115.3701379324056, 6, turning at positions -23:40, 0.9366001318045118, 63, DynamicHMC.Directions(0x3af727e8)), DynamicHMC.TreeStatisticsNUTS(-116.47766910004954, 6, turning at positions -35:28, 0.9987757268875384, 63, DynamicHMC.Directions(0x1ef96a9c)), DynamicHMC.TreeStatisticsNUTS(-120.00663262510562, 6, turning at positions -8:55, 0.8214885731987472, 63, DynamicHMC.Directions(0xf3f0c2b7)), DynamicHMC.TreeStatisticsNUTS(-118.78528855026464, 6, turning at positions -12:51, 0.9958768965872059, 63, DynamicHMC.Directions(0xc7c37e33)), DynamicHMC.TreeStatisticsNUTS(-120.3946461338778, 6, turning at positions -10:53, 0.9616190649524977, 63, DynamicHMC.Directions(0xf575db75)), DynamicHMC.TreeStatisticsNUTS(-120.62246024896044, 7, turning at positions -59:68, 0.8876876877314692, 127, DynamicHMC.Directions(0x7ddeb744)), DynamicHMC.TreeStatisticsNUTS(-120.15340931713118, 6, turning at positions -30:33, 0.993592252282268, 63, DynamicHMC.Directions(0x19444161))  …  DynamicHMC.TreeStatisticsNUTS(-116.37213543775337, 6, turning at positions 23:86, 0.9872096116370161, 127, DynamicHMC.Directions(0x0d9fa3d6)), DynamicHMC.TreeStatisticsNUTS(-116.38780902668951, 6, turning at positions -33:-96, 0.9389447184220459, 127, DynamicHMC.Directions(0xf5a7e51f)), DynamicHMC.TreeStatisticsNUTS(-116.826727700531, 5, turning at positions -5:-8, 0.925867203764391, 39, DynamicHMC.Directions(0xef142b9f)), DynamicHMC.TreeStatisticsNUTS(-115.27750954459073, 5, turning at positions 4:35, 0.9997076891004354, 63, DynamicHMC.Directions(0xaf2c0a23)), DynamicHMC.TreeStatisticsNUTS(-114.29236957854708, 5, turning at positions 20:51, 0.9999990706338214, 63, DynamicHMC.Directions(0x96460573)), DynamicHMC.TreeStatisticsNUTS(-115.51443346002517, 6, turning at positions -4:59, 0.9752253373512486, 63, DynamicHMC.Directions(0x1a916bfb)), DynamicHMC.TreeStatisticsNUTS(-116.32457686707203, 6, turning at positions 26:89, 0.9843814603584213, 127, DynamicHMC.Directions(0x14ae2ad9)), DynamicHMC.TreeStatisticsNUTS(-116.29531740983084, 6, turning at positions -7:56, 0.8137934186971354, 63, DynamicHMC.Directions(0x32ed6978)), DynamicHMC.TreeStatisticsNUTS(-117.93208810050099, 6, turning at positions 6:69, 0.9903359426498987, 127, DynamicHMC.Directions(0x0778b045)), DynamicHMC.TreeStatisticsNUTS(-116.44924878001504, 5, turning at positions -20:11, 0.9941095761857561, 31, DynamicHMC.Directions(0xa9d9c6ab))], κ = Gaussian kinetic energy (Diagonal), √diag(M⁻¹): [0.08869613477055453, 0.15331203647369712, 0.9256337201223703, 0.6942164457062617, 0.506147220916694], ϵ = 0.048324753132567275)

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.1464167434183906 -0.23740723925620355 … -0.3351353518429406 -0.28704156943900294; -0.08067001815646768 0.08500685843703569 … 0.3732852604726868 0.3841596608668608; … ; 0.0324889529666727 -0.2523908457162586 … -0.21915116107353083 -0.5653718644348034; 0.3417969177362027 0.502065444031663 … 0.3880851429871406 0.8600960067612551], tree_statistics = DynamicHMC.TreeStatisticsNUTS[DynamicHMC.TreeStatisticsNUTS(-119.64891443426312, 3, turning at positions -4:3, 0.9380712947483321, 7, DynamicHMC.Directions(0xa0fead5b)), DynamicHMC.TreeStatisticsNUTS(-118.222837343832, 2, turning at positions -1:2, 0.9999999999999999, 3, DynamicHMC.Directions(0x74ddaf76)), DynamicHMC.TreeStatisticsNUTS(-115.55937643627719, 2, turning at positions -4:-7, 0.9814516140813867, 7, DynamicHMC.Directions(0x5c61dab0)), DynamicHMC.TreeStatisticsNUTS(-116.04988034983377, 3, turning at positions -7:0, 0.9262471037059253, 7, DynamicHMC.Directions(0x043eb2e0)), DynamicHMC.TreeStatisticsNUTS(-116.56449955185056, 2, turning at positions 4:7, 0.987139370253514, 7, DynamicHMC.Directions(0xcdcf9a57)), DynamicHMC.TreeStatisticsNUTS(-113.67757497115986, 2, turning at positions 3:6, 0.9122202444847967, 7, DynamicHMC.Directions(0xf039004e)), DynamicHMC.TreeStatisticsNUTS(-113.19273005736329, 2, turning at positions 4:7, 0.9636691847201068, 7, DynamicHMC.Directions(0x66cc4c9f)), DynamicHMC.TreeStatisticsNUTS(-115.9008642457226, 2, turning at positions -4:-7, 0.9424516316594742, 7, DynamicHMC.Directions(0x172fca18)), DynamicHMC.TreeStatisticsNUTS(-116.38183534681743, 3, turning at positions -1:6, 0.9779182160926867, 7, DynamicHMC.Directions(0x2ff0f6de)), DynamicHMC.TreeStatisticsNUTS(-116.28412900273405, 3, turning at positions -6:1, 0.9973269906037345, 7, DynamicHMC.Directions(0x20f66c51))  …  DynamicHMC.TreeStatisticsNUTS(-116.98332250594667, 2, turning at positions -3:0, 0.8602700801701157, 3, DynamicHMC.Directions(0x9a108760)), DynamicHMC.TreeStatisticsNUTS(-117.98628134893605, 3, turning at positions -3:4, 0.8146138177453305, 7, DynamicHMC.Directions(0x5c3f1344)), DynamicHMC.TreeStatisticsNUTS(-116.74470277885952, 3, turning at positions -2:5, 0.9906430061807275, 7, DynamicHMC.Directions(0xf72ee0b5)), DynamicHMC.TreeStatisticsNUTS(-116.05924173657883, 4, turning at positions 0:15, 0.9309646748791001, 15, DynamicHMC.Directions(0x07bcc6bf)), DynamicHMC.TreeStatisticsNUTS(-116.29740465846075, 3, turning at positions 0:7, 0.9593313129489935, 7, DynamicHMC.Directions(0xeb13203f)), DynamicHMC.TreeStatisticsNUTS(-116.9043299886622, 4, turning at positions -12:3, 0.8133203451142353, 15, DynamicHMC.Directions(0xd878bab3)), DynamicHMC.TreeStatisticsNUTS(-118.13878193113096, 3, turning at positions -4:3, 0.8477175939039514, 7, DynamicHMC.Directions(0xa6df8483)), DynamicHMC.TreeStatisticsNUTS(-119.70512907888455, 3, turning at positions -6:1, 0.8658549122207525, 7, DynamicHMC.Directions(0x8c2d9b91)), DynamicHMC.TreeStatisticsNUTS(-115.744066906302, 3, turning at positions -5:2, 0.9959352832772886, 7, DynamicHMC.Directions(0xb87c34f2)), DynamicHMC.TreeStatisticsNUTS(-119.23912758175422, 2, turning at positions 2:5, 0.8224669082102981, 7, DynamicHMC.Directions(0xe855fe75))], κ = Gaussian kinetic energy (Symmetric), √diag(M⁻¹): [0.09575203714009892, 0.1520647913847786, 0.927698905842215, 0.8287654393030375, 0.6092104837297332], ϵ = 0.3721212012523526)

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.3733623148804505 -0.3088164337303296 … -0.3490030876902151 -0.3511791351769841; 0.4816048837578013 0.40065880794985653 … 0.2173310752238738 0.3100568316702414; … ; -0.9434305466904477 0.8835683383294203 … 0.1403091361619621 -0.2572552738074885; 0.02467482906953959 -1.051802368053576 … -0.07808417493458011 0.10100719485582432], tree_statistics = DynamicHMC.TreeStatisticsNUTS[DynamicHMC.TreeStatisticsNUTS(-120.72090525592459, 5, turning at positions 30:37, 0.9933204519447291, 55, DynamicHMC.Directions(0x15ddb56d)), DynamicHMC.TreeStatisticsNUTS(-120.73841887409964, 2, turning at positions -4:-7, 0.7856742633950509, 7, DynamicHMC.Directions(0x8524aea8)), DynamicHMC.TreeStatisticsNUTS(-117.21279402483178, 2, turning at positions -3:-6, 0.9399668540837695, 7, DynamicHMC.Directions(0xebffa421)), DynamicHMC.TreeStatisticsNUTS(-115.4870889249574, 2, turning at positions -3:0, 0.924567209878597, 3, DynamicHMC.Directions(0x6ff453b8)), DynamicHMC.TreeStatisticsNUTS(-123.39669084149129, 2, turning at positions -2:-5, 0.6402710154549979, 7, DynamicHMC.Directions(0xa0d091a2)), DynamicHMC.TreeStatisticsNUTS(-122.85270572431705, 3, turning at positions -5:2, 0.9472753268262505, 7, DynamicHMC.Directions(0xa0f3035a)), DynamicHMC.TreeStatisticsNUTS(-120.2420390306208, 3, turning at positions -3:4, 0.9999999999999999, 7, DynamicHMC.Directions(0x073a432c)), DynamicHMC.TreeStatisticsNUTS(-119.21783535088174, 3, turning at positions -6:1, 0.9978432450862196, 7, DynamicHMC.Directions(0xf4daeb19)), DynamicHMC.TreeStatisticsNUTS(-121.08066383387015, 3, turning at positions -2:5, 0.9147077117928849, 7, DynamicHMC.Directions(0x661fbe9d)), DynamicHMC.TreeStatisticsNUTS(-117.51130415622677, 3, turning at positions -4:3, 0.9999999999999999, 7, DynamicHMC.Directions(0x0333dbfb))  …  DynamicHMC.TreeStatisticsNUTS(-115.89258640288939, 2, turning at positions 0:3, 0.978182998718744, 3, DynamicHMC.Directions(0xbeb91efb)), DynamicHMC.TreeStatisticsNUTS(-116.95523460669148, 4, turning at positions -17:-24, 0.932309888430465, 31, DynamicHMC.Directions(0xb4369587)), DynamicHMC.TreeStatisticsNUTS(-117.66347417099315, 3, turning at positions -3:4, 0.7904817683408186, 7, DynamicHMC.Directions(0xace3ca44)), DynamicHMC.TreeStatisticsNUTS(-116.169814997754, 2, turning at positions -2:1, 0.8701010914934723, 3, DynamicHMC.Directions(0x664b2e35)), DynamicHMC.TreeStatisticsNUTS(-118.871665139584, 2, turning at positions -2:1, 0.9313975313462236, 3, DynamicHMC.Directions(0x4e419c59)), DynamicHMC.TreeStatisticsNUTS(-122.95561593529484, 3, turning at positions 6:13, 0.953714830331071, 15, DynamicHMC.Directions(0x4c5bddfd)), DynamicHMC.TreeStatisticsNUTS(-124.59722585574245, 3, turning at positions -4:3, 0.6607424920989999, 7, DynamicHMC.Directions(0xcdc40f4b)), DynamicHMC.TreeStatisticsNUTS(-119.31675872567227, 5, turning at positions 17:20, 0.9682091290203075, 43, DynamicHMC.Directions(0xfc951028)), DynamicHMC.TreeStatisticsNUTS(-113.31589650941636, 3, turning at positions -2:5, 0.9880403071343108, 7, DynamicHMC.Directions(0x2e798fbd)), DynamicHMC.TreeStatisticsNUTS(-113.67688178649166, 3, turning at positions -2:-9, 0.992606865288171, 15, DynamicHMC.Directions(0xf9c27dd6))], κ = Gaussian kinetic energy (WoodburyPDMat), √diag(M⁻¹): [0.07042103670059328, 0.13741059991408527, 0.1835267592270858, 0.846792583266708, 0.5100277689641941], ϵ = 0.7077940031437842)

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.365596740125783, 0.17059650569800316, 1.7106733614219014, 1.9226687888044092, -1.5793105571462596], [-0.2567731040071911, 0.267162092071601, 2.102592812479207, -0.03350435470066741, -0.33490013820872944], [-0.43009377324013187, 0.24318630747641287, -1.9706991914007892, 0.4525896652309068, 0.5838541773972088], [-0.48069518613521445, 0.13174728770968158, -1.284608862736512, -0.676186172202712, 1.2581093748114065], [-0.2880978603620167, 0.09140046154712576, -1.4050781339771286, -0.616055115710048, 1.252775036600405], [-0.4105966189337662, 0.042488253953525484, -1.5531189912206003, -0.7916538214549118, 1.396327120926058], [-0.2537942959563149, 0.2121270451106063, -1.7133630891120257, -0.8012198032549152, 1.3141851931671786], [-0.23297957239423478, 0.28361290884865953, -0.8222504169111231, -0.116924062730113, 0.6361048498608369], [-0.29466851237770153, 0.2933170361325806, -0.6065737016705158, 0.5835275511005248, 0.03629669056245648], [-0.4138456402760152, 0.13438713708628688, -0.6006194488384454, 0.8407387642807409, -0.0012389372425721107]  …  [-0.27088686061471734, 0.05789447728553368, -0.05578881891851032, 0.8566712240926333, -0.13216913835268657], [-0.2941284508872779, 0.4201992644107405, -0.6470402660562693, 0.4099623389697281, 0.17086495215277775], [-0.22719916891702777, 0.35017856629552996, 0.6636700523914725, 0.3887691191766755, -0.37406898535102784], [-0.3612378546022489, 0.2215456449672544, 0.8169426300363867, 0.3769694102170507, -0.39179618808566863], [-0.40271199176192646, 0.31442398409710703, 0.8415628383325356, 0.42557843188245903, -0.27842804993124076], [-0.20212202918160604, 0.23326939702286098, 0.025583574099054138, 0.12923073903248025, 0.22920330235002767], [-0.3687469942299848, 0.41525479737216914, 0.04127782330858672, -0.10852760124932706, 0.12049000853541937], [-0.3736177024244123, 0.1675616051913491, -0.19959248484852693, 1.5270643984992638, -0.6233122531374252], [-0.4061824559055249, 0.14773653962388797, 0.6441818160511852, 0.19456975247386127, -0.03652492373470852], [-0.4540085467116301, 0.09158263593798986, 0.658241354591661, 0.2940589997704758, -0.02951682986598845]], NamedTuple[(n_steps = 39, is_accept = true, acceptance_rate = 0.9989845571860547, log_density = -117.21997628727328, hamiltonian_energy = 118.4741128892763, hamiltonian_energy_error = -0.031511632073602414, max_hamiltonian_energy_error = -0.2209719714144427, tree_depth = 5, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 127, is_accept = true, acceptance_rate = 0.7057230057766004, log_density = -116.87282385272438, hamiltonian_energy = 123.28430742704134, hamiltonian_energy_error = 0.599077704337418, max_hamiltonian_energy_error = 1.1047343198018211, tree_depth = 6, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 127, is_accept = true, acceptance_rate = 0.9766451534044202, log_density = -115.65254033125211, hamiltonian_energy = 118.58879295082508, hamiltonian_energy_error = -0.5668212333949612, max_hamiltonian_energy_error = -0.9780395004346332, tree_depth = 7, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 63, is_accept = true, acceptance_rate = 0.987879452936739, log_density = -117.14269878419624, hamiltonian_energy = 120.65241096415772, hamiltonian_energy_error = 0.2197558296968225, max_hamiltonian_energy_error = -0.396196238874964, tree_depth = 6, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.9435515946692828, log_density = -115.10644796643132, hamiltonian_energy = 119.32562826402524, hamiltonian_energy_error = -0.4570341956466706, max_hamiltonian_energy_error = -0.5538392866526323, tree_depth = 3, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 47, is_accept = true, acceptance_rate = 0.9200222810743852, log_density = -116.31008167808628, hamiltonian_energy = 122.61482083989141, hamiltonian_energy_error = 0.05374508955716806, max_hamiltonian_energy_error = 0.3035919494219286, tree_depth = 5, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 15, is_accept = true, acceptance_rate = 0.638767027783684, log_density = -117.27714465973006, hamiltonian_energy = 118.62028059875679, hamiltonian_energy_error = 0.763767727747279, max_hamiltonian_energy_error = 0.9252199267461805, tree_depth = 3, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 35, is_accept = true, acceptance_rate = 0.956520470958761, log_density = -114.16866198475039, hamiltonian_energy = 117.72563074979317, hamiltonian_energy_error = -0.4836370328169579, max_hamiltonian_energy_error = -0.9337622409236559, tree_depth = 5, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 127, is_accept = true, acceptance_rate = 0.8916545320464725, log_density = -112.9611921225575, hamiltonian_energy = 115.48634003453132, hamiltonian_energy_error = -0.0957307689057103, max_hamiltonian_energy_error = 0.5445157687399131, tree_depth = 6, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 63, is_accept = true, acceptance_rate = 0.9847561037191847, log_density = -113.68410513078796, hamiltonian_energy = 114.26916118055362, hamiltonian_energy_error = 0.0674622775509306, max_hamiltonian_energy_error = -0.10146463426612229, tree_depth = 6, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false)  …  (n_steps = 31, is_accept = true, acceptance_rate = 0.9882462513384364, log_density = -114.6014860865269, hamiltonian_energy = 116.10141538872219, hamiltonian_energy_error = -0.09068637653221856, max_hamiltonian_energy_error = -0.46061276017796615, tree_depth = 4, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 63, is_accept = true, acceptance_rate = 0.8042143056914448, log_density = -113.89941255023511, hamiltonian_energy = 117.24796632560897, hamiltonian_energy_error = -0.07428818886717181, max_hamiltonian_energy_error = 0.6863531516107031, tree_depth = 5, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 71, is_accept = true, acceptance_rate = 0.5762232184266781, log_density = -117.24004814421869, hamiltonian_energy = 118.88785849762338, hamiltonian_energy_error = 0.9328476617493493, max_hamiltonian_energy_error = 2.3204003828717674, tree_depth = 6, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 15, is_accept = true, acceptance_rate = 0.7001063780151207, log_density = -119.89378492113195, hamiltonian_energy = 121.34309924838409, hamiltonian_energy_error = 1.5525410863216251, max_hamiltonian_energy_error = 1.8470537494762027, tree_depth = 3, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.9413240326694675, log_density = -113.69415723578166, hamiltonian_energy = 118.61728367227171, hamiltonian_energy_error = -3.5126942219948916, max_hamiltonian_energy_error = -3.5126942219948916, tree_depth = 2, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 55, is_accept = true, acceptance_rate = 0.9184814224340566, log_density = -114.60023036378188, hamiltonian_energy = 118.47592921770486, hamiltonian_energy_error = 0.020524682261680027, max_hamiltonian_energy_error = 0.7350231545286903, tree_depth = 5, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.5876020077890851, log_density = -117.97625869446203, hamiltonian_energy = 120.0099429542013, hamiltonian_energy_error = 1.3059739387069413, max_hamiltonian_energy_error = 1.4463357793961222, tree_depth = 3, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 47, is_accept = true, acceptance_rate = 0.9991364627461081, log_density = -113.72849784710539, hamiltonian_energy = 117.53657682011209, hamiltonian_energy_error = -2.2845344209433875, max_hamiltonian_energy_error = -2.4005653694473637, tree_depth = 5, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 47, is_accept = true, acceptance_rate = 0.8651644346138977, log_density = -112.92690956654481, hamiltonian_energy = 117.67599094472962, hamiltonian_energy_error = 0.01755193476179784, max_hamiltonian_energy_error = 0.32386516025353274, tree_depth = 5, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, is_adapt = false), (n_steps = 31, is_accept = true, acceptance_rate = 0.5029308680783446, log_density = -114.70434456938442, hamiltonian_energy = 116.62672368898207, hamiltonian_energy_error = 0.1979985784284679, max_hamiltonian_energy_error = 1.5163667551879882, tree_depth = 4, numerical_error = false, step_size = 0.04005901000802962, nom_step_size = 0.04005901000802962, 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.4559121662384009, 0.15766355997621723, -0.9658125108846081, -0.03069706294135288, 0.6664275393034331], [-0.43702949898258553, 0.29256250165564723, 0.8287853346629266, 0.32587124398871087, -0.25073582842504755], [-0.24948611122642694, 0.20037905669101247, -0.3522965713103882, -0.07416339444381159, 0.46699284284526016], [-0.209609780629109, 0.32249702955365983, -0.28851938507944636, -0.804941848684209, 0.8359810158682269], [-0.34132329953290286, 0.3194543784283229, -0.5551859203536835, 0.2762706860432318, 0.2384236849141479], [-0.3041119542740221, 0.1758318688206451, -0.4027663938717147, -0.44088493653508576, 0.7437218159583027], [-0.26627955425003247, 0.16432117470915603, -0.4964985460716248, 0.4592254861774757, 0.23318935683175407], [-0.2240216379642597, 0.23290395633187383, -0.5814357188271356, 0.9994503179651125, -0.167257173572815], [-0.4678100070650148, 0.40104191264597916, 0.13078323475033649, -2.3857472204544226, 1.7650797186614013], [-0.2676244845066477, 0.09136862813687932, -0.4162802531592627, 1.2919367584106909, -0.3824915161521878]  …  [-0.29340710175103096, 0.24495269720447077, 1.7435571700077803, -0.4693089615677203, 0.014962497904641131], [-0.4074062764996815, 0.2502748792219075, 0.6800989050037656, 0.6974918432543723, -0.43142536369058065], [-0.2549277468672565, 0.24982610260917712, 1.1586893864875043, -0.46094573484193624, 0.21727872268996712], [-0.33842088960968536, 0.25687181453316316, -1.320118131331318, 1.3216595555767467, -0.17894111315912814], [-0.21134769732181027, -0.036978811005675, -0.7457530795093287, -1.3263683559610193, 1.5960732543133347], [-0.4463334646011564, 0.5383570611775498, -1.8020697369244032, 1.5520827546116014, -0.3535690347092658], [-0.49169725556489213, 0.34795001091383837, -1.6172679599471407, 0.9710041402527736, 0.0904930724565225], [-0.2815370217462947, 0.18895046499448215, -1.4512884558184147, -0.20087281331502393, 0.902254259056551], [-0.31020573790808537, 0.38277319778850505, -1.7197721771600367, 0.5935815749711434, 0.4240932649451334], [-0.36974671082096433, 0.08005777497258869, -1.7400730480395727, -0.3552832634287279, 1.1358383440970676]], NamedTuple[(n_steps = 23, is_accept = true, acceptance_rate = 0.9295208420992196, log_density = -114.17962032283224, hamiltonian_energy = 116.10228024208809, hamiltonian_energy_error = 0.03844347646708002, max_hamiltonian_energy_error = 0.13819208792556026, tree_depth = 4, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 43, is_accept = true, acceptance_rate = 0.9998450848566077, log_density = -113.3321135715965, hamiltonian_energy = 117.56728288051924, hamiltonian_energy_error = -0.17804018463637306, max_hamiltonian_energy_error = -0.3043139015911436, tree_depth = 5, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 43, is_accept = true, acceptance_rate = 0.8418083716475444, log_density = -113.25840600335731, hamiltonian_energy = 115.60373254817927, hamiltonian_energy_error = 0.07664917051768327, max_hamiltonian_energy_error = 0.3885774995962805, tree_depth = 5, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.706798229236611, log_density = -114.98014257527933, hamiltonian_energy = 116.9347694903667, hamiltonian_energy_error = 0.3769413644553481, max_hamiltonian_energy_error = 0.759849651085517, tree_depth = 2, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.9751255596642991, log_density = -112.42098398665782, hamiltonian_energy = 115.73950122600492, hamiltonian_energy_error = -0.6282403939471237, max_hamiltonian_energy_error = -0.6282403939471237, tree_depth = 2, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.8172958594103449, log_density = -112.85632027356262, hamiltonian_energy = 113.38811668923329, hamiltonian_energy_error = 0.11873814654690307, max_hamiltonian_energy_error = 0.25596122470726357, tree_depth = 2, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.8047168658796209, log_density = -114.0952247659964, hamiltonian_energy = 115.06702640815313, hamiltonian_energy_error = 0.27138164151857325, max_hamiltonian_energy_error = 0.34814615171542584, tree_depth = 2, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.954674151363614, log_density = -114.41344027493683, hamiltonian_energy = 115.47135091615473, hamiltonian_energy_error = 0.13121320245744528, max_hamiltonian_energy_error = -0.21922442522345875, tree_depth = 2, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.5142899103821224, log_density = -118.91738082295211, hamiltonian_energy = 120.00320968654324, hamiltonian_energy_error = 1.1493611412580975, max_hamiltonian_energy_error = 1.1493611412580975, tree_depth = 2, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 1.0, log_density = -114.26758458450998, hamiltonian_energy = 118.63962236068298, hamiltonian_energy_error = -1.1689037803630953, max_hamiltonian_energy_error = -1.423382095008833, tree_depth = 2, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false)  …  (n_steps = 11, is_accept = true, acceptance_rate = 0.9981115249764969, log_density = -114.03657901541717, hamiltonian_energy = 114.8385483026474, hamiltonian_energy_error = -0.06032208815545914, max_hamiltonian_energy_error = -0.12052008497299482, tree_depth = 3, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 47, is_accept = true, acceptance_rate = 0.9779448575398846, log_density = -112.97270110440927, hamiltonian_energy = 114.86277209494187, hamiltonian_energy_error = -0.0009899172661107514, max_hamiltonian_energy_error = -0.12723495791374262, tree_depth = 5, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 15, is_accept = true, acceptance_rate = 0.6204298036844106, log_density = -113.90369825404132, hamiltonian_energy = 116.89447410385718, hamiltonian_energy_error = 0.33675975242518064, max_hamiltonian_energy_error = 0.936977478005474, tree_depth = 3, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 35, is_accept = true, acceptance_rate = 0.9768336963569602, log_density = -113.83617659785563, hamiltonian_energy = 115.30575386191818, hamiltonian_energy_error = -0.06046231520390677, max_hamiltonian_energy_error = 0.08006257439068065, tree_depth = 5, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.5650609808528294, log_density = -118.4563389525626, hamiltonian_energy = 118.80443498548779, hamiltonian_energy_error = 1.0331936118984828, max_hamiltonian_energy_error = 1.0331936118984828, tree_depth = 2, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 15, is_accept = true, acceptance_rate = 0.9585872536320833, log_density = -119.42417475221, hamiltonian_energy = 122.40323236500605, hamiltonian_energy_error = 0.45068563055687605, max_hamiltonian_energy_error = -1.0189097031186947, tree_depth = 3, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 1.0, log_density = -116.57524013472403, hamiltonian_energy = 119.89378104086842, hamiltonian_energy_error = -0.9726815678619971, max_hamiltonian_energy_error = -1.1486845166405715, tree_depth = 2, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 1.0, log_density = -114.14782566220791, hamiltonian_energy = 116.93236321967764, hamiltonian_energy_error = -0.6020682670559552, max_hamiltonian_energy_error = -0.6020682670559552, tree_depth = 2, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.9237047681102045, log_density = -114.92197003197542, hamiltonian_energy = 115.68580140589276, hamiltonian_energy_error = 0.13182677282927102, max_hamiltonian_energy_error = 0.13326313478786744, tree_depth = 2, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, is_adapt = false), (n_steps = 19, is_accept = true, acceptance_rate = 0.9801038871119595, log_density = -115.46777262348627, hamiltonian_energy = 116.83939632731057, hamiltonian_energy_error = 0.05290718317456822, max_hamiltonian_energy_error = -0.09339129755473152, tree_depth = 4, numerical_error = false, step_size = 0.997232746014232, nom_step_size = 0.997232746014232, 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.2527388088852728, 0.17208012699750494, 0.2952584936465345, 0.022320068103348634, 0.15733575613528494], [-0.4291377134539547, 0.32920513736825285, 0.4393892488007558, -0.0013200027011879278, 0.12258003572248383], [-0.26001217742047933, 0.15318182286726076, 0.09201227904075221, 1.6526601688816887, -0.7518870811979403], [-0.3155436513687605, -0.07998549561625119, 0.6051193124268837, -0.5513730052747756, 0.6328849786592662], [-0.2661332913313262, -0.13712984516614357, 0.5149913494112253, -0.3012780402723181, 0.5497272872853781], [-0.22215648646250585, 0.14331381776470486, 0.3672360499575149, 0.09222757546176336, 0.17784971126504545], [-0.2915732506855215, 0.13630978100186972, 0.7166718756613559, -1.5679400391247573, 1.2013957899252157], [-0.37987489735390434, 0.09441089965302114, -0.005856445119694742, -1.7669976761242954, 1.5021189630490048], [-0.36848708101523586, 0.11024118611250996, 0.20064485677944982, 1.4980326696396744, -0.7893281756963201], [-0.493791079519271, 0.38354181140226445, 0.5781455885728157, -0.1908567677105213, 0.13789219645054585]  …  [-0.17490736182536634, 0.12978027511029805, 1.7563948998902064, -0.6258320715159139, 0.2545713096188753], [-0.22008437130092529, 0.06035052678847744, 2.3213092144480676, -0.9865270787613014, 0.33159670390632734], [-0.32531258068535274, 0.03470187710029662, 0.7424389257389611, 0.2005961339483665, -0.03076543093762596], [-0.3060455151009557, 0.35466336316635066, 0.456007030648103, 1.3776087300218438, -0.7938605613689966], [-0.3963760453216015, 0.14904832572424143, 0.881242775769902, -1.0458455740128305, 0.6677602549323026], [-0.26298562354650795, 0.2987678107909115, 0.1489465799270607, -0.49949266397200365, 0.5776019009846981], [-0.4364036232907639, 0.24159281172976876, -1.0758712438719928, 0.5684848433644487, 0.27242714627248477], [-0.3507538932954303, 0.1193680086172931, -1.033366394540409, 0.3184873648953528, 0.44861709632980806], [-0.5004509888714077, 0.44079917750099606, -0.9223444311776047, -0.3205539046575383, 0.7067786708158721], [-0.14769846606332743, 0.05859371997690402, -1.2941895126042766, 1.1066668181469903, 0.04985178354923539]], NamedTuple[(n_steps = 7, is_accept = true, acceptance_rate = 0.8760332522622697, log_density = -113.52733133342548, hamiltonian_energy = 115.85739868389065, hamiltonian_energy_error = -0.06182447511865519, max_hamiltonian_energy_error = 0.26543666254804066, tree_depth = 2, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 27, is_accept = true, acceptance_rate = 0.9858019138894797, log_density = -113.48500877948257, hamiltonian_energy = 114.5703562976834, hamiltonian_energy_error = 0.017863263965594456, max_hamiltonian_energy_error = -0.16204274869353696, tree_depth = 4, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.4724630505109441, log_density = -115.65995231186191, hamiltonian_energy = 119.46668216430464, hamiltonian_energy_error = 0.614371741812306, max_hamiltonian_energy_error = 1.2561289467941776, tree_depth = 2, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 31, is_accept = true, acceptance_rate = 0.996561839426301, log_density = -115.60223605427826, hamiltonian_energy = 117.88016018368306, hamiltonian_energy_error = -0.03397291414280801, max_hamiltonian_energy_error = -0.3202962841468775, tree_depth = 4, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.947636115057466, log_density = -117.17589956576387, hamiltonian_energy = 118.12572720710554, hamiltonian_energy_error = 0.17089705147913037, max_hamiltonian_energy_error = -0.8237253260316777, tree_depth = 2, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.9723237920918238, log_density = -114.24688410273087, hamiltonian_energy = 117.88183561301392, hamiltonian_energy_error = -0.400823278166456, max_hamiltonian_energy_error = -0.5519515652853215, tree_depth = 2, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.7182668669710662, log_density = -116.13402003886873, hamiltonian_energy = 117.73014161656154, hamiltonian_energy_error = 0.4150879491173072, max_hamiltonian_energy_error = 0.4150879491173072, tree_depth = 2, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 27, is_accept = true, acceptance_rate = 0.9963872327824952, log_density = -115.6709924532715, hamiltonian_energy = 118.77036353271669, hamiltonian_energy_error = -0.2167908457387142, max_hamiltonian_energy_error = -0.4312459887147213, tree_depth = 4, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 39, is_accept = true, acceptance_rate = 0.928918428585088, log_density = -115.32821256554415, hamiltonian_energy = 119.79091199125762, hamiltonian_energy_error = -0.065616000936501, max_hamiltonian_energy_error = 0.28057853294632196, tree_depth = 5, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 31, is_accept = true, acceptance_rate = 0.9531250659445826, log_density = -115.1341003614533, hamiltonian_energy = 117.97502728480856, hamiltonian_energy_error = -0.09197827052622642, max_hamiltonian_energy_error = 0.13546838454789167, tree_depth = 5, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false)  …  (n_steps = 3, is_accept = true, acceptance_rate = 0.7458022550322915, log_density = -118.72354235333272, hamiltonian_energy = 121.26500194465272, hamiltonian_energy_error = 0.33027560593130545, max_hamiltonian_energy_error = 0.6564659506890251, tree_depth = 2, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 15, is_accept = true, acceptance_rate = 0.994363299329306, log_density = -119.19540623223247, hamiltonian_energy = 122.41313663497087, hamiltonian_energy_error = -0.043231690232758524, max_hamiltonian_energy_error = -0.5308886451997523, tree_depth = 3, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 43, is_accept = true, acceptance_rate = 0.9866384032472298, log_density = -113.73899223343896, hamiltonian_energy = 119.88450884422788, hamiltonian_energy_error = -0.6825097915696574, max_hamiltonian_energy_error = -0.7362172408297312, tree_depth = 5, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.8552913971515622, log_density = -114.8533306625371, hamiltonian_energy = 115.85155095370388, hamiltonian_energy_error = 0.2533504997957863, max_hamiltonian_energy_error = 0.2533504997957863, tree_depth = 2, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.9970629526698467, log_density = -114.75743755648226, hamiltonian_energy = 115.25064120563096, hamiltonian_energy_error = 0.020773616490942004, max_hamiltonian_energy_error = -0.429409959493654, tree_depth = 2, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 43, is_accept = true, acceptance_rate = 0.8476040522972915, log_density = -113.75729018165242, hamiltonian_energy = 120.6941341365927, hamiltonian_energy_error = -0.20165815065332993, max_hamiltonian_energy_error = 0.5448746223740955, tree_depth = 5, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 39, is_accept = true, acceptance_rate = 0.987812934971051, log_density = -113.70314936044402, hamiltonian_energy = 115.22660485421288, hamiltonian_energy_error = -0.14718026758713165, max_hamiltonian_energy_error = -0.1891450656758309, tree_depth = 5, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.8994347705037488, log_density = -113.26163153307867, hamiltonian_energy = 114.67505222756724, hamiltonian_energy_error = -0.03603071070953945, max_hamiltonian_energy_error = 0.1741619501261482, tree_depth = 2, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.5864229086241388, log_density = -116.61130583106993, hamiltonian_energy = 117.58384196707065, hamiltonian_energy_error = 0.7262788052466504, max_hamiltonian_energy_error = 0.7262788052466504, tree_depth = 2, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.7920594933971575, log_density = -117.81654728806015, hamiltonian_energy = 119.7676456911751, hamiltonian_energy_error = 0.36010150070316627, max_hamiltonian_energy_error = -0.5722561419494951, tree_depth = 2, numerical_error = false, step_size = 0.9357093479683786, nom_step_size = 0.9357093479683786, is_adapt = false)])
  • 1https://mc-stan.org/docs/reference-manual/hmc-algorithm-parameters.html