From c21650fe0c645dd1309c39495974f2411058cadd Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Tue, 26 Sep 2023 00:27:39 +0000 Subject: [PATCH] build based on 8f220d2 --- dev/examples/initializing-hmc/index.html | 254 +- dev/examples/quickstart/index.html | 4388 +++++++++++----------- dev/examples/turing/index.html | 6 +- dev/index.html | 2 +- dev/lib/internals/index.html | 2 +- dev/lib/public/index.html | 2 +- dev/search/index.html | 2 +- 7 files changed, 2328 insertions(+), 2328 deletions(-) diff --git a/dev/examples/initializing-hmc/index.html b/dev/examples/initializing-hmc/index.html index de01421b..d4ecff3b 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)\\ @@ -275,4 +275,4 @@ nadapts; drop_warmup=true, progress=false, -)

+)
diff --git a/dev/examples/quickstart/index.html b/dev/examples/quickstart/index.html index 64a1e085..bc09ded0 100644 --- a/dev/examples/quickstart/index.html +++ b/dev/examples/quickstart/index.html @@ -106,84 +106,84 @@ contour(xrange, yrange, exp ∘ logp_banana ∘ Base.vect; xlabel="x₁", ylabel="x₂") - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +

Now we run pathfinder.

result = pathfinder(prob_banana; init_scale=10)
Single-path Pathfinder result
   tries: 1
@@ -211,1084 +211,1084 @@
 plot!(xlims=extrema(xrange), ylims=extrema(yrange), xlabel="x₁", ylabel="x₂", legend=false)
- + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + +

While the draws do a poor job of covering the tails of the distribution, they are still useful for identifying the nonlinear correlation between these two parameters.

A 100-dimensional funnel

As we have seen above, running multi-path Pathfinder is much more useful for target distributions that are far from normal. One particularly difficult distribution to sample is Neal's funnel:

