Blocked Gibbs sampler 2026-10-06
A blocked Gibbs sampler draws groups of coordinates jointly from their full conditional distributions. Each update preserves the joint probability distribution; dependence between blocks can still cause a long mixing time.
Checkerboard Gibbs sampling Created 2026-10-07 Updated 2026-11-05
For a Markov random field whose positive probability density function factors into single-vertex and pairwise edge factors on a bipartite graph, variables in one color class are conditionally independent given the other color. A checkerboard Gibbs sampler therefore draws every black variable from its full conditional distribution in parallel, then every white variable conditional on the newly drawn blacks. Each color update is a blocked Gibbs sampler preserving the joint target, and their composition preserves it too.
Bipartiteness of a displayed pixel-neighbour graph is insufficient if the actual likelihood introduces factors coupling several same-color variables. For example, an observation depending jointly on two black neighbours can destroy their conditional independence. The conditional factorization of the posterior, rather than the picture alone, justifies the parallel updates.
A single-coordinate Gibbs sampler update preserves the remaining coordinates and independently redraws the selected coordinate from its full conditional distribution. The joint measure of old and new states factors into a marginal and two identical conditional factors, making it symmetric. A fixed-probability mixture of such kernels therefore satisfies detailed balance.
Full conditional distribution Created 2026-09-28 Updated 2026-11-05
A Full conditional distribution is the conditional law of one component of a joint model given all the other components and the observed data. A Gibbs sampler updates components by drawing from these laws.
A Gamma–Poisson hierarchical model uses , , and , with gamma distributions in shape-rate convention. Conditional independence gives full conditional distributions and .
Gaussian change-point Gibbs updates Created 2026-10-14 Updated 2026-11-05
For independent means and , the first mean's conditional precision is and conditional precision-weighted mean is ; replace by for the second mean. With its conditional law is . The discrete split has conditional probabilities proportional to . These full conditional distributions give a Gibbs sampler including . Averaging the sampled indicators of that configuration estimates its probability; averaging its conditional probabilities gives an estimate by Rao-Blackwellization.
Take independent proper normal prior distributions for the two segment means and a proper inverse-gamma distribution for the common variance. A uniform prior distribution over may then retain the empty second segment. The posterior distribution is proper: its likelihood function is bounded above by , whose integral against is finite for . At the second mean has its unchanged proper prior distribution as its full conditional distribution. The configuration's posterior probability now has the meaningful interpretation of no change inside the observed sample.
Gaussian conjugacy for an initialized AR(2) regression Created 2026-10-06 Updated 2026-11-05
Condition on initial observations and model
with known and independent standard-normal prior distributions for . Put and . Gaussian conjugacy for a normal linear model gives posterior precision matrix and posterior mean
The prior distribution makes positive-definite even with a deficient design matrix. The unscaled sums occur specifically when .
If and , the two full conditional distributions have means and and variances and . These formulas use the conditional autoregressive model of order two likelihood function. Giving the initial pair its stationary law, or imposing a stationary-parameter restriction, changes that posterior distribution.
For a strictly positive posterior on finitely many binary spins, a Random-scan Gibbs sampler uses the two local posterior weights to redraw one spin. Positive full conditional distribution probabilities allow every finite sequence of spin changes, giving an irreducible Markov chain with positive self-transition probabilities.
Gibbs updates for a Poisson count change point Created 2026-10-14 Updated 2026-11-05
The full conditional distributions are and , in shape-rate notation. Conditional on the two rates, has weights . A Gibbs sampler cycles through these three draws. Each update preserves the joint posterior distribution; subtracting the largest log weight before exponentiation stabilizes the categorical draw. Averages of estimate the posterior probability of no observed change.
Latent-normal Gibbs sampler for probit regression Created 2026-10-07 Updated 2026-10-14
For binary observations with success probability , introduce latent and let the sign determine the observation. Given and the observed sign, each latent variable has a truncated normal distribution. With a standard normal prior, the full conditional distribution of is normal with precision and mean . Alternating these blocks is Gibbs sampling with the required marginal posterior.
When an observation mean depends on the neighboring spins, changing a spin affects observations centered at its neighbors. Its own observation need not involve that spin. Selecting precisely the affected factors gives a correct local full conditional distribution without recomputing the entire posterior.
Markov chain Monte Carlo Created 2026-09-24 Updated 2026-11-05
Markov chain Monte Carlo estimates expectations under a target probability distribution by simulating a Markov chain that preserves . For an integrable observable , the assumptions of a Markov-chain law of large numbers justify
almost surely. A Gibbs sampler preserves the target through full conditional distributions; a Metropolis–Hastings algorithm proposes a move and accepts or rejects it using a ratio of target and proposal densities. The unknown normalization constant cancels from that ratio, which makes unnormalized Bayesian posterior densities usable.
Successive states are generally dependent, so Monte Carlo precision depends on the observable's integrated autocorrelation time, rather than the raw iteration count alone. Burn-in can reduce initial-state effects but is not a proof of convergence. A correct stationary distribution also does not ensure rapid exploration: isolated modes or strong dependence can produce a long mixing time. Markov chain Monte Carlo convergence diagnostics investigate these limitations.
Metropolis-within-Gibbs algorithm Created 2026-10-14 Updated 2026-10-25
A Metropolis-within-Gibbs sweep updates one coordinate or block at a time by a Metropolis–Hastings algorithm transition whose invariant law is that block's full conditional distribution. For a proposal changing only block , the acceptance ratio uses the full joint target with the other coordinates fixed, together with the reverse/forward proposal ratio. Each block kernel preserves the joint posterior, so their composition does as well. Conjugate blocks can instead use exact Gibbs sampling draws. Systematic composition need not be reversible, even when every block kernel is reversible.
In a normal linear model , assign the coefficient vector a proper normal distribution with fixed positive-definite covariance matrix , independently of the variance , whose prior distribution is inverse-gamma distribution. Completing the square gives
Multiplying the residual likelihood function by the inverse-gamma distribution density also gives
These full conditional distributions permit a Gibbs sampler. The marginal coefficient posterior distribution is obtained by marginalization over . Its conditional mean and covariance matrix both depend on , so it is generally not a Student's t-distribution. Even if the columns of and the prior coordinates make the conditional coefficient components independent, averaging over a shared unknown need not preserve that independence.
A normal-inverse-gamma prior instead scales the conditional coefficient prior covariance matrix by , producing a multivariate Student's t-distribution on marginalization. It is a different joint prior distribution.
For the Metropolis–Hastings algorithm, start at a point with positive target probability density function. Draw from a proposal probability density function , generate an independent uniform distribution value , and set the next state to if
Otherwise retain , including that repeated state in the sample. Where a proposed forward move is possible but its reverse probability density function vanishes, its acceptance probability is zero. Unknown normalizing constants in cancel.
For distinct states, the accepted probability flow is
which is symmetric in . This detailed balance identity, together with the holding probability, proves that is invariant. Under appropriate irreducibility and aperiodicity conditions the chain converges to ; successive states are generally dependent.
The Gibbs sampler updates coordinates from their full conditional distributions. In a systematic sweep, draw successively
Each update preserves the target joint law: integrating the old coordinate against its conditional probability density function and replacing it by an independent draw from that same conditional leaves the joint probability density function unchanged. The composition of the coordinate updates therefore also preserves . A Gibbs sampler coordinate move can be regarded as a Metropolis–Hastings algorithm move with acceptance probability one. Systematic sweeps preserve stationarity but need not themselves be reversible. Initialization away from stationarity requires convergence before treating the draws as approximately target-distributed, and dependence must be accounted for in Monte Carlo method error estimates.
Both the Metropolis–Hastings algorithm and the Gibbs sampler construct a Markov chain with a specified target distribution, usually a posterior distribution known only up to normalization. For a proposal density and target density , the Metropolis–Hastings acceptance probability is
After drawing , move there with this probability; otherwise stay at . The unknown normalizing constant of cancels. The original Metropolis algorithm uses a symmetric proposal, , so the proposal-density ratio disappears. The general Metropolis–Hastings algorithm permits nonsymmetric proposals and needs that correction.
A Gibbs sampler instead chooses a coordinate or block and draws directly from its full conditional distribution, leaving the other coordinates fixed. It is exactly a conditional Metropolis–Hastings update whose proposal is that full conditional. For a change from to with fixed, the acceptance ratio is
Thus a Gibbs update is an always-accepted Metropolis–Hastings update with the full conditional as proposal. This statement concerns each update: a systematic sweep of several Gibbs kernels preserves the target but need not itself be reversible.
When the full conditional distributions are easy to sample, a Gibbs sampler avoids proposal tuning and rejection, and is particularly convenient for conjugate priors and data augmentation. When a conditional cannot be sampled directly, a Metropolis–Hastings algorithm can use only its evaluable density; such an update can also be inserted into a Gibbs sweep. Block or joint Metropolis–Hastings proposals can move efficiently along strongly correlated directions for which coordinate-wise Gibbs updates mix slowly. Conversely, a badly chosen Metropolis–Hastings proposal can reject most moves or make only tiny moves. Acceptance probability one by itself does not guarantee rapid exploration. Both methods require appropriate irreducibility and convergence checks before their long-run averages are useful posterior estimates.
The posterior kernel gives two gamma full conditional distributions directly:
with rates as the second parameters. For the index, terms independent of the proposed value cancel. Its conditional weights are
Define and . The normalized categorical probabilities are
Subtracting the largest log weight prevents needless numerical overflow, an application of the log-sum-exp function.
Precompute the cumulative counts . Initialize any and positive rates. At each iteration, draw from its gamma conditional given the current index, draw from its gamma conditional given that index, and draw a new index from the categorical probabilities using the newly drawn rates. Repeat and retain the parameter triples after initialization effects have diminished. These are the Gibbs updates for a Poisson count change point.
To verify invariance rather than just identify a sampler, a coordinate update integrates the old joint density as and replaces the first factor by an independent draw from the same conditional. The joint posterior distribution is therefore unchanged. The same argument applies to the other two updates, so their composition preserves the posterior. All gamma densities and all categorical weights are positive on their supports. The full-sweep transition density is consequently positive across the joint support, giving the usual irreducibility and aperiodicity conditions for this proper-posterior Gibbs sampler. This supports posterior long-run averages under the ergodic theorem for a positive Harris recurrent Markov chain.
The joint density factors as . In the full conditional distribution of , all factors not involving cancel. The remaining likelihood function and exponential distribution prior give
In shape–rate convention this is , a special case of the Gamma–Poisson hierarchical model. It depends only on the node's observed child and parent , as required for its Gibbs sampler update.