Learning Bayesian Statistics

← Learning Bayesian Statistics13 août · 1 h 24 min

#163 How to make your models sample faster, with Adrian Seyboldt & Eliot Carlson

#163 How to make your models sample faster, with Adrian Seyboldt & Eliot Carlson13 août1 h 24 min

<p><b>Support &amp; Resources</b><br />→ Support the show on <a rel="noopener noreferrer nofollow" href="https://www.patreon.com/c/learnbayesstats" target="_blank">Patreon</a><br />→ <a rel="noopener noreferrer nofollow" href="https://topmate.io/alex_andorra/1011122" target="_blank">Bayesian Modeling Course</a> (first 2 lessons free)<br /><br />Our theme music is « Good Bayesian », by Baba Brinkman (feat MC Lars and Mega Ran). Check out his<a rel="noopener noreferrer nofollow" href="https://bababrinkman.com/" target="_blank"> awesome work</a></p><p><br />Takeaways:<br /><br />Q: What is mass matrix adaptation, in plain terms?<br />A: Mass matrix adaptation is best understood as an automatic, fairly dumb, but very effective reparameterization of your model. The simplest version, the diagonal mass matrix, just rescales each parameter so its posterior standard deviation becomes one, which is exactly what you'd do by hand if you had the patience. Every time you sample a PyMC or Stan model, this kind of reparameterization is happening under the hood.<br /><br />Q: How does Nutpie's approach to mass matrix adaptation differ from Stan and PyMC's default?<br />A: Stan and PyMC's default sampler only use one source of information for diagonal mass matrix adaptation: the posterior standard deviation estimated from warm-up draws. Nutpie also uses the gradients of the log density, which HMC is already computing at every step to build its trajectory. For a standard normal distribution, the covariance of the gradients is exactly the inverse covariance of the draws, so Nutpie takes the geometric mean of the two resulting standard deviations. There's no guarantee it's always better, but in practice it usually is.<br /><br />Q: What problem does "Preconditioning Hamiltonian Monte Carlo by Minimizing Fisher Divergence" actually solve?<br />A: Preconditioning HMC means transforming your target distribution into one that's friendly to sample, but doing that well requires knowing things about the distribution, like its covariance, that sampling itself is supposed to discover. This chicken-and-egg problem is usually handled by sketching a rough estimate from a handful of early warm-up draws, which can burn a large share of total sampling time. Adrian and Eliot's paper formalizes how to make better use of a second signal, the score function, that HMC already computes for free but that Stan-style preconditioning ignores.<br /><br /><br />Chapters:<br />00:00:00 What is HMC precon