\[\begin{aligned} \tau &\sim \mathrm{Normal}(\mu=0, \sigma=3)\\ @@ -1340,1087 +1340,1087 @@ plot!(; xlims=extrema(τ_range), ylims=extrema(β₁_range), xlabel="τ", ylabel="β₁", legend=false) - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + -

+ diff --git a/dev/examples/turing/index.html b/dev/examples/turing/index.html index 2deb1ae8..b2f61436 100644 --- a/dev/examples/turing/index.html +++ b/dev/examples/turing/index.html @@ -67,8 +67,8 @@ Iterations = 501:1:1500 Number of chains = 4 Samples per chain = 1000 -Wall duration = 8.38 seconds -Compute duration = 6.04 seconds +Wall duration = 7.94 seconds +Compute duration = 5.49 seconds parameters = α, β, σ internals = lp, n_steps, is_accept, acceptance_rate, log_density, hamiltonian_energy, hamiltonian_energy_error, max_hamiltonian_energy_error, tree_depth, numerical_error, step_size, nom_step_size @@ -116,4 +116,4 @@ progress=false, )
([[1.4676402233577517, 2.0074038351557344, -1.4841937242140848], [1.4807946823073779, 2.0093123538946296, -1.5181587082519967], [1.415393196701997, 2.007056906013418, -1.4321505435894895], [1.493231958550808, 2.00341124900399, -1.5931804982180824], [1.4561374815832329, 2.011388144537265, -1.5185743201225377], [1.5218218898915163, 1.9997281004626335, -1.6081599902590913], [1.4865222773504163, 2.0060288523741434, -1.5960983644526323], [1.4645278977026965, 2.009341376402341, -1.6767083888554495], [1.512515685316033, 2.0027271841784025, -1.4073616456821285], [1.5036001911203791, 1.995789055325274, -1.5486660645040526]  …  [1.5129472987618144, 1.9931476408498332, -1.605188822644906], [1.4362468608990842, 2.01238639794947, -1.630789444029088], [1.5302979980280567, 1.995947091140596, -1.462321807636107], [1.4907390646514165, 2.0065112037496045, -1.5450615247120634], [1.490634870113431, 2.0010298354323384, -1.6301395083494823], [1.4646460455078356, 2.009722646886248, -1.552417987563257], [1.5300956489836317, 1.997405454393315, -1.6451578523810704], [1.436088289703882, 2.01085264592819, -1.591661426829158], [1.4824733020478118, 1.9996745881169993, -1.5531501748711314], [1.4809078303928631, 1.9994430010724284, -1.5688139887827495]], NamedTuple[(n_steps = 7, is_accept = true, acceptance_rate = 0.883600253830029, log_density = 7.761488891605511, hamiltonian_energy = -5.449857209110606, hamiltonian_energy_error = -0.004598836381440208, max_hamiltonian_energy_error = 0.2744620290551536, tree_depth = 3, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.9392494156413083, log_density = 7.528433449761108, hamiltonian_energy = -6.681374538522578, hamiltonian_energy_error = 0.019214956520409388, max_hamiltonian_energy_error = 0.12379508840124753, tree_depth = 2, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.7120275508653812, log_density = 4.186245521102456, hamiltonian_energy = -3.6754079091725127, hamiltonian_energy_error = 0.438488030607314, max_hamiltonian_energy_error = 0.438488030607314, tree_depth = 2, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.9605800748703299, log_density = 7.949650072506822, hamiltonian_energy = -3.1610190479831237, hamiltonian_energy_error = -0.5854110216058186, max_hamiltonian_energy_error = -0.5854110216058186, tree_depth = 3, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.96554694407735, log_density = 7.802574934285351, hamiltonian_energy = -7.459218488786334, hamiltonian_energy_error = 0.03961194141551161, max_hamiltonian_energy_error = 0.0555739612847761, tree_depth = 3, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.9505344253847955, log_density = 7.200063535130109, hamiltonian_energy = -6.840269168776417, hamiltonian_energy_error = 0.058406665731227214, max_hamiltonian_energy_error = 0.09613982298851642, tree_depth = 2, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 11, is_accept = true, acceptance_rate = 0.9969004647515886, log_density = 7.876706043725011, hamiltonian_energy = -7.016030854399295, hamiltonian_energy_error = -0.09956255341367015, max_hamiltonian_energy_error = -0.11975268992651777, tree_depth = 3, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.7818256896080591, log_density = 6.329867834048604, hamiltonian_energy = -5.638796993011745, hamiltonian_energy_error = 0.23821975937041362, max_hamiltonian_energy_error = 0.3838240200238836, tree_depth = 2, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.8885254637118603, log_density = 5.861245671846356, hamiltonian_energy = -3.8157290926649043, hamiltonian_energy_error = 0.11037000607528213, max_hamiltonian_energy_error = 0.33485362654746265, tree_depth = 2, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 11, is_accept = true, acceptance_rate = 0.9511796450153046, log_density = 6.607957774659404, hamiltonian_energy = -3.8377368477041816, hamiltonian_energy_error = -0.09436292398567758, max_hamiltonian_energy_error = -0.3038257291549553, tree_depth = 3, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false)  …  (n_steps = 7, is_accept = true, acceptance_rate = 0.8916885801927464, log_density = 5.226404588072593, hamiltonian_energy = -4.277896352320278, hamiltonian_energy_error = 0.2690165699846876, max_hamiltonian_energy_error = 0.2690165699846876, tree_depth = 3, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 11, is_accept = true, acceptance_rate = 1.0, log_density = 7.019780437862182, hamiltonian_energy = -4.819960784311828, hamiltonian_energy_error = -0.3677626374235512, max_hamiltonian_energy_error = -0.42035826865857473, tree_depth = 3, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.9132036146804784, log_density = 6.612394319079511, hamiltonian_energy = -5.386581233294251, hamiltonian_energy_error = 0.10012500899977006, max_hamiltonian_energy_error = 0.21324112747079038, tree_depth = 3, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 1.0, log_density = 7.878321485404268, hamiltonian_energy = -6.66661460787871, hamiltonian_energy_error = -0.2183710411307045, max_hamiltonian_energy_error = -0.2183710411307045, tree_depth = 2, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.7797955547387869, log_density = 7.153461855847842, hamiltonian_energy = -4.549506622611551, hamiltonian_energy_error = -0.007392300189944301, max_hamiltonian_energy_error = 0.6187067956498566, tree_depth = 2, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.9900488836858519, log_density = 8.030537772910673, hamiltonian_energy = -6.619381490352603, hamiltonian_energy_error = -0.11693593797947965, max_hamiltonian_energy_error = -0.11693593797947965, tree_depth = 2, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.7160772739874185, log_density = 6.264624132178908, hamiltonian_energy = -3.1266014248405947, hamiltonian_energy_error = 0.12538246369640227, max_hamiltonian_energy_error = 0.7535328451430714, tree_depth = 3, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 7, is_accept = true, acceptance_rate = 0.9481407681503587, log_density = 7.5173471057431875, hamiltonian_energy = -4.2587346571289055, hamiltonian_energy_error = -0.16005835781577904, max_hamiltonian_energy_error = 0.17225479155535695, tree_depth = 3, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 3, is_accept = true, acceptance_rate = 0.9513250028584923, log_density = 7.121690491698855, hamiltonian_energy = -6.636997266552586, hamiltonian_energy_error = 0.08947353718440709, max_hamiltonian_energy_error = 0.08947353718440709, tree_depth = 2, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false), (n_steps = 1, is_accept = true, acceptance_rate = 0.9528697555900233, log_density = 6.8601547814818105, hamiltonian_energy = -6.703189205681179, hamiltonian_energy_error = 0.04827705246423708, max_hamiltonian_energy_error = 0.04827705246423708, tree_depth = 1, numerical_error = false, step_size = 0.7264850453013639, nom_step_size = 0.7264850453013639, is_adapt = false)])

