{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "\n", "# Gibbs sampling\n", "\n", "In this notebook, we show how to use CUQIpy to sample hierarchical Bayesian models using Gibbs sampling.\n", "\n", "Gibbs sampling is a Markov chain Monte Carlo (MCMC) method for sampling a joint probability distribution of multiple random variables.\n", "Instead of sampling all variables simultaneously, Gibbs sampling samples the variables sequentially. The sampling of each variable is achieved by sampling from the conditional distribution of that variable given (fixed, previously sampled) values of the other variables.\n", "\n", "Gibbs sampling is often an efficient way of sampling from a joint distribution if the conditional distributions are easy to sample from. On the other hand, if the conditional distributions are highly correlated and/or are difficult to sample from, then Gibbs sampling can be very inefficient. For these reasons, Gibbs sampling is often a double-edged sword that needs to be used in the right context.\n", "\n", "## Learning objectives\n", "\n", "Going through this notebook you will see how to:\n", "\n", "- Describe the basic idea of Gibbs sampling.\n", "- Define a hierarchical Bayesian model using CUQIpy.\n", "- Define a Gibbs sampling scheme in CUQIpy.\n", "- Run the Gibbs sampler and analyze the results.\n", "\n", "## Table of contents\n", "\n", "1. [The basics of Gibbs sampling](#basics)\n", "2. [Gibbs for inverse problems](#inverse)\n", "3. [Exploring other priors](#exploring-other-priors)\n", "4. [Connection to BayesianProblem class](#BayesianProblem)\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
cuqi.experimental.mcmc
module, which are expected to become the default soon. Check out the documentation for more details.\n",
"