diff --git a/dev/examples/initializing-hmc/index.html b/dev/examples/initializing-hmc/index.html index eeb79f5a..404376aa 100644 --- a/dev/examples/initializing-hmc/index.html +++ b/dev/examples/initializing-hmc/index.html @@ -9,143 +9,143 @@ scatter(x, y; xlabel="x", ylabel="y", legend=false, msw=0, ms=2)
We'll fit this using a simple polynomial regression model:
\[\begin{aligned} \sigma &\sim \text{Half-Normal}(\mu=0, \sigma=1)\\ @@ -190,44 +190,44 @@ ∇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: 2
draws: 5
- fit iteration: 22 (total: 30)
- fit ELBO: -117.74 ± 0.25
+ fit iteration: 32 (total: 32)
+ fit ELBO: -116.82 ± 0.61
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.351938851773518, 0.24689540392550613, 0.05827742217490308, 0.11655069217591063, 0.17482994194820867]
-Σ: [0.005794060117888708 0.004501772414217777 … 0.005154335534465927 -0.004280279761853394; 0.004501772414217777 0.03531824833492471 … 0.007991672055998154 -0.017293830014585607; … ; 0.005154335534465927 0.007991672055998154 … 0.7015097471184754 -0.440833068526388; -0.004280279761853394 -0.017293830014585607 … -0.440833068526388 0.28326699991508697]
+μ: [-0.35193742732366645, 0.2469005998325288, 0.05827588221943315, 0.11655176419252547, 0.17482764675446022]
+Σ: [0.004783202383029375 -0.001170612806498005 … 0.017642243198185595 -0.010817997078899744; -0.001170612806498005 0.020979748064002175 … -0.03205170538208288 0.01130698208468521; … ; 0.017642243198185595 -0.03205170538208288 … 1.0789712537388085 -0.6702794586413363; -0.010817997078899744 0.01130698208468521 … -0.6702794586413363 0.42226112257957793]
)
init_params = result_pf.draws[:, 1]
5-element Vector{Float64}:
- -0.3490992268968827
- 0.1768169119835949
- 0.1570690692732149
- -0.25930709446876066
- 0.4601383974449641
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.00579406 0.00450177 -0.00167075 0.00515434 -0.00428028
- 0.00450177 0.0353182 -0.00747888 0.00799167 -0.0172938
- -0.00167075 -0.00747888 0.0168776 -0.0892416 0.0570341
- 0.00515434 0.00799167 -0.0892416 0.70151 -0.440833
- -0.00428028 -0.0172938 0.0570341 -0.440833 0.283267
Here we just need to pass one of the draws as the initial point q
:
result_dhmc1 = mcmc_with_warmup(
+ -0.20140055125980677
+ 0.12271379282185454
+ -0.1694336237882354
+ 0.8614423999825955
+ -0.16004585896461493
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.0047832 -0.00117061 -0.000928193 0.0176422 -0.010818
+ -0.00117061 0.0209797 -0.000129508 -0.0320517 0.011307
+ -0.000928193 -0.000129508 0.0187343 -0.112272 0.0692776
+ 0.0176422 -0.0320517 -0.112272 1.07897 -0.670279
+ -0.010818 0.011307 0.0692776 -0.670279 0.422261
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.2758483430657324 -0.2893555991876607 … -0.37227629978523785 -0.3736822563814165; 0.31279906133060686 0.39336339879549875 … 0.271963235723552 0.27608919719580766; … ; 2.1809397121524112 0.6999844721757637 … 0.5842955088857441 1.8260496793967949; -1.5722167409245562 -0.6838662776940696 … -0.1548026495712692 -0.7703779597891128], tree_statistics = DynamicHMC.TreeStatisticsNUTS[DynamicHMC.TreeStatisticsNUTS(-117.66725488232109, 6, turning at positions -32:31, 0.9983291009431183, 63, DynamicHMC.Directions(0xbc27959f)), DynamicHMC.TreeStatisticsNUTS(-118.83703125483953, 6, turning at positions -35:28, 0.9777449382939619, 63, DynamicHMC.Directions(0xd07c275c)), DynamicHMC.TreeStatisticsNUTS(-117.35774859313008, 6, turning at positions -24:39, 0.9981679732178887, 63, DynamicHMC.Directions(0xdf6ec2e7)), DynamicHMC.TreeStatisticsNUTS(-117.95148087539897, 6, turning at positions -30:33, 0.9993693337084574, 63, DynamicHMC.Directions(0x3fe72a21)), DynamicHMC.TreeStatisticsNUTS(-124.00673222308028, 5, turning at positions -24:7, 0.8104172296411057, 31, DynamicHMC.Directions(0x315b4727)), DynamicHMC.TreeStatisticsNUTS(-122.49865390925322, 5, turning at positions -27:4, 0.9991340230919505, 31, DynamicHMC.Directions(0xbc5ece44)), DynamicHMC.TreeStatisticsNUTS(-115.91470245218702, 6, turning at positions -37:26, 0.9630110228799411, 63, DynamicHMC.Directions(0x6c355f9a)), DynamicHMC.TreeStatisticsNUTS(-114.39996506023576, 6, turning at positions -59:4, 0.9979480921106051, 63, DynamicHMC.Directions(0x0ab27f44)), DynamicHMC.TreeStatisticsNUTS(-115.41146259913958, 5, turning at positions 0:31, 0.9841617186594932, 31, DynamicHMC.Directions(0x9258eeff)), DynamicHMC.TreeStatisticsNUTS(-116.26828121119772, 6, turning at positions 0:63, 0.9908824354639745, 63, DynamicHMC.Directions(0x7b5b407f)) … DynamicHMC.TreeStatisticsNUTS(-114.99478723539855, 6, turning at positions -63:0, 0.9907022431104505, 63, DynamicHMC.Directions(0xef2aaa40)), DynamicHMC.TreeStatisticsNUTS(-116.97869290793183, 6, turning at positions -33:30, 0.7143602645686365, 63, DynamicHMC.Directions(0x8b77191e)), DynamicHMC.TreeStatisticsNUTS(-117.11186074123758, 6, turning at positions -48:15, 0.9737851940269915, 63, DynamicHMC.Directions(0x4da332cf)), DynamicHMC.TreeStatisticsNUTS(-116.65213028014398, 5, turning at positions -12:19, 0.985788223742232, 31, DynamicHMC.Directions(0xe9613733)), DynamicHMC.TreeStatisticsNUTS(-115.36237866813609, 2, turning at positions 1:4, 0.955490897307274, 7, DynamicHMC.Directions(0x4f520a0c)), DynamicHMC.TreeStatisticsNUTS(-118.5153762924302, 6, turning at positions -39:24, 0.9854234355029934, 63, DynamicHMC.Directions(0x70cec658)), DynamicHMC.TreeStatisticsNUTS(-114.58940759461872, 6, turning at positions -52:11, 0.9746921531995503, 63, DynamicHMC.Directions(0xc17210cb)), DynamicHMC.TreeStatisticsNUTS(-115.55715635279923, 6, turning at positions -29:34, 0.9074377963974533, 63, DynamicHMC.Directions(0xa15f60e2)), DynamicHMC.TreeStatisticsNUTS(-114.51994962110324, 6, turning at positions -3:60, 0.9939306867613937, 63, DynamicHMC.Directions(0x22920bbc)), DynamicHMC.TreeStatisticsNUTS(-117.22219257244788, 5, turning at positions -30:-33, 0.7625347575553412, 35, DynamicHMC.Directions(0x2695cf02))], κ = Gaussian kinetic energy (Diagonal), √diag(M⁻¹): [0.09617852377050368, 0.1467357966306328, 0.9427362465213873, 0.841927276752426, 0.5581416342226222], ϵ = 0.05204229470662355)
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(
+)
(posterior_matrix = [-0.42919697100974286 -0.21139987374860927 … -0.22891457642505386 -0.33697543481854547; 0.48762605177160445 0.20262889511823914 … 0.2780834137705154 0.5447343569669959; … ; 0.9816611739784356 0.35854051771698725 … -0.29019017804493763 0.3642718591782569; -0.42761123506228177 0.016430712777248335 … 0.3864856201949099 -0.44487446738133996], tree_statistics = DynamicHMC.TreeStatisticsNUTS[DynamicHMC.TreeStatisticsNUTS(-117.41394406969577, 7, turning at positions -102:25, 0.996969674355359, 127, DynamicHMC.Directions(0x94ec7119)), DynamicHMC.TreeStatisticsNUTS(-116.38727364732652, 6, turning at positions -10:53, 0.9408602272997408, 63, DynamicHMC.Directions(0xd35d94b5)), DynamicHMC.TreeStatisticsNUTS(-122.34842074548729, 5, turning at positions 22:37, 0.9685683448308003, 47, DynamicHMC.Directions(0x658f88b5)), DynamicHMC.TreeStatisticsNUTS(-117.73587548128637, 6, turning at positions -8:55, 0.9205483370267166, 63, DynamicHMC.Directions(0x0933d177)), DynamicHMC.TreeStatisticsNUTS(-116.7826214110699, 6, turning at positions -45:-108, 0.9229544878924183, 127, DynamicHMC.Directions(0xeb352013)), DynamicHMC.TreeStatisticsNUTS(-117.46496917475748, 5, turning at positions -5:26, 0.9950471930429885, 31, DynamicHMC.Directions(0xc667fe3a)), DynamicHMC.TreeStatisticsNUTS(-121.8205179028736, 6, turning at positions -52:11, 0.5377305954120832, 63, DynamicHMC.Directions(0xd739974b)), DynamicHMC.TreeStatisticsNUTS(-114.4297516222513, 6, turning at positions -42:21, 0.9999415419313027, 63, DynamicHMC.Directions(0x25ed57d5)), DynamicHMC.TreeStatisticsNUTS(-117.97526690130654, 6, turning at positions 51:114, 0.9542847420596517, 127, DynamicHMC.Directions(0x831fc4f2)), DynamicHMC.TreeStatisticsNUTS(-118.14671669864885, 6, turning at positions -23:40, 0.9996859381468479, 63, DynamicHMC.Directions(0x9ea797a8)) … DynamicHMC.TreeStatisticsNUTS(-116.28226876069697, 5, turning at positions -17:-24, 0.9941580906090818, 55, DynamicHMC.Directions(0x64d9c15f)), DynamicHMC.TreeStatisticsNUTS(-117.55520220821121, 6, turning at positions -16:47, 0.8627163765317972, 63, DynamicHMC.Directions(0x49afbf6f)), DynamicHMC.TreeStatisticsNUTS(-116.90846339831225, 5, turning at positions -50:-53, 0.9492362141772703, 59, DynamicHMC.Directions(0x68cd4bc6)), DynamicHMC.TreeStatisticsNUTS(-115.69232080039238, 7, turning at positions -55:72, 0.8534494973113602, 127, DynamicHMC.Directions(0x9146ca48)), DynamicHMC.TreeStatisticsNUTS(-120.41351488156272, 5, turning at positions 21:24, 0.9943538863976024, 55, DynamicHMC.Directions(0x9b63fc60)), DynamicHMC.TreeStatisticsNUTS(-117.75486776360326, 3, turning at positions -11:-14, 1.0, 15, DynamicHMC.Directions(0xb5c7fdb1)), DynamicHMC.TreeStatisticsNUTS(-117.88943724110086, 6, turning at positions -25:38, 0.9960354418105171, 63, DynamicHMC.Directions(0x5a6ce8e6)), DynamicHMC.TreeStatisticsNUTS(-115.2129750928417, 6, turning at positions -42:21, 0.9763375164470813, 63, DynamicHMC.Directions(0x900c5495)), DynamicHMC.TreeStatisticsNUTS(-116.1749007866109, 6, turning at positions 55:118, 0.9063254939971952, 127, DynamicHMC.Directions(0xf5b5a2f6)), DynamicHMC.TreeStatisticsNUTS(-120.17330342805336, 6, turning at positions -48:15, 0.9248222337081514, 63, DynamicHMC.Directions(0x75275acf))], κ = Gaussian kinetic energy (Diagonal), √diag(M⁻¹): [0.10455343664482653, 0.16510796593373156, 0.9239050246960616, 0.9815622112734754, 0.6972805974168755], ϵ = 0.03724657208882331)
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.32648878112876384 -0.4498067859073784 … -0.36253933637973246 -0.2942447143233157; 0.1789489916056201 0.2705448204425909 … 0.3067924203299595 0.12069966548599022; … ; 1.1951679257639007 -0.13642757907793546 … -1.9301625886255915 1.786347939406547; -0.5786945141617406 0.013197186437861663 … 0.7754402322031595 -1.005541126401132], tree_statistics = DynamicHMC.TreeStatisticsNUTS[DynamicHMC.TreeStatisticsNUTS(-116.70836299448789, 2, turning at positions -2:-5, 0.7301853041411208, 7, DynamicHMC.Directions(0x207aac42)), DynamicHMC.TreeStatisticsNUTS(-117.667763940461, 2, turning at positions -1:-4, 0.9023143210668639, 7, DynamicHMC.Directions(0xe93c3103)), DynamicHMC.TreeStatisticsNUTS(-121.63867308383959, 2, turning at positions 4:5, 0.7280634557080287, 7, DynamicHMC.Directions(0xe7270e6d)), DynamicHMC.TreeStatisticsNUTS(-123.10679167712954, 3, turning at positions -1:6, 0.7837276732237234, 7, DynamicHMC.Directions(0x5f1018ee)), DynamicHMC.TreeStatisticsNUTS(-119.99658317186748, 3, turning at positions -1:6, 0.9999999999999999, 7, DynamicHMC.Directions(0x7edde8ee)), DynamicHMC.TreeStatisticsNUTS(-116.74761696010485, 3, turning at positions -5:2, 0.9999999999999999, 7, DynamicHMC.Directions(0x24a3ed02)), DynamicHMC.TreeStatisticsNUTS(-115.76997523869682, 3, turning at positions -7:0, 0.9614756882882664, 7, DynamicHMC.Directions(0xe3258bd0)), DynamicHMC.TreeStatisticsNUTS(-116.71885589205205, 3, turning at positions 0:7, 0.9227570915349447, 7, DynamicHMC.Directions(0xb7928e0f)), DynamicHMC.TreeStatisticsNUTS(-119.53868695864278, 3, turning at positions -2:5, 0.947333613939426, 7, DynamicHMC.Directions(0xc8b216cd)), DynamicHMC.TreeStatisticsNUTS(-118.58913181581636, 2, turning at positions 0:3, 0.9810358527557205, 3, DynamicHMC.Directions(0xf854e9db)) … DynamicHMC.TreeStatisticsNUTS(-116.23247473967454, 3, turning at positions -7:0, 0.972153105250679, 7, DynamicHMC.Directions(0xddea2d58)), DynamicHMC.TreeStatisticsNUTS(-116.75693992925254, 3, turning at positions -2:5, 0.8179952447787305, 7, DynamicHMC.Directions(0x6b1a053d)), DynamicHMC.TreeStatisticsNUTS(-115.31016319240376, 3, turning at positions 2:9, 0.9150281108627871, 15, DynamicHMC.Directions(0x2f68fbc9)), DynamicHMC.TreeStatisticsNUTS(-115.03079604985959, 3, turning at positions -5:2, 0.966953505236604, 7, DynamicHMC.Directions(0x1811d08a)), DynamicHMC.TreeStatisticsNUTS(-119.04301779347969, 3, turning at positions -7:0, 0.8141752871237031, 7, DynamicHMC.Directions(0xffc25420)), DynamicHMC.TreeStatisticsNUTS(-120.66561638733852, 3, turning at positions -7:-14, 0.8152733003536984, 15, DynamicHMC.Directions(0xd4254bc1)), DynamicHMC.TreeStatisticsNUTS(-118.22994577380338, 3, turning at positions -4:3, 0.993389555180804, 7, DynamicHMC.Directions(0xe02aca4b)), DynamicHMC.TreeStatisticsNUTS(-119.44027609408025, 3, turning at positions -1:6, 0.9149157662478588, 7, DynamicHMC.Directions(0xdc4bb1ee)), DynamicHMC.TreeStatisticsNUTS(-120.7510753218437, 3, turning at positions -1:6, 0.8915789365969319, 7, DynamicHMC.Directions(0xaff5b83e)), DynamicHMC.TreeStatisticsNUTS(-121.8043833441733, 3, turning at positions -4:3, 0.9439045716910872, 7, DynamicHMC.Directions(0x512426d3))], κ = Gaussian kinetic energy (Symmetric), √diag(M⁻¹): [0.09619301578778361, 0.15690946921549248, 0.993146819375534, 0.9035124315845696, 0.6267610944004433], ϵ = 0.4111885323414418)
We also specified that DynamicHMC should tune a dense Symmetric
matrix. However, we could also have requested a Diagonal
metric.
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(
+)
(posterior_matrix = [-0.31014276886825337 -0.3106878294599664 … -0.3730454801184784 -0.3533404536024512; 0.267717123829322 0.04660326476567415 … 0.414620009341598 0.37932939382376846; … ; -0.568646642074459 -1.0292760706849555 … -0.11134341163745792 -0.02827637419331233; 0.9611002844502203 0.7325931335649423 … 0.3119996940588185 0.27599663245071826], tree_statistics = DynamicHMC.TreeStatisticsNUTS[DynamicHMC.TreeStatisticsNUTS(-115.7756349008694, 3, turning at positions -7:0, 0.9999999999999999, 7, DynamicHMC.Directions(0x55266cd8)), DynamicHMC.TreeStatisticsNUTS(-115.90610868981345, 3, turning at positions -6:1, 0.9421034479296162, 7, DynamicHMC.Directions(0x450e1409)), DynamicHMC.TreeStatisticsNUTS(-117.48957192032064, 2, turning at positions -2:1, 0.6707089911316859, 3, DynamicHMC.Directions(0x9de7dd79)), DynamicHMC.TreeStatisticsNUTS(-120.98646703298404, 4, turning at positions -5:10, 0.981521795667835, 15, DynamicHMC.Directions(0xb2bd883a)), DynamicHMC.TreeStatisticsNUTS(-118.1772153607903, 2, turning at positions -3:0, 0.7999750870288872, 3, DynamicHMC.Directions(0xb2038924)), DynamicHMC.TreeStatisticsNUTS(-116.04538304166215, 2, turning at positions -3:-6, 0.7421969365056256, 7, DynamicHMC.Directions(0x7159f471)), DynamicHMC.TreeStatisticsNUTS(-117.3078094358584, 3, turning at positions 0:7, 0.98376858854086, 7, DynamicHMC.Directions(0xc8cd499f)), DynamicHMC.TreeStatisticsNUTS(-116.21112748208503, 3, turning at positions -2:5, 0.9361700699063016, 7, DynamicHMC.Directions(0x804b1a3d)), DynamicHMC.TreeStatisticsNUTS(-116.6627131682672, 3, turning at positions 7:14, 0.9524854418867338, 15, DynamicHMC.Directions(0x6c92645e)), DynamicHMC.TreeStatisticsNUTS(-116.23730157895373, 4, turning at positions -9:6, 0.9946496227184538, 15, DynamicHMC.Directions(0x1fee9526)) … DynamicHMC.TreeStatisticsNUTS(-115.2486485726483, 3, turning at positions -6:1, 0.9360185875556345, 7, DynamicHMC.Directions(0x75080b21)), DynamicHMC.TreeStatisticsNUTS(-116.61287951930387, 3, turning at positions -1:6, 0.930339753460138, 7, DynamicHMC.Directions(0x610e2ca6)), DynamicHMC.TreeStatisticsNUTS(-116.21017508013456, 3, turning at positions -4:3, 0.9863437560699042, 7, DynamicHMC.Directions(0xfc34992b)), DynamicHMC.TreeStatisticsNUTS(-114.54254427477282, 3, turning at positions -2:-9, 0.8817877246875803, 15, DynamicHMC.Directions(0xca036cd6)), DynamicHMC.TreeStatisticsNUTS(-116.7009212820656, 3, turning at positions -4:-11, 0.8886135247324539, 15, DynamicHMC.Directions(0x26abcb44)), DynamicHMC.TreeStatisticsNUTS(-118.96741935047831, 2, turning at positions 4:7, 0.737620892185108, 7, DynamicHMC.Directions(0x31d22197)), DynamicHMC.TreeStatisticsNUTS(-116.64681022206888, 4, turning at positions -13:2, 0.9417505471018972, 15, DynamicHMC.Directions(0x17dcdae2)), DynamicHMC.TreeStatisticsNUTS(-113.87803518129803, 2, turning at positions -3:0, 0.9768712482851519, 3, DynamicHMC.Directions(0x8f5d82b8)), DynamicHMC.TreeStatisticsNUTS(-113.61032551791598, 3, turning at positions 0:7, 0.9969578182704871, 7, DynamicHMC.Directions(0x8ede1cd7)), DynamicHMC.TreeStatisticsNUTS(-115.34685088248375, 2, turning at positions -3:-6, 0.7695188241780929, 7, DynamicHMC.Directions(0xd01e9ad1))], κ = Gaussian kinetic energy (Symmetric), √diag(M⁻¹): [0.0965317466481926, 0.15847293750719074, 0.9664008766490653, 0.8736134921867713, 0.6113141649474361], ϵ = 0.36953154011916056)
We also specified that DynamicHMC should tune a dense Symmetric
matrix. However, we could also have requested a Diagonal
metric.
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.3220999997719651 -0.3539428454128892 … -0.30121528354499405 -0.4041290268392466; 0.20922838146662068 0.27503336515201066 … 0.3321879640126638 0.1402967215906879; … ; -1.4596534441690088 0.49830920997529193 … -0.4195580015564275 -0.1108684729509048; 0.7874958291454363 -0.5349471228235019 … 0.4298572143808084 0.26806480905203345], tree_statistics = DynamicHMC.TreeStatisticsNUTS[DynamicHMC.TreeStatisticsNUTS(-116.08868723825647, 3, turning at positions 0:7, 0.9639151099664913, 7, DynamicHMC.Directions(0x739551f7)), DynamicHMC.TreeStatisticsNUTS(-115.61834900625175, 3, turning at positions -6:1, 0.9859740075959113, 7, DynamicHMC.Directions(0xaaafbb81)), DynamicHMC.TreeStatisticsNUTS(-117.0701364285515, 3, turning at positions -4:3, 0.7854735691209184, 7, DynamicHMC.Directions(0x92f0b80b)), DynamicHMC.TreeStatisticsNUTS(-120.92139131786823, 4, turning at positions 13:16, 0.8356562395419037, 19, DynamicHMC.Directions(0xd1ba64dc)), DynamicHMC.TreeStatisticsNUTS(-117.01121219875554, 5, turning at positions -56:-63, 0.9839987580066771, 63, DynamicHMC.Directions(0xb59a4cc0)), DynamicHMC.TreeStatisticsNUTS(-113.61636832717885, 3, turning at positions -1:6, 0.9843239993844046, 7, DynamicHMC.Directions(0x3cbbdd0e)), DynamicHMC.TreeStatisticsNUTS(-118.1064001496842, 5, turning at positions -24:-31, 0.9068905544707647, 55, DynamicHMC.Directions(0xdbfb21d8)), DynamicHMC.TreeStatisticsNUTS(-119.20844748257664, 3, turning at positions -1:6, 0.9769238655159613, 7, DynamicHMC.Directions(0x412e7b16)), DynamicHMC.TreeStatisticsNUTS(-117.49956392367964, 3, turning at positions -1:-8, 0.9916980256441906, 15, DynamicHMC.Directions(0xa0ff0dc7)), DynamicHMC.TreeStatisticsNUTS(-117.6369647715093, 3, turning at positions 0:7, 0.981386254331903, 7, DynamicHMC.Directions(0xe818f797)) … DynamicHMC.TreeStatisticsNUTS(-118.25919129308764, 4, turning at positions -9:-16, 0.9353725519452714, 23, DynamicHMC.Directions(0x427b8067)), DynamicHMC.TreeStatisticsNUTS(-118.76351868444107, 5, turning at positions -13:-20, 0.9968995056924803, 47, DynamicHMC.Directions(0x10d9e19b)), DynamicHMC.TreeStatisticsNUTS(-116.97208589801134, 2, turning at positions -3:-6, 0.9530442805291315, 7, DynamicHMC.Directions(0x6172f4c1)), DynamicHMC.TreeStatisticsNUTS(-115.01592069581415, 3, turning at positions 0:7, 0.9405106205666193, 7, DynamicHMC.Directions(0x0d18df97)), DynamicHMC.TreeStatisticsNUTS(-114.17429417003753, 2, turning at positions 0:3, 0.9431001984970614, 3, DynamicHMC.Directions(0x427be733)), DynamicHMC.TreeStatisticsNUTS(-115.81278660512051, 2, turning at positions -3:0, 0.7880384318709096, 3, DynamicHMC.Directions(0x7df42a40)), DynamicHMC.TreeStatisticsNUTS(-116.69748819751109, 3, turning at positions 1:8, 0.9960526312879888, 15, DynamicHMC.Directions(0x7e8ddff8)), DynamicHMC.TreeStatisticsNUTS(-116.33728773819973, 4, turning at positions -10:-17, 0.9976433446532477, 31, DynamicHMC.Directions(0xf14966ae)), DynamicHMC.TreeStatisticsNUTS(-115.56938599776959, 4, turning at positions 15:18, 0.993730396814222, 31, DynamicHMC.Directions(0xf99a8bb2)), DynamicHMC.TreeStatisticsNUTS(-116.16448886228234, 2, turning at positions -2:1, 0.8615756698640805, 3, DynamicHMC.Directions(0x3a0ecd95))], κ = Gaussian kinetic energy (WoodburyPDMat), √diag(M⁻¹): [0.07611872383250201, 0.1879314990493204, 0.12991366130961352, 0.8375617870452757, 0.5322283343782884], ϵ = 0.5921487293357944)
Similar to Pathfinder and DynamicHMC, AdvancedHMC can also work with a LogDensityProblem:
using AdvancedHMC
+)
(posterior_matrix = [-0.4181625730398314 -0.23877134506937422 … -0.35614010602074525 -0.24722202784428687; 0.05571152811327862 0.619978254287339 … 0.20045614019028773 0.31306989981244226; … ; 0.5655661954890383 0.4215438738188121 … 0.6400758154365427 1.0100512173072085; 0.26902213235922845 0.045262270609987165 … -0.31061309450176394 -0.5660013259462144], tree_statistics = DynamicHMC.TreeStatisticsNUTS[DynamicHMC.TreeStatisticsNUTS(-118.53676632555118, 3, turning at positions -3:4, 0.9833313602551751, 7, DynamicHMC.Directions(0xbe9b702c)), DynamicHMC.TreeStatisticsNUTS(-120.8838229100884, 3, turning at positions -5:2, 0.7341930608698936, 7, DynamicHMC.Directions(0xd26a56a2)), DynamicHMC.TreeStatisticsNUTS(-119.95672868844748, 2, turning at positions 1:4, 0.9202879625885396, 7, DynamicHMC.Directions(0xfa36c5f4)), DynamicHMC.TreeStatisticsNUTS(-123.86640832029974, 3, turning at positions -2:5, 0.6493471024251117, 7, DynamicHMC.Directions(0x760a88cd)), DynamicHMC.TreeStatisticsNUTS(-124.29934923967515, 2, turning at positions -4:-7, 0.9720951305027359, 7, DynamicHMC.Directions(0x1dd13028)), DynamicHMC.TreeStatisticsNUTS(-119.1539650995537, 4, turning at positions 15:22, 0.9854062272332355, 23, DynamicHMC.Directions(0xda9cfc3e)), DynamicHMC.TreeStatisticsNUTS(-121.39213425234674, 3, turning at positions -7:0, 0.9454032875301186, 7, DynamicHMC.Directions(0xe15d7378)), DynamicHMC.TreeStatisticsNUTS(-119.96011164509231, 4, turning at positions 9:12, 0.9415326017234932, 19, DynamicHMC.Directions(0x06e1ac98)), DynamicHMC.TreeStatisticsNUTS(-121.0541668513089, 4, turning at positions -15:-18, 0.9918490575831471, 31, DynamicHMC.Directions(0xb1acee4d)), DynamicHMC.TreeStatisticsNUTS(-116.44757077188903, 3, turning at positions -1:6, 0.9122997019401838, 7, DynamicHMC.Directions(0x20e9e9ce)) … DynamicHMC.TreeStatisticsNUTS(-121.56185800529579, 2, turning at positions 0:3, 0.9999999999999999, 3, DynamicHMC.Directions(0x6e800713)), DynamicHMC.TreeStatisticsNUTS(-117.27002583868729, 4, turning at positions 14:21, 0.9566276366622275, 31, DynamicHMC.Directions(0x57eaab35)), DynamicHMC.TreeStatisticsNUTS(-115.95077961112513, 3, turning at positions 0:7, 0.9766196003987198, 7, DynamicHMC.Directions(0xdbea3ebf)), DynamicHMC.TreeStatisticsNUTS(-116.18470511396829, 3, turning at positions -1:6, 0.9458181707424528, 7, DynamicHMC.Directions(0x63d16046)), DynamicHMC.TreeStatisticsNUTS(-115.20026995617256, 3, turning at positions -4:3, 0.9160195963698293, 7, DynamicHMC.Directions(0x2c472c0b)), DynamicHMC.TreeStatisticsNUTS(-115.04048344120976, 3, turning at positions -6:-13, 1.0, 15, DynamicHMC.Directions(0x3c99b0c2)), DynamicHMC.TreeStatisticsNUTS(-114.43740020033614, 2, turning at positions -1:2, 0.9999999999999999, 3, DynamicHMC.Directions(0xeeda9292)), DynamicHMC.TreeStatisticsNUTS(-114.00367254041109, 3, turning at positions -3:4, 0.9895162034571758, 7, DynamicHMC.Directions(0x1512902c)), DynamicHMC.TreeStatisticsNUTS(-114.65821370763774, 2, turning at positions -1:-4, 0.9146540642893474, 7, DynamicHMC.Directions(0xc7973343)), DynamicHMC.TreeStatisticsNUTS(-115.9492589091601, 3, turning at positions -4:3, 0.9256976182440564, 7, DynamicHMC.Directions(0xe43d4c2b))], κ = Gaussian kinetic energy (WoodburyPDMat), √diag(M⁻¹): [0.06916069970025875, 0.14484387478938207, 0.13687335049101199, 1.0387354108428228, 0.6498162221579102], ϵ = 0.6642437176866007)
Similar to Pathfinder and DynamicHMC, AdvancedHMC can also work with a LogDensityProblem:
using AdvancedHMC
nadapts = 500;
metric = DiagEuclideanMetric(dim)
hamiltonian = Hamiltonian(metric, ∇P)
@@ -275,4 +275,4 @@
nadapts;
drop_warmup=true,
progress=false,
-)
Settings
This document was generated with Documenter.jl version 0.27.25 on Tuesday 3 October 2023. Using Julia version 1.9.3.