Now we pack the samples into an MCMCChains.Chains:

samples_transformed = reduce(vcat, fun.transform.(samples)')
 varnames = Pathfinder.flattened_varnames_list(model)
-chns = MCMCChains.Chains(samples_transformed, varnames)

See Initializing HMC with Pathfinder for further examples.

+chns = MCMCChains.Chains(samples_transformed, varnames)

See Initializing HMC with Pathfinder for further examples.

diff --git a/dev/index.html b/dev/index.html index 46bb1f25..83f511db 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -Home · Pathfinder.jl

Pathfinder.jl: Parallel quasi-Newton variational inference

This package implements Pathfinder, [Zhang2021] a variational method for initializing Markov chain Monte Carlo (MCMC) methods.

Single-path Pathfinder

Single-path Pathfinder (pathfinder) attempts to return draws in or near the typical set, usually with many fewer gradient evaluations. Pathfinder uses the limited-memory BFGS(L-BFGS) optimizer to construct a maximum a posteriori (MAP) estimate of a target posterior distribution $p$. It then uses the trace of the optimization to construct a sequence of multivariate normal approximations to the target distribution, returning the approximation that maximizes the evidence lower bound (ELBO) – equivalently, minimizes the Kullback-Leibler divergence from the target distribution – as well as draws from the distribution.

Multi-path Pathfinder

Multi-path Pathfinder (multipathfinder) consists of running Pathfinder multiple times. It returns a uniformly-weighted mixture model of the multivariate normal approximations of the individual runs. It also uses importance resampling to return samples that better approximate the target distribution and assess the quality of the approximation.

Uses

Using the Pathfinder draws

Folk theorem of statistical computing

When you have computational problems, often there’s a problem with your model.

Visualizing posterior draws is a common way to diagnose problems with a model. However, problematic models often tend to be slow to warm-up. Even if the draws returned by Pathfinder are only approximations to the posterior, they can sometimes still be used to diagnose basic issues such as highly correlated parameters, parameters with very different posterior variances, and multimodality.

Initializing MCMC

Pathfinder can be used to initialize MCMC. This especially useful when sampling with Hamiltonian Monte Carlo. See Initializing HMC with Pathfinder for details.

Integration with the Julia ecosystem

Pathfinder uses several packages for extended functionality:

  • Optimization.jl: This allows the L-BFGS optimizer to be replaced with any of the many Optimization-compatible optimizers and supports use of callbacks. Note that any changes made to Pathfinder using these features would be experimental.
  • Transducers.jl: parallelization support
  • Distributions.jl/PDMats.jl: fits can be used anywhere a Distribution can be used
  • LogDensityProblems.jl: defining the log-density function, gradient, and Hessian
  • ProgressLogging.jl: In Pluto, Juno, and VSCode, nested progress bars are shown. In the REPL, use TerminalLoggers.jl to get progress bars.
  • Zhang2021Lu Zhang, Bob Carpenter, Andrew Gelman, Aki Vehtari (2021). Pathfinder: Parallel quasi-Newton variational inference. arXiv: 2108.03782 [stat.ML]. Code
+Home · Pathfinder.jl

Pathfinder.jl: Parallel quasi-Newton variational inference

This package implements Pathfinder, [Zhang2021] a variational method for initializing Markov chain Monte Carlo (MCMC) methods.

Single-path Pathfinder

Single-path Pathfinder (pathfinder) attempts to return draws in or near the typical set, usually with many fewer gradient evaluations. Pathfinder uses the limited-memory BFGS(L-BFGS) optimizer to construct a maximum a posteriori (MAP) estimate of a target posterior distribution $p$. It then uses the trace of the optimization to construct a sequence of multivariate normal approximations to the target distribution, returning the approximation that maximizes the evidence lower bound (ELBO) – equivalently, minimizes the Kullback-Leibler divergence from the target distribution – as well as draws from the distribution.

Multi-path Pathfinder

Multi-path Pathfinder (multipathfinder) consists of running Pathfinder multiple times. It returns a uniformly-weighted mixture model of the multivariate normal approximations of the individual runs. It also uses importance resampling to return samples that better approximate the target distribution and assess the quality of the approximation.

Uses

Using the Pathfinder draws

Folk theorem of statistical computing

When you have computational problems, often there’s a problem with your model.

Visualizing posterior draws is a common way to diagnose problems with a model. However, problematic models often tend to be slow to warm-up. Even if the draws returned by Pathfinder are only approximations to the posterior, they can sometimes still be used to diagnose basic issues such as highly correlated parameters, parameters with very different posterior variances, and multimodality.

Initializing MCMC

Pathfinder can be used to initialize MCMC. This especially useful when sampling with Hamiltonian Monte Carlo. See Initializing HMC with Pathfinder for details.

Integration with the Julia ecosystem

Pathfinder uses several packages for extended functionality:

  • Optimization.jl: This allows the L-BFGS optimizer to be replaced with any of the many Optimization-compatible optimizers and supports use of callbacks. Note that any changes made to Pathfinder using these features would be experimental.
  • Transducers.jl: parallelization support
  • Distributions.jl/PDMats.jl: fits can be used anywhere a Distribution can be used
  • LogDensityProblems.jl: defining the log-density function, gradient, and Hessian
  • ProgressLogging.jl: In Pluto, Juno, and VSCode, nested progress bars are shown. In the REPL, use TerminalLoggers.jl to get progress bars.
  • Zhang2021Lu Zhang, Bob Carpenter, Andrew Gelman, Aki Vehtari (2021). Pathfinder: Parallel quasi-Newton variational inference. arXiv: 2108.03782 [stat.ML]. Code
diff --git a/dev/lib/internals/index.html b/dev/lib/internals/index.html index f4d0409c..90989668 100644 --- a/dev/lib/internals/index.html +++ b/dev/lib/internals/index.html @@ -23,4 +23,4 @@ \end{align}\]

