Tutorials › Stochastic Processes › Target Distributions and Markov Chain Sampling

Markov Chain Monte Carlo · Tutorial 911 of 994

Target Distributions and Markov Chain Sampling

Learn how to express a target with or without its normalizing constant, and estimate a posterior event probability by averaging indicators along an MCMC chain.

Advanced 10 min read

What You'll Learn

  • Distinguish a normalized target distribution from unnormalized weights or a density.
  • Normalize a finite target and verify that its probabilities sum to one.
  • Express a posterior probability as a ratio that cancels an unknown normalizing constant.
  • Define an MCMC estimate using the empirical average of an event indicator.
  • Interpret a finite chain output cautiously, accounting for dependence and initialization.
  • Recognize when a reported sample proportion is not itself the exact target probability.

Targets and the Sampling Goal

Many statistical computations ask for a probability under a distribution that is easy to specify up to a constant but difficult to normalize or sum over. A posterior distribution is a common example: its relative weights come from the prior and likelihood, while its normalizing constant may be an intractable sum or integral. Markov chain Monte Carlo (MCMC) addresses this computational setting by producing a dependent sequence of states intended to represent the target distribution. The basic estimate of an event probability is then the fraction of sampled states in that event.

A target distribution is the probability law whose probabilities or expectations are the quantities of interest. On a finite or countable state space \(S\), it can be specified by nonnegative weights \(w(i)\) with finite positive total \(Z=\sum_{i\in S}w(i)\). The resulting probabilities are \( \pi(i)=w(i)/Z \). The weights need not sum to one; the normalized probabilities do. States with zero weight have target probability zero. If \(Z=0\), these weights do not define a probability distribution.

Definition: An unnormalized target is a nonnegative function \(w\) whose sum \(Z=\sum_{i\in S}w(i)\) is finite and strictly positive, or whose integral \(Z=\int_S w(x)\,dx\) is finite and strictly positive in a continuous state space. The normalized target is \(w/Z\). The value \(Z\) is the normalizing constant.

For a continuous state space, the target may be a density with respect to a stated reference measure, such as Lebesgue measure. Its probabilities are integrals of that density over sets. Multiplying all unnormalized weights or density values by the same positive constant leaves the normalized target unchanged. This scale freedom is useful: computations can use \(w\) without first calculating \(Z\).

In Bayesian inference, if \(\theta\) is a parameter, \(y\) is observed data, \(p(\theta)\) is a prior density or mass function, and \(L(y\mid\theta)\) is the likelihood, the posterior is proportional to \(p(\theta)L(y\mid\theta)\). Thus an unnormalized posterior can be taken as \(w(\theta)=p(\theta)L(y\mid\theta)\); the evidence \(Z\) is the sum or integral of these weights over the parameter space. The formulas below require that the prior and likelihood yield \(0<Z<\infty\).

From a Target to an MCMC Estimate

Let \((\Omega,\mathcal{F},\mathbb{P})\) be a probability space, and let \((X_n)_{n\ge0}\) be a discrete-time Markov chain on a finite or countable state space \(S\). A Markov chain Monte Carlo procedure is designed so that the target distribution is an invariant distribution for the chain: if \(X_n\) has that distribution, then \(X_{n+1}\) has the same distribution. This definition states the sampling goal; it does not by itself prove that a particular chain has the desired target or that its output has converged to the target. Verifying invariance and convergence requires additional conditions and methods.

Definition: Given a target probability \(\pi\), a set \(A\subseteq S\), and chain output \(X_1,\ldots,X_N\), the MCMC estimate of \(\pi(A)\) is the empirical average $$ \widehat{\pi}_N(A)=\frac{1}{N}\sum_{n=1}^N\mathbf{1}_{\{X_n\in A\}}. $$ More generally, for a function \(h\) whose target expectation exists, the empirical estimate is \(N^{-1}\sum_{n=1}^N h(X_n)\).

Here \(N\) is a positive integer, so the displayed average is defined. An initial segment of a chain may be omitted in an application; if \(b\ge0\) states are omitted and \(N\ge1\) states retained, the estimate is \(N^{-1}\sum_{n=b+1}^{b+N}\mathbf{1}_{\{X_n\in A\}}\). Omitting initial states does not itself guarantee that the retained sample represents the target. In general, MCMC states are dependent, so this average is not automatically an average of independent draws, nor is it automatically unbiased. Its reliability depends on the chain and its sampling behavior.

Theorem (Cancellation of the normalizing constant): Suppose \(S\) is finite or countable, \(w(i)\ge0\), and \(0<Z=\sum_{i\in S}w(i)<\infty\). For every \(A\subseteq S\), $$ \pi(A)=\frac{\sum_{i\in A}w(i)}{\sum_{i\in S}w(i)}. $$ Consequently, the probability of \(A\) can be expressed using unnormalized weights without separately interpreting their scale.

Proof. By definition, \(\pi(i)=w(i)/Z\). Countable additivity gives \(\pi(A)=\sum_{i\in A}\pi(i)=\sum_{i\in A}w(i)/Z\). Substituting \(Z=\sum_{i\in S}w(i)\) gives the claimed ratio. The denominator is finite and strictly positive by assumption, so the ratio is defined. \(\square\)

For a continuous target density, the same calculation uses integrals: if \(0<Z=\int_S w(x)\,dx<\infty\), then \(\pi(A)=\int_A w(x)\,dx\,/\,\int_S w(x)\,dx\). This identity can make a probability mathematically well-defined even when evaluating either integral, and therefore \(Z\), is computationally difficult. MCMC estimates the probability by sampling from a chain designed for the target, rather than by evaluating the ratio directly.

Worked Calculations

Worked Example: Normalize a Finite Target

