Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Fig 7.4 (Book2) add hmc_beta_binom_blackjax.ipynb #94

Merged
merged 1 commit into from
Apr 23, 2022

Conversation

karm-patel
Copy link
Contributor

@karm-patel karm-patel commented Apr 23, 2022

Description

Reproduced HMC approximation for coin-toss problem using Blackjax from https://github.com/probml/probml-notebooks/blob/main/notebooks/beta_binom_approx_post_pymc.ipynb

Colab link

colab

Issue

probml/pyprobml#737

Steps

  • followed PEP8 convention and latexified the figure

Figures

Book2 - Figure 7.2

Checklist:

  • Performed a self-review of the code
  • Tested on Google Colab.

Potential problems/Important remarks

  • I have kept common legend for the both figure due to less space in 2nd subfigure.

c.c. - Dr. @murphyk, Prof. @nipunbatra, @patel-zeel

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@nipunbatra
Copy link

I had a few questions/suggestions. I don't think they would change the notebook content, but, perhaps would be good to know and I'm sure would be useful for other more advanced MCMC examples.

  • Can we figure out the "acceptance" ratio? This nice blogpost from Colin Caroll says that PyMC generally aims for ~65% acceptance ratio for HMC and 85% for NUTS.
  • This 1d problem is fairly trivial one and perhaps does not need to account for "burn-in". The trace plot also seems to indicate that we enter the high probability region right from the outset. Perhaps we can look at some diagnostics or maybe just consider first few (say 100 ) samples for burn-in?
  • Perhaps we can look at some statistics/diagnostics to confirm the convergence?
  • It may be a fun exercise to try and replicate this video from Colin's blog post for the simpler 1d beta-binomial coin toss example.

@murphyk
Copy link
Member

murphyk commented Apr 23, 2022

The current colab looks fine. But the things Nipun mentioned would indeed be nice extensions.
I guess there is an editorial decision we need to make - do we (1) put all this good stuff (like convergence diagmostics) in this notebook, or do we (2) save that for the MCMC chapter in the code-first book, and keep the current figure notebook short and sweet? I am inclined towards option 2...

@nipunbatra
Copy link

Yeah, I was also thinking this after posting my message. I think as long as the examples are relatively simple (like beta-binomial), there's nothing much to gain by diving deeper to check for convergence, etc. As such this was the conjugate case, so matching the true posterior (which we do) looks enough.

So, it seems we can stick with option 2 unless there's a non-trivial example (and can revisit this discussion if we get there) where we indeed need diagnostics.

@murphyk
Copy link
Member

murphyk commented Apr 23, 2022

Agreed. Let me merge this. Karm can make new demos for sec 11.6.2 "Practical convergence diagnostics".
I already have a bunch of figures made using numpyro, which may not be worth remaking, but for code-first book, we want to roll everything ourselves from the ground up :)

@murphyk murphyk merged commit 8d4a02c into probml:main Apr 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants