top of page


In order to run the examples shown here you will need to install the packages listed bellow. 

The book provides code in R, JAGS, Python and Stan, and for the examples we mainly used R+JAGS and Python+Stan. Apart from the more advanced examples of Chapter 10, having one of these configurations allows you to run the examples yourself and understand how to modify the code to your needs. 


If you wish to compare implementations or are proficient in one of the languages and willing to dive into the other, you will require all the resources listed below.


Just Another Gibbs Sampler


- R2jags

- lattice

- ggplot2

- MCMCpack

- mcmcplots



- RStudio

- rstan


- matplotlib

- numpy

- pandas

- pymc3

- pystan

- scipy

- statsmodels



- IPython

Important remarks:

- The code available in this site corresponds to the code in the first edition of Bayesian Models for Astrophysical Data - using R, JAGS, Python and Stan by Hilbe, de Souza and Ishida, Cambridge University Press, 2017. If you use this material in a publication, you are kindly asked to include the appropriate citation (click here for bibtex entry).

- On the CONTENTS+CODE page, we provide a link to every instance of code (just click on the underlined code number and you will be directed to the corresponding static code).

- Each code page contains a                             button, which will take you to the updated github version of the code. 

- The official repository hosting all the code presented in the book and the corresponding licence  is

- Some of the models presented may be time consuming for a user working on a standard personal computer. Whenever this is the case, you will find the symbol          in the top right corner of the page.  

- Copying and pasting code from this page may lead to errors due to the interpretation of blank lines and/or TABS by some environments. We advise the reader to use this page as a reference but restrict copy/paste exercises to the code from the github repository. 

- We offer our sincere apologies for all errors in the text, for which we are fully responsible. We would also like to thank everyone who has taken the time to alert us to our mistakes. You can access the list of corrections on the ERRATUM page.

get source
bottom of page