source
Pathfinder.lbfgs_inverse_hessiansMethod
lbfgs_inverse_hessians(
     θs, ∇logpθs; Hinit=gilbert_init, history_length=5, ϵ=1e-12
 ) -> Tuple{Vector{WoodburyPDMat},Int}

From an L-BFGS trajectory and gradients, compute the inverse Hessian approximations at each point.

Given positions θs with gradients ∇logpθs, construct LBFGS inverse Hessian approximations with the provided history_length.

The 2nd returned value is the number of BFGS updates to the inverse Hessian matrices that were rejected due to keeping the inverse Hessian positive definite.

source
Pathfinder.pdfactorizeMethod
pdfactorize(A, B, D) -> WoodburyPDFactorization

Factorize the positive definite matrix $W = A + B D B^\mathrm{T}$.

The result is the "square root" factorization (L, R), where $W = L R$ and $L = R^\mathrm{T}$.

Let $U^\mathrm{T} U = A$ be the Cholesky decomposition of $A$, and let $Q X = U^{-\mathrm{T}} B$ be a thin QR decomposition. Define $C = I + XDX^\mathrm{T}$, with the Cholesky decomposition $V^\mathrm{T} V = C$. Then, $W = R^\mathrm{T} R$, where

\[R = \begin{pmatrix} U & 0 \\ 0 & I \end{pmatrix} Q^\mathrm{T} V.\]

The positive definite requirement is equivalent to the requirement that both $A$ and $C$ are positive definite.

For a derivation of this decomposition for the special case of diagonal $A$, see appendix A of [Zhang2021].

See pdunfactorize, WoodburyPDFactorization, WoodburyPDMat

source
Pathfinder.pdunfactorizeMethod
pdunfactorize(F::WoodburyPDFactorization) -> (A, B, D)

