liveBook · Manning

Target distribution

As explained in Machine Learning Algorithms in Depth

A target distribution is the probability distribution from which a sampling method aims to generate samples.

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)
figure

Compare the plotted target, proposal, and integrand to see why proposal samples need weights when estimating an expectation under the target. section 2.7

How Machine Learning Algorithms in Depth covers it

How deep it goes
Derives an MH correction through detailed balance and defines importance weights as p(x)/q(x), then implements both algorithms.
Examples
Uses a two-dimensional Gaussian mixture for MH and an unnormalized Chi-shaped target for an importance-sampling expectation.
What you can do after
Build it from scratch as an MH target density or use it with proposal-density weights to estimate an expectation.
How it connects
Connects Metropolis–Hastings, detailed balance, proposal distributions, importance sampling, and Monte Carlo integration.

Also explained in

Compare how 2 books explain target distribution →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Algorithms in Depth. The section links point to the parts of the book it draws on.