A target distribution p(x) is the distribution of interest, even when drawing from it directly is difficult. The task determines what “target” means: Metropolis–Hastings (MH) aims to generate samples from p(x), while importance sampling uses samples from another distribution to estimate an expectation under p(x). A target may be a posterior p(θ|x) or a specified density p(θ). section 2.6 section 2.7
Two algorithms give the target different roles:
- In MH, propose x′ from q(x′|x), then accept or reject the move using a correction based on p and q. Detailed balance is used to make p the Markov chain’s stationary distribution. section 2.6
- In importance sampling, draw x from an easier proposal q(x) and weight its contribution by w(x)=p(x)/q(x). This lets proposal samples contribute to an estimate of an integral involving p(x)f(x). section 2.7
Targets in code
For MH, a `target_pdf` function evaluates a two-component, two-dimensional Gaussian mixture; samples are compared with that mixture. For importance sampling, a `target_pdf` evaluates an unnormalized Chi-shaped function on x≥0, while proposal samples and p(x)/q(x) weights are used to estimate an expectation of f(x)=2 sin(πx/1.5). In both cases, defining the target density is distinct from choosing the distribution used to propose or draw candidate points. section 2.6 section 2.7
Figure 2.16 IS components (left) and IS estimate (right)
Compare the plotted target, proposal, and integrand to see why proposal samples need weights when estimating an expectation under the target. section 2.7