Perform a reverse operation to pdfactorize.

Note that this function does not compute the inverse of pdfactorize. It only computes matrices that produce the same matrix $W = A + B D B^\mathrm{T}$ as for the inputs to pdfactorize.

source
Pathfinder.resampleMethod
resample(rng, x, log_weights, ndraws) -> (draws, psis_result)
-resample(rng, x, ndraws) -> draws

Draw ndraws samples from x, with replacement.

If log_weights is provided, perform Pareto smoothed importance resampling.

source
+resample(rng, x, ndraws) -> draws

Draw ndraws samples from x, with replacement.

If log_weights is provided, perform Pareto smoothed importance resampling.

source
diff --git a/dev/lib/public/index.html b/dev/lib/public/index.html index bc5f0054..bb119643 100644 --- a/dev/lib/public/index.html +++ b/dev/lib/public/index.html @@ -2,4 +2,4 @@ Public · Pathfinder.jl

Public Documentation

Documentation for Pathfinder.jl's public interface.

See the Internals section for documentation of internal functions.

Index

Public Interface

Pathfinder.pathfinderFunction
pathfinder(ℓ; kwargs...)
 pathfinder(fun::SciMLBase::OptimizationFunction; kwargs...)
 pathfinder(prob::SciMLBase::OptimizationProblem; kwargs...)

Find the best multivariate normal approximation encountered while maximizing a log density.

From an optimization trajectory, Pathfinder constructs a sequence of (multivariate normal) approximations to the distribution specified by a log density function. The approximation that maximizes the evidence lower bound (ELBO), or equivalently, minimizes the KL divergence between the approximation and the true distribution, is returned.

The covariance of the multivariate normal distribution is an inverse Hessian approximation constructed using at most the previous history_length steps.

Arguments

  • : an object, representing the log-density of the target distribution and its gradient, that implements the LogDensityProblems interface.
  • fun::SciMLBase.OptimizationFunction: an optimization function that represents the negative log density with its gradient. It must have the necessary features (e.g. a Hessian function, if applicable) for the chosen optimization algorithm. For details, see Optimization.jl: OptimizationFunction.
  • prob::SciMLBase.OptimizationProblem: an optimization problem containing a function with the same properties as fun, as well as an initial point, in which case init and dim are ignored.

Keywords

  • dim::Int: dimension of the target distribution, needed only if fun is provided and init is not.
  • init::AbstractVector{<:Real}: initial point of length dim from which to begin optimization. If not provided, an initial point of type Vector{Float64} and length dim is created and filled using init_sampler.
  • init_scale::Real: scale factor $s$ such that the default init_sampler samples entries uniformly in the range $[-s, s]$
  • init_sampler: function with the signature (rng, x) -> x that modifies a vector of length dims in-place to generate an initial point
  • ndraws_elbo::Int=5: Number of draws used to estimate the ELBO
  • ndraws::Int=ndraws_elbo: number of approximate draws to return
  • rng::Random.AbstractRNG: The random number generator to be used for drawing samples
  • executor::Transducers.Executor=Transducers.SequentialEx(): Transducers.jl executor that determines if and how to perform ELBO computation in parallel. The default (SequentialEx()) performs no parallelization. If rng is known to be thread-safe, and the log-density function is known to have no internal state, then Transducers.PreferParallel() may be used to parallelize log-density evaluation. This is generally only faster for expensive log density functions.
  • history_length::Int=6: Size of the history used to approximate the inverse Hessian.
  • optimizer: Optimizer to be used for constructing trajectory. Can be any optimizer compatible with Optimization.jl, so long as it supports callbacks. Defaults to Optim.LBFGS(; m=history_length, linesearch=LineSearches.MoreThuente()). See the Optimization.jl documentation for details.
  • ntries::Int=1_000: Number of times to try the optimization, restarting if it fails. Before every restart, a new initial point is drawn using init_sampler.
  • fail_on_nonfinite::Bool=true: If true, optimization fails if the log-density is a NaN or Inf or if the gradient is ever non-finite. If nretries > 0, then optimization will be retried after reinitialization.
  • kwargs... : Remaining keywords are forwarded to Optimization.solve.

Returns

source
Pathfinder.PathfinderResultType
PathfinderResult

Container for results of single-path Pathfinder.

