Gibbs sampling is a Markov chain Monte Carlo technique for drawing samples from a multivariate joint distribution by iteratively sampling from conditional distributions of each variable given the current values of all other variables, making it particularly useful for high-dimensional problems where direct simulation or other methods like accept-reject or Metropolis-Hastings are impractical.
Gibbs Sampling Explained: Conditional Distributions for Bayesian Inference
Added:Hello, this is Jared Nami with a mini lecture on Gibbs sampling.
All right, so previously we've talked about trying to sample from univariate distributions. Most of the methods that we talked about could be generalized to multivariate distributions. We just haven't done so. Today or right now we're going to make explicit trying to draw from this bariate distribution for theta 1 and theta 2.
Um but we're going to think of situations where it's not practical to do direct simulation from this joint distribution or using accept reject or metropolis Hastings. Um but we're going to consider a situation where we can sample from the conditional distributions for theta 1 given theta 2 and for theta 2 given theta 1. So if you can sample from these two distributions then you can use something called gib sampling.
All right. So we have the exactly the same setup. We've got a joint distribution for theta 1 and theta 2. we can sample from their two conditional distributions. Uh and we're going to start with initial value for theta 1 and theta 2 with the superscript zero.
So this the Gibb sampler is going to say all right at iteration J draw from the conditional distribution for theta 1 conditional on the previous value for theta 2 and then turn around and sample a value for theta 2 from the full conditional distribution for theta 2 given theta 1 that you just drew.
All right. And this is the gib sampler.
All right. So it's another Markov chain just like the Metropolis Hastings algorithm created and so it has the same results that that algorithm had in particular that this theta J vector which has components theta 1 and theta 2 converges in distribution to a draw from the joint distribution that you're interested in namely one that has the joint distribution P theta 1 theta 2 it should be clear again that the theta J's is not an independent sequence. It is again a marov chain in that the draw at time j depended on what the prime was at draw j minus one.
But similar to the Matopoulos Hastings algorithm, we again uh under regularity conditions have a law of large numbers and central limit theorem that says that for any function that we're interested in, we can take the mean of that function over these samples and that does converge to the uh the expectation that we're interested in. I've changed the notation slightly here just to use the thetas that we've been using. And that p here is the joint distribution for theta 1 and theta 2. All right, so let's get to an example. The example we're going to use here for illustrative purposes is the bariate normal. So theta here is going to be a normal with dimension two. For simplicity, a mean of zero and a coariance matrix that has ones in the diagonal and has row that is the correlation between components theta 1 and theta 2.
All right, we can derive the the conditional distributions for this model. namely theta 1 given theta 2 we have a mean that's shrunk back towards zero I guess assuming that row is between uh 0 and one and we have a a variance here and we have exactly a symmetric distribution here for theta 2 given theta 1 and these are the two conditional distributions for theta 1 given theta 2 and then theta 2 given theta 1 that will be necessary for the gib sampler. So the way that the Gibb sampler is going to work is that we're again going to start with an initial value and at the first iteration we're going to sample theta 1 conditional on this current value for theta 2 and then we're going to turn around and sample theta 2 given the conditional distribution for theta 1 that we just drew.
All right, we repeat this procedure many times. So generically at iteration K, we use the value for theta 2 at k minus one and then we use the value uh for theta 1 at K to draw theta 2.
All right, so that's the example. Here's an illustration of that example in practice. Here's the a biaried normal with a correlation of 0.9. And we're going to start out here at the value minus 33.
So the first thing that we're going to do is find the full conditional distribution for theta 1 conditional on this current value for theta 2. So that is we're going to draw a slice at theta 2= 3 and we're going to find that conditional distribution for theta 1 which turns out as we saw in the last page to be a normal distribution and we're going to sample from it. So this gray line here indicates that we've moved theta 1 from the value it was of minus3 up to a value of about 2.3.
Now we're going to turn around and do exactly the same thing, but now we're going to condition on the value for theta 1 of about 2.3.
And we're going to fake the full conditional distribution for theta 2 conditional on that value for theta 1 and sample from it. Again, it's a normal distribution easy to sample from. And now we have our new point here. This here is the now the at iteration one the value for theta 1 and theta 2. We can repeat this procedure again and again.
And what we see is that we're slowly moving toward the mass of this posterior distribution or of this joint distribution for theta 1 and theta 2.
Right? What we want to see are points that are sampled among these ellipses.
So if we repeat this procedure a whole bunch of times, this is what we see.
All right. So this was an example so far of a bariate normal. We can have a k component gib sampler. That is if we can break down the theta vector into k different components, we can create a gibb sampler for those k components.
It's going to have capital k steps. And here are the steps. The first step is to draw theta 1 condition on the value for theta 2 up to theta k from the previous iteration.
Now we're going to draw a value for theta 2. And we're going to use that value we just drew for theta 1, but we're going to use the previous iteration's value for theta 3 up to theta k.
So generically at at step K within this iteration of the Gibb sampler, we're going to use the newly updated values for all the parameters for theta 1 up to theta k minus one from this iteration. And then we're going to use the values for theta k + 1 up to theta k from the previous iteration.
We can conclude this iteration by drawing the last step conditional on last step that is for theta k conditional on all the updated values for theta 1 up to theta k minus one.
These distributions here are all are called the full conditional distributions. That is they're the distributions that are conditional on everything except for the parameter that we're trying to draw. And when constructing and gib samplers these full conditional distributions that are necessary now I've been thinking about this or I've been describing this problem where theta 1 up to theta k are going to be scalers but that's not necessary. Theta 1 could be bari triariat could have arbitrarily large dimension as long as you can sample from its full conditional distribution.
So the gib sample is a very versatile uh sampling mechanism as long as you can construct the full conditional distribution.
All right. So in summary, the Gibb samplers can be used to draw samples from this joint distribution for theta and you want to use it when other methods don't work well. But this is typically going to happen in high dimensions. That is in theory you can construct accept rejection samplers in high dimensions but the rejection rate is going to tend to be very large.
Um, similarly, Metropolis Hastings algorithm, it's going to be hard to construct a good proposal in high dimensions.
And all you need in order to do to construct a Gibb sampler is to be able to draw samples from the full conditional distributions for a component theta K given all the other components. The shorthand notation here is for all the components except for K.
Up Next

Metropolis-Hastings Algorithm: An Introduction to MCMC Sampling
@jaradniemi
86.8K views•2013-03-03

Gain Recalibration in Hippocampal Path Integration: Math Theory
@1024kyz
144 views•2020-07-02

Fourier Series Introduction: The Big Idea Explained
@DrTrefor
387K views•2021-05-03

The Mathematical Impossibility of Accurate World Maps
@Vox
23.3M views•2016-12-02
Related Study Plans & Knowledge Roadmaps
Structured learning paths in Mathematics







































