Code

This page contains code snippets for algorithms in the book, sometimes in multiple languages. Click on the language icons to view and download the code.

Chapter 1 - The Bayesics

Chapter 2 - One-parameter models

Chapter 3 - Multi-parameter models

Chapter 4 - Priors

Chapter 5 - Regression

Chapter 6 - Prediction and Decision making

Chapter 7 - Normal posterior approximation

Chapter 8 - Classification

Chapter 9 - Gibbs sampling

Gibbs sampling - multivariate normal Gibbs sampling from a multivariate normal - Julia
Gibbs sampling - mixture of normals Gibbs sampling - mixture of normals - Julia Gibbs sampling - mixture of normals - R
Gibbs sampling - mixture of Poissons Gibbs sampling - mixture of Poissons - Julia
Gibbs sampling - probit regression Gibbs sampling - probit regression - Julia
Gibbs sampling - logistic regression Gibbs sampling - logistic regression - Julia
Gibbs sampling - autoregressive processes Gibbs sampling - AR processes - Julia

Chapter 10 - Markov Chain Monte Carlo simulation

Chapter 11 - Variational inference

Chapter 12 - Regularization

Gibbs sampling - linear regression with L2-regularization Gibbs sampling from a multivariate normal - Julia Gibbs sampling from a multivariate normal - R

Chapter 13 - Mixture models and Bayesian nonparametrics

Chapter 14 - Model comparison and variable selection

Chapter 15 - Gaussian processes

Chapter 16 - Interaction models

Chapter 17 - Dynamic models and sequential inference

Kalman filter and parameter estimation Gibbs sampling from a multivariate normal - Julia