Fields

  • input: User-provided input object, e.g. a LogDensityProblem, optim_fun, optim_prob, or another object.
  • optimizer: Optimizer used for maximizing the log-density
  • rng: Pseudorandom number generator that was used for sampling
  • optim_prob::SciMLBase.OptimizationProblem: Otimization problem used for optimization
  • logp: Log-density function
  • fit_distribution::Distributions.MvNormal: ELBO-maximizing multivariate normal distribution
  • draws::AbstractMatrix{<:Real}: draws from multivariate normal with size (dim, ndraws)
  • fit_distribution_transformed: fit_distribution transformed to the same space as the user-supplied target distribution. This is only different from fit_distribution when integrating with other packages, and its type depends on the type of input.
  • draws_transformed: draws transformed to be draws from fit_distribution_transformed.
  • fit_iteration::Int: Iteration at which ELBO estimate was maximized
  • num_tries::Int: Number of tries until Pathfinder succeeded
  • optim_solution::SciMLBase.OptimizationSolution: Solution object of optimization.
  • optim_trace::Pathfinder.OptimizationTrace: container for optimization trace of points, log-density, and gradient. The first point is the initial point.
  • fit_distributions::AbstractVector{Distributions.MvNormal}: Multivariate normal distributions for each point in optim_trace, where fit_distributions[fit_iteration + 1] == fit_distribution
  • elbo_estimates::AbstractVector{<:Pathfinder.ELBOEstimate}: ELBO estimates for all but the first distribution in fit_distributions.
  • num_bfgs_updates_rejected::Int: Number of times a BFGS update to the reconstructed inverse Hessian was rejected to keep the inverse Hessian positive definite.

Returns

source
Pathfinder.multipathfinderFunction
multipathfinder(ℓ, ndraws; kwargs...)
-multipathfinder(fun::SciMLBase.OptimizationFunction, ndraws; kwargs...)

Run pathfinder multiple times to fit a multivariate normal mixture model.

For nruns=length(init), nruns parallel runs of pathfinder produce nruns multivariate normal approximations $q_k = q(\phi | \mu_k, \Sigma_k)$ of the posterior. These are combined to a mixture model $q$ with uniform weights.

$q$ is augmented with the component index to generate random samples, that is, elements $(k, \phi)$ are drawn from the augmented mixture model

\[\tilde{q}(\phi, k | \mu, \Sigma) = K^{-1} q(\phi | \mu_k, \Sigma_k),\]

where $k$ is a component index, and $K=$ nruns. These draws are then resampled with replacement. Discarding $k$ from the samples would reproduce draws from $q$.

If importance=true, then Pareto smoothed importance resampling is used, so that the resulting draws better approximate draws from the target distribution $p$ instead of $q$. This also prints a warning message if the importance weighted draws are unsuitable for approximating expectations with respect to $p$.

Arguments

  • : an object, representing the log-density of the target distribution and its gradient, that implements the LogDensityProblems interface.
  • fun::SciMLBase.OptimizationFunction: an optimization function that represents a negative log density with its gradient. It must have the necessary features (e.g. a Hessian function) for the chosen optimization algorithm. For details, see Optimization.jl: OptimizationFunction.
  • ndraws::Int: number of approximate draws to return

Keywords

  • init: iterator of length nruns of initial points of length dim from which each single-path Pathfinder run will begin. length(init) must be implemented. If init is not provided, nruns must be, and dim must be if fun provided.
  • nruns::Int: number of runs of Pathfinder to perform. Ignored if init is provided.
  • ndraws_per_run::Int: The number of draws to take for each component before resampling. Defaults to a number such that ndraws_per_run * nruns > ndraws.
  • importance::Bool=true: Perform Pareto smoothed importance resampling of draws.
  • rng::AbstractRNG=Random.GLOBAL_RNG: Pseudorandom number generator. It is recommended to use a parallelization-friendly PRNG like the default PRNG on Julia 1.7 and up.
  • executor::Transducers.Executor=Transducers.SequentialEx(): Transducers.jl executor that determines if and how to run the single-path runs in parallel. If a transducer for multi-threaded computation is selected, you must first verify that rng and the log density function are thread-safe.
  • executor_per_run::Transducers.Executor=Transducers.SequentialEx(): Transducers.jl executor used within each run to parallelize PRNG calls. Defaults to no parallelization. See pathfinder for a description.
  • kwargs... : Remaining keywords are forwarded to pathfinder.