Let \(S=\{a,b,c\}\) and assign weights \(w(a)=2\), \(w(b)=3\), and \(w(c)=5\). Find the normalized target and its probability of \(A=\{b,c\}\).

The total weight is \(Z=2+3+5=10\), which is positive and finite. Dividing each weight by this total gives $$ \pi(a)=\frac{2}{10}=\frac15,\qquad \pi(b)=\frac{3}{10},\qquad \pi(c)=\frac{5}{10}=\frac12. $$ The probabilities sum to \(\frac15+\frac3{10}+\frac12=\frac2{10}+\frac3{10}+\frac5{10}=1\), as required. For \(A=\{b,c\}\), the strict membership test is \(i\in A\): both \(b\) and \(c\) are included, and \(a\) is not. Therefore \(\pi(A)=\frac3{10}+\frac5{10}=\frac8{10}=\frac45\).

Check by the ratio formula: the total weight in \(A\) is \(3+5=8\), while the total weight in \(S\) is \(10\). Thus \(\pi(A)=8/10=4/5\), agreeing with the sum of the normalized probabilities.

Worked Example: A Posterior Probability with an Unknown Normalizer

Let \(\theta\in\{0,1,2\}\). Suppose the prior probabilities are \(1/2,1/3,1/6\), respectively, and the observed data have likelihoods \(1/5,3/5,4/5\), respectively. Find the posterior probability of the event \(A=\{\theta:\theta\ge1\}\).

The unnormalized posterior weights are prior probability times likelihood: \(w(0)=(1/2)(1/5)=1/10\), \(w(1)=(1/3)(3/5)=1/5\), and \(w(2)=(1/6)(4/5)=2/15\). Their sum is $$ Z=\frac1{10}+\frac15+\frac2{15} =\frac3{30}+\frac6{30}+\frac4{30} =\frac{13}{30}. $$ For the event \(\theta\ge1\), the included states are \(1\) and \(2\), while \(0\) is excluded. Its unnormalized weight is \(1/5+2/15=3/15+2/15=1/3\). Therefore $$ \pi(A)=\frac{1/3}{13/30} =\frac13\cdot\frac{30}{13} =\frac{10}{13}. $$ The denominator \(Z\) is needed to report the full posterior distribution, but it cancels in the event-probability ratio: \((1/5+2/15)/(1/10+1/5+2/15)=10/13\).

Check: the posterior masses are \((1/10)/(13/30)=3/13\), \((1/5)/(13/30)=6/13\), and \((2/15)/(13/30)=4/13\). They sum to \((3+6+4)/13=1\), and the event mass is \(6/13+4/13=10/13\).

Worked Example: Estimate the Posterior Event from Chain Output

Continue with the posterior target from the previous example, but suppose its normalizing constant is not available to the computation. A sampler intended for this target returns the following \(N=12\) states, in order: \(0,1,1,2,0,1,2,2,1,0,2,1\). Estimate the posterior probability of \(A=\{\theta:\theta\ge1\}\).

Use the membership rule \(\theta\ge1\): states \(1\) and \(2\) count, while state \(0\) does not. The chain has \(8\) included states: positions \(2,3,4,6,7,8,10,12\). Hence $$ \widehat{\pi}_{12}(A)=\frac{8}{12}=\frac23. $$ This is the MCMC estimate from these 12 retained states. It is not the exact posterior probability: the exact value calculated from the weights is \(10/13\). The difference does not by itself establish a problem with the sampler; a finite output can differ from its target, and the successive states may be dependent.

Check: there are four excluded zeros, so the number included is \(12-4=8\); the sample proportion is \(8/12=2/3\). This count verifies the estimate without requiring the unknown normalizing constant.

What the Estimate Does—and Does Not—Say

The empirical average has a direct interpretation: it is the observed fraction of retained states in the event. The cancellation identity explains why an unknown normalizing constant need not prevent estimating a posterior probability. But the identity does not establish that a particular Markov chain samples from the target. That requires checking how the chain was constructed. Nor does a finite sample proportion certify its own accuracy. A sequence that has not explored relevant parts of the state space can give a misleading estimate, even if its intended target is correct.

Common mistake: treating unnormalized event weight as a probability. In the posterior example, the event weight is \(1/3\). Reporting \(1/3\) as the posterior probability ignores the total posterior weight. The correction is to divide by \(Z=13/30\), giving \((1/3)/(13/30)=10/13\). In MCMC, the corresponding correction is different in form but serves the same normalization role: count the sampled states in the event and divide by the total number of retained states. Reporting \(8\) from the sample, rather than \(8/12\), would likewise fail to produce a probability.

Keep three quantities distinct: the unnormalized target \(w\), the normalized target probability \(\pi(A)\), and the sample estimate \(\widehat{\pi}_N(A)\). The first encodes relative mass, the second is the desired theoretical answer, and the third is calculated from a finite chain output. A trustworthy MCMC analysis must connect the chain to the target and assess whether its output adequately represents that target; the sample proportion alone does not supply that justification.

Check Your Understanding

For each question, distinguish the target quantity from any finite-sample estimate.

  1. On \(S=\{1,2,3\}\), weights are \(1,2,5\). What is the normalized probability of \(A=\{2,3\}\), and what condition must the total weight satisfy?
  2. A posterior has unnormalized weights \(2,3,5\) on states \(a,b,c\). Find the posterior probability of \(A=\{b\}\) without first listing all normalized masses.
  3. For the 12-state output in the worked example, how many states satisfy \(\theta\ge1\), and what is the empirical MCMC estimate?
  4. Why does an unknown normalizing constant not prevent expressing a finite-target event probability as a ratio?
  5. Does defining the empirical MCMC estimate prove that the chain has the target distribution? Explain the distinction.