skoro v0.0.0

Importance weights

Drawing the free quantities of a model in an ancestral order, each from a proposal, and weighing the draw by the ratio of the model's density to the proposals', gives an unbiased estimate of every integral against the unnormalized conditional law, provided each ratio is of densities against one reference measure.

Updated 2026-11-25 · 4 min read

A model built forward can be sampled by drawing its quantities in the order they were built. Once some of its quantities are observed, or it carries likelihood factors, or a quantity is drawn from something other than its own kernel, the draw is no longer from the law that is wanted. It is from a law that differs from it by a known factor, the importance weight. This note defines the weight, proves what it estimates, and states the two conditions that are easy to break.

Proposals and ancestral draws#

Let a model have quantities with conditional densities pi(xi∣x<i)\density_i(\point_i \mid \point_{<i}) against reference measures νi\nu_i, likelihood factors LjL_j, and parameters with scores SS, and let its quantities be split into the observed ones, xO\point_O, held at given values, and the free ones, xF\point_F. Write

p(xF,xO)=∏ipi(xi∣x<i)∏jLj(x)  S(θ) \density(\point_F, \point_O) = \prod_i \density_i(\point_i \mid \point_{<i}) \prod_j L_j(\point)\; S(\theta)

for the product of everything the model states. By Proposition 9 and Proposition 10, the law of the free quantities given the observations has, when the model has no parameters, a density proportional to p(⋅,xO)\density(\cdot, \point_O) against the product dxF\dd \point_F of the free quantities’ reference measures, and with parameters p(⋅,xO)\density(\cdot, \point_O) is the unnormalized measure of (11).

A proposal for a free quantity is a conditional density qi(xi∣x<i)\proposal_i(\point_i \mid \point_{<i}) against the quantity’s own reference measure νi\nu_i, from which the quantity can be drawn. A quantity’s own kernel is a proposal for it, with qi=pi\proposal_i = \density_i, and is called exact. A parameter has no kernel, so its proposal is always something else. Drawing the free quantities in an ancestral order, each from its proposal given the quantities drawn or fixed before it, is an ancestral draw. Its weight is

log⁡w(xF)=log⁡p(xF,xO)−∑i∈Flog⁡qi(xi∣x<i).(1) \log \weight(\point_F) = \log \density(\point_F, \point_O) - \sum_{i \in F} \log \proposal_i(\point_i \mid \point_{<i}) . \tag{1}
(1)

Each free quantity drawn from its own kernel cancels, log⁡pi−log⁡qi=0\log \density_i - \log \proposal_i = 0, so with exact proposals throughout the weight is what remains: the densities of the observed quantities at their values, the likelihood factors, and the scores,

log⁡w(xF)=∑i∈Olog⁡pi(xi∣x<i)+∑jlog⁡Lj(x)+log⁡S(θ)−∑θ freelog⁡qθ, \log \weight(\point_F) = \sum_{i \in O} \log \density_i(\point_i \mid \point_{<i}) + \sum_j \log L_j(\point) + \log S(\theta) - \sum_{\theta \text{ free}} \log \proposal_\theta ,

the likelihood of everything that was not generated, at the point that was.

Proposition 2(Importance weights).

Let the quantities xF\point_F of a model built forward be free and xO\point_O observed, with dxF\dd\point_F the product of the free quantities’ reference measures and p(xF,xO)\density(\point_F, \point_O) the product of every kernel’s density, every likelihood factor and every score. Suppose that every free quantity has a proposal, of density qi\proposal_i with respect to the quantity’s reference measure, and that the product q\proposal of the proposals is positive wherever p(⋅,xO)\density(\cdot, \point_O) is. If xF\point_F is drawn ancestrally from the proposals, then for every hh with ∫∣h∣ p(xF,xO) dxF<∞\int \lvert h \rvert\, \density(\point_F, \point_O)\, \dd\point_F < \infty,

Eq[w(xF) h(xF)]=∫h(xF) p(xF,xO) dxF. \E_\proposal\bigl[\weight(\point_F)\, h(\point_F)\bigr] = \int h(\point_F)\, \density(\point_F, \point_O)\, \dd \point_F .