Returns

source
Pathfinder.MultiPathfinderResultType
MultiPathfinderResult

Container for results of multi-path Pathfinder.

Fields

  • input: User-provided input object, e.g. either logp, (logp, ∇logp), optim_fun, optim_prob, or another object.
  • optimizer: Optimizer used for maximizing the log-density
  • rng: Pseudorandom number generator that was used for sampling
  • optim_prob::SciMLBase.OptimizationProblem: Otimization problem used for optimization
  • logp: Log-density function
  • fit_distribution::Distributions.MixtureModel: uniformly-weighted mixture of ELBO- maximizing multivariate normal distributions from each run.
  • draws::AbstractMatrix{<:Real}: draws from fit_distribution with size (dim, ndraws), potentially resampled using importance resampling to be closer to the target distribution.
  • draw_component_ids::Vector{Int}: component id of each draw in draws.
  • fit_distribution_transformed: fit_distribution transformed to the same space as the user-supplied target distribution. This is only different from fit_distribution when integrating with other packages, and its type depends on the type of input.
  • draws_transformed: draws transformed to be draws from fit_distribution_transformed.
  • pathfinder_results::Vector{<:PathfinderResult}: results of each single-path Pathfinder run.
  • psis_result::Union{Nothing,<:PSIS.PSISResult}: If importance resampling was used, the result of Pareto-smoothed importance resampling. psis_result.pareto_shape also diagnoses whether draws can be used to compute estimates from the target distribution. See PSIS.PSISResult for details
source
+multipathfinder(fun::SciMLBase.OptimizationFunction, ndraws; kwargs...)

Run pathfinder multiple times to fit a multivariate normal mixture model.

For nruns=length(init), nruns parallel runs of pathfinder produce nruns multivariate normal approximations $q_k = q(\phi | \mu_k, \Sigma_k)$ of the posterior. These are combined to a mixture model $q$ with uniform weights.

$q$ is augmented with the component index to generate random samples, that is, elements $(k, \phi)$ are drawn from the augmented mixture model

\[\tilde{q}(\phi, k | \mu, \Sigma) = K^{-1} q(\phi | \mu_k, \Sigma_k),\]

where $k$ is a component index, and $K=$ nruns. These draws are then resampled with replacement. Discarding $k$ from the samples would reproduce draws from $q$.

If importance=true, then Pareto smoothed importance resampling is used, so that the resulting draws better approximate draws from the target distribution $p$ instead of $q$. This also prints a warning message if the importance weighted draws are unsuitable for approximating expectations with respect to $p$.

Arguments

Keywords

Returns

source
Pathfinder.MultiPathfinderResultType
MultiPathfinderResult

Container for results of multi-path Pathfinder.

Fields

  • input: User-provided input object, e.g. either logp, (logp, ∇logp), optim_fun, optim_prob, or another object.
  • optimizer: Optimizer used for maximizing the log-density
  • rng: Pseudorandom number generator that was used for sampling
  • optim_prob::SciMLBase.OptimizationProblem: Otimization problem used for optimization
  • logp: Log-density function
  • fit_distribution::Distributions.MixtureModel: uniformly-weighted mixture of ELBO- maximizing multivariate normal distributions from each run.
  • draws::AbstractMatrix{<:Real}: draws from fit_distribution with size (dim, ndraws), potentially resampled using importance resampling to be closer to the target distribution.
  • draw_component_ids::Vector{Int}: component id of each draw in draws.
  • fit_distribution_transformed: fit_distribution transformed to the same space as the user-supplied target distribution. This is only different from fit_distribution when integrating with other packages, and its type depends on the type of input.
  • draws_transformed: draws transformed to be draws from fit_distribution_transformed.
  • pathfinder_results::Vector{<:PathfinderResult}: results of each single-path Pathfinder run.
  • psis_result::Union{Nothing,<:PSIS.PSISResult}: If importance resampling was used, the result of Pareto-smoothed importance resampling. psis_result.pareto_shape also diagnoses whether draws can be used to compute estimates from the target distribution. See PSIS.PSISResult for details
source
diff --git a/dev/search/index.html b/dev/search/index.html index 8c48a713..5862d1b9 100644 --- a/dev/search/index.html +++ b/dev/search/index.html @@ -1,2 +1,2 @@ -Search · Pathfinder.jl

Loading search...

    +Search · Pathfinder.jl

    Loading search...