ArticleslgStudy

science

Gibbs sampling

Gibbs sampling is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Gibbs sampling rather than just read about it. In short: In statistics, Gibbs sampling or a Gibbs sampler, also known in statistical mechanics as the heat bath algorithm, is a Markov chain Monte Carlo (MCMC) algorithm for sampling from a specified multivariate probability distribution when direct sampling from the joint distribution is difficult, but sampling from the conditional distribution is more practical. This sequence can be used to approximate the joint distributi…

Gibbs sampling — main illustration
Gibbs sampling — illustration

Key takeaways

  • Gibbs sampling belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Gibbs sampling to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Gibbs sampling from memory before moving on to harder problems.

Reference excerpt

In statistics, Gibbs sampling or a Gibbs sampler, also known in statistical mechanics as the heat bath algorithm, is a Markov chain Monte Carlo (MCMC) algorithm for sampling from a specified multivariate probability distribution when direct sampling from the joint distribution is difficult, but sampling from the conditional distribution is more practical. This sequence can be used to approximate the joint distribution (e.g., to generate a histogram of the distribution); to approximate the marginal distribution of one of the variables, or some subset of the variables (for example, the unknown parameters or latent variables); or to compute an integral (such as the expected value of one of the variables). Typically, some of the variables correspond to observations whose values are known, and hence do not need to be sampled. Gibbs sampling is commonly used as a means of statistical inference, especially Bayesian inference. It is a randomized algorithm (i.e. an algorithm that makes use of random numbers), and is an alternative to deterministic algorithms for statistical inference such as the expectation–maximization algorithm (EM). As with other MCMC algorithms, Gibbs sampling generates a Markov chain of samples, each of which is correlated with nearby samples. As a result, care must be taken if independent samples are desired. Samples from the beginning of the chain (the burn-in period) may not accurately represent the desired distribution and are usually discarded.

Introduction Gibbs sampling is named after the physicist Josiah Willard Gibbs, in reference to an analogy between the sampling algorithm and statistical physics. The algorithm was described by brothers Stuart and Donald Geman in 1984, some eight decades after the death of Gibbs, and became popularized in the statistics community for calculating marginal probability distribution, especially the posterior distribution. In its basic version, Gibbs sampling is a special case of the Metropolis–Hastings algorithm. However, in its extended versions (see below), it can be considered a general framework for sampling from a large set of variables by sampling each variable (or in some cases, each group of variables) in turn, and can incorporate the Metropolis–Hastings algorithm (or methods such as slice sampling) to implement one or more of the sampling steps. Gibbs sampling is applicable when the joint distribution is not known explicitly or is difficult to sample from directly, but the conditional distribution of each variable is known and is easy (or at least, easier) to sample from. The Gibbs sampling algorithm generates an instance from the distribution of each variable in turn, conditional on the current values of the other variables. It can be shown that the sequence of samples constitutes a Markov chain, and the stationary distribution of that Markov chain is just the sought-after joint distribution. Gibbs sampling is particularly well-adapted to sampling the posterior distribution of a Bayesian network, since Bayesian networks are typically specified as a collection of conditional distributions.

Implementation Gibbs sampling, in its basic incarnation, is a special case of the Metropolis–Hastings algorithm. The point of Gibbs sampling is that given a multivariate distribution it is simpler to sample from a conditional distribution than to marginalize by integrating over a joint distribution. Suppose we want to obtain k {\displaystyle k} samples of a n {\displaystyle n} -dimensional random vector X = ( X 1 , … , X n ) {\displaystyle \mathbf {X} =(X_{1},\dots ,X_{n})} . We proceed iteratively:

… excerpt ends here. Continue reading the full article.

Illustrations

Gibbs sampling: A pictorial description of the Gibbs sampling algorithm [4]
A pictorial description of the Gibbs sampling algorithm [4]
Gibbs sampling: Schematic description of the information equality associated with the Gibbs sampler at the i-th step within a cycle [4]
Schematic description of the information equality associated with the Gibbs sampler at the i-th step within a cycle [4]

Worked examples

Example 1 — a first encounter with Gibbs sampling

Start with the simplest possible case. Write down what Gibbs sampling claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Gibbs sampling before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Gibbs sampling ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Gibbs sampling

In research
Gibbs sampling appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Gibbs sampling in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Gibbs sampling is common in secondary-school and first-year university syllabi. It links to neighbouring topics Markov chain Monte Carlo, so understanding it makes those chapters shorter.
In everyday life
Look for Gibbs sampling outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study Gibbs sampling in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Gibbs sampling means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Gibbs sampling out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Gibbs sampling in simple terms?

In statistics, Gibbs sampling or a Gibbs sampler, also known in statistical mechanics as the heat bath algorithm, is a Markov chain Monte Carlo (MCMC) algorithm for sampling from a specified multivariate probability distribution when direct sampling from the joint distribution is difficult, but sam…

Why does Gibbs sampling matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Gibbs sampling?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Gibbs sampling.

Tags

  • Markov chain Monte Carlo

Keep exploring