When the model has neither parameters nor likelihood factors, the right side is E[h(xF)∣xO=xO]\E[h(\randomPoint_F) \mid \randomPoint_O = \point_O] times the marginal density of xO\randomPoint_O at xO\point_O. In general it is Z Eπ[h]Z\, \E_\pi[h] whenever Z=∫p(xF,xO) dxFZ = \int \density(\point_F, \point_O)\, \dd\point_F is finite and positive, with π\pi the measure of density p(⋅,xO)/Z\density(\cdot, \point_O) / Z.

Proof.

An ancestral draw has the density q(xF)=∏i∈Fqi(xi∣x<i)\proposal(\point_F) = \prod_{i \in F} \proposal_i(\point_i \mid \point_{<i}) with respect to dxF\dd \point_F, since each free quantity is drawn given quantities drawn or fixed before it. Then w=p(xF,xO)/q(xF)\weight = \density(\point_F, \point_O) / \proposal(\point_F) wherever q>0\proposal > 0, which covers the set where p(⋅,xO)>0\density(\cdot, \point_O) > 0, and

Eq[wh]=∫h p(xF,xO)q(xF) q(xF) dxF=∫h p(xF,xO) dxF. \E_\proposal[\weight h] = \int h\, \frac{\density(\point_F, \point_O)}{\proposal(\point_F)}\, \proposal(\point_F)\, \dd \point_F = \int h\, \density(\point_F, \point_O)\, \dd \point_F .

Without parameters or likelihood factors, p(xF,xO)\density(\point_F, \point_O) is the joint density, which is the conditional density of Proposition 9 times the marginal density of the observations. When ZZ is finite and positive, π\pi is a probability measure, and the integral is Z Eπ[h]Z\, \E_\pi[h].

∎

What a weighted draw is for#

The statement gives Z Eπ[h]Z\, \E_\pi[h] and not Eπ[h]\E_\pi[h]: the weight turns the proposal’s law into the target only up to the constant ZZ. That is all an algorithm needs, and often what it wants.

  • With h=1h = 1, the mean weight of independent draws is an unbiased estimate of ZZ itself, which without parameters or likelihood factors is the marginal density of the observations, the model’s evidence.
  • A self-normalized estimate ∑nwnhn/∑nwn\sum_n \weight_n h_n / \sum_n \weight_n over draws estimates Eπ[h]\E_\pi[h], with ZZ cancelling between its numerator and its denominator. It is consistent and not unbiased.
  • A Metropolis–Hastings ratio, a gradient of log⁡w\log \weight, and a resampling step in a particle filter are each unchanged when every weight is multiplied by the same number.

A constant that does not depend on the free quantities may therefore be dropped from the weight, and with it from every density it is made of, when all that is wanted is the law. It may not be dropped when the evidence is.

The two conditions#

Positivity. The proposals must be positive wherever the target is: a region the proposals never reach contributes nothing to any estimate, however much of the target lies there. It is a property of the proposals that no computation on draws can check.

One reference measure for each ratio. The weight is a ratio of densities, and the ratio means something only when numerator and denominator are densities against the same measure. A density of a continuous quantity against Lebesgue measure and a mass function of a discrete one against counting measure mix freely in a product, since each quantity’s ratio is formed on its own. What breaks the condition is a density written in a chart. If gg is the density of log⁡x\log \randomPoint with respect to Lebesgue measure on Rn\R^n, the density ff of x\randomPoint with respect to Lebesgue measure on R>0n\positive^n carries the Jacobian of the chart,

log⁡f(x)=log⁡g(log⁡x)−∑ilog⁡xi,(3) \log f(\point) = \log g(\log \point) - \sum_i \log \point_i , \tag{3}
(3)

and a proposal written as gg against a target written as ff gives weights wrong by ∏ixi\prod_i \point_i at every draw. The general form of this correction is the volume of a chart: a density of a point drawn through a chart is the density of its tangent coordinate less the chart’s log-volume (Proposition 4), and a weight on a curved space is right when the target’s densities and the proposals’ both keep to it.

Built on by