Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Advanced Inference

Contents

This section demonstrates Fugue's inference methods beyond adaptive MCMC:

Fugue's headline feature list advertises "Multiple Inference Methods: MCMC, SMC, Variational Inference, ABC." The Bayesian Coin Flip tutorial and most of the Statistical Modeling tutorials use adaptive_mcmc_chain. This section covers the other three, each on the same running example so you can compare their posteriors directly.

A gradient-based fifth option: HMC

Fugue also ships Hamiltonian Monte Carlo (hmc_chain), which mixes far better than single-site MH on correlated continuous posteriors by moving all continuous sites jointly using (finite-difference) gradient information. It isn't covered by its own tutorial page yet, but is fully documented — with a runnable example — in the hmc module rustdoc and listed alongside the other methods in the README.

The running example

All three tutorials in this section perform inference on the same conjugate Normal-Normal model, so their results are directly comparable:

Because both the prior and likelihood are Gaussian, the posterior has a closed form (precision-weighted combination of prior and likelihood):

Having ground truth in hand means each tutorial can check its inference method against an exact number instead of asking you to eyeball a histogram — the same property that makes each method's corresponding example (examples/smc_inference.rs, examples/abc_inference.rs, examples/vi_inference.rs) a genuine regression test rather than a "runs without panicking" demo.

When to reach for which method

MethodFunctionGood fit when...
MCMC (adaptive MH)adaptive_mcmc_chainGeneral-purpose default; works on discrete and continuous sites
HMChmc_chainContinuous, correlated posteriors where MH mixes slowly
SMCadaptive_smcYou also want a log-evidence estimate, or the posterior is multimodal/hard to reach by local moves
VIoptimize_meanfield_vi_with_configYou need speed over exactness, or a differentiable, tunable approximation
ABCabc_smc_weightedThe likelihood is intractable but you can simulate from the model

Try it yourself

cargo run --example smc_inference cargo run --example abc_inference cargo run --example vi_inference