An overview of importance sampling techniques
- 1. Numerical integration in 1D
- 2. Multidimensional integrals & Monte Carlo
- 3. Rejection sampling
- 4. Stratified sampling
- 5. Quasi Monte Carlo
- 6. Importance sampling (IS)
- 7. Multiple importance sampling (MIS)
- 8. Weighted importance sampling (WIS - SNIS)
- 9. Resampled importance sampling (RIS)
- 10. Weighted reservoir sampling (WRS)
- 11. Stratified resampling (bidirectional CDF sampling)
- 12. Spatiotemporal reservoir resampling (ReSTIR)
- 13. Multiple weighted importance sampling (MWIS)
- 14. To learn for next time
- References
1. Numerical integration in 1D
Problem: compute
\[\displaystyle I=\int_a^b f(x)\,\mathrm{d}x\]Solutions:
- Simple uniform quadratures: rectangle rule, trapezoidal rule, Simpson’s rule = piecewise polynomial interpolation.
- Higher order uniform quadratures: Newton-Cotes, Romberg.
- Weighted quadratures with non uniform subdivisions: Gaussian quadratures (Gauss-Legendre, …).
- Other methods: for specific forms of integrals (Laplace), adaptive methods, …
Example 1.1: integrate the square function with the rectangle rule
\[\displaystyle I=\int_0^2 x^2\,\mathrm{d}x = \frac{8}{3}\]Rectangle quadrature of \(f\) on \([a,b]\) with \(n\) subdivisions, using their left end points, midpoints and right end points (for an increasing function such as \(x^2\), the left and right sums are lower and upper bounds):
def rectangle_rule(f, a, b, n):
size = (b - a) / n
area_inf, area_mid, area_sup = 0, 0, 0
for i in range(n):
area_inf = area_inf + size * f(a + i * size)
area_mid = area_mid + size * f(a + (i + 0.5) * size)
area_sup = area_sup + size * f(a + (i + 1) * size)
return area_inf, area_mid, area_sup
area_inf, area_mid, area_sup = rectangle_rule(lambda x: x * x, 0, 2, 8)
trapezoid = (area_inf + area_sup) / 2 # 2.6875
simpson = (area_inf + 4 * area_mid + area_sup) / 6 # 2.666... = 8/3
With \(h = \frac{b-a}{n}\), the left sum \(I_{\inf}\) and the right sum \(I_{\sup}\) (area_inf and area_sup) are:
The integral can be approximated either by the midpoint sum (area_mid):
or by the mean of the two bounds, i.e. the trapezoidal rule:
\[\displaystyle \hat I = \frac{I_{\inf} + I_{\sup}}{2}\]For \(x^2\) on \([0, 2]\) with \(n = 8\): \(\hat I_{\text{mid}} = 2.65625\) and \(\hat I = 2.6875\), against \(8/3 \approx 2.66667\). The errors, \(-1/96\) and \(+1/48\), have opposite signs and the midpoint one is half the trapezoidal one, as predicted for smooth functions (exactly here, since \(f''\) is constant).
Can we obtain a better estimate? Yes. For a smooth \(f\), the trapezoidal error is about \(+\frac{(b-a)\,h^2}{12}f''\) and the midpoint error about \(-\frac{(b-a)\,h^2}{24}f''\). Weighting the midpoint twice cancels the \(h^2\) term:
\[\displaystyle \hat I_S = \frac{2\,\hat I_{\text{mid}} + \frac{I_{\inf}+I_{\sup}}{2}}{3} = \frac{I_{\inf} + 4\,\hat I_{\text{mid}} + I_{\sup}}{6}\]This is the composite Simpson rule (each subinterval split at its midpoint), with an error in \(O(h^4)\), exact for polynomials up to degree 3. For \(x^2\) it gives exactly \(\frac{2.1875 + 4 \times 2.65625 + 3.1875}{6} = \frac{16}{6} = \frac{8}{3}\).
| estimate (\(n = 8\)) | value | error |
|---|---|---|
| left sum \(I_{\inf}\) | 2.1875 | −0.479167 |
| right sum \(I_{\sup}\) | 3.1875 | +0.520833 |
| trapezoid \((I_{\inf}+I_{\sup})/2\) | 2.6875 | +0.020833 |
| midpoint \(\hat I_{\text{mid}}\) | 2.65625 | −0.010417 |
| Simpson \(\hat I_S\) | 2.666667 | 0 |
Repeating this cancellation between estimates with \(n\) and \(2n\) subdivisions is Richardson extrapolation, which leads to the Romberg integration listed above.
2. Multidimensional integrals & Monte Carlo
Problem:
-
Multidimensional integrals: surface/volume integration, physics simulation, computer graphics simulation \(\rightarrow\) rendering, games AI, … and a lot more applications:
\[\displaystyle I = \int_{\Omega_0} \int_{\Omega_1} \dots \int_{\Omega_k} f(x_0, x_1, \dots, x_k) \prod_{i=0}^k \mathrm{d}x_i\] -
They can not be solved efficiently by quadratures (the number of samples grows exponentially with the dimension).
Solution:
-
Monte Carlo methods: approximate the integral by random sampling of the integration domain:
\[\displaystyle I \approx \hat{I} = \frac{1}{n}\sum_{i=1}^n \frac{f(x_i)}{p(x_i)}\] -
\(p(x)\) is the probability density function of the samples and has to be normalized: \(\int_\Omega p(x)\,\mathrm{d}x = 1\).
Downsides:
- Uniform sampling is (often) easy, but MC estimators are noisy (variance) due to the random sampling process and require a large number of samples to converge.
- With pure random sampling the error vanishes in \(O(\frac{1}{\sqrt n})\), hence it takes 4 times more samples to divide the error by 2.
- Designing efficient and correct non uniform sampling is hard (see the importance sampling section).
Your mission, should you choose to accept it: reduce the variance of the estimator at any cost.
Example 2.1: integrate the square function with Monte Carlo
\[\displaystyle I=\int_0^2 x^2\,\mathrm{d}x\]- Uniformly sample the domain \([0,2[\), with probability density \(p(x)=\frac{1}{2}\).
3. Rejection sampling
Problem:
- We do not know how to sample from a distribution \(g\),
- but we know how to sample from a distribution \(f\) such that \(c \cdot f(x) > g(x)\).
Solution:
- Sample a domain larger than the target distribution domain,
- and reject the samples that are outside the region of interest.
- Sampling routine:
- Sample \(x\) from \(f\).
- Draw a uniform sample \(u\) in \(U(0,1)\).
- While \(u > \frac{g(x)}{c \cdot f(x)}\), go to 1.
- Accept \(x\), which is distributed with probability density \(g(x)\).
(the generic version replaces \(\frac{g(x)}{c \cdot f(x)}\) by \(h(x)\) with values in \([0,1]\))
Pros: sample arbitrary distributions from uniform samples.
Cons: can be very inefficient if rejection is more frequent than acceptance.
Example 3.1: Estimate Pi with Monte Carlo and rejection sampling
- Sample \(x\) uniformly in the square \(((0,0), (2,2))\), with pdf \(p(x) = 1/4\).
- \(h(x) = 1\) if \(x \in C\) else \(h(x) = 0\) \(\rightarrow\) binary acceptance.
4. Stratified sampling
Problem:
- Classic uniform sampling suffers from voids and clusters: how to get a better coverage of the domain?
Solution:
- Subdivide the domain and draw random samples in the subregions.
- Converges faster than uniform sampling.
- Works in high dimensions since 2019 with orthogonal arrays [Jarosz:2019].
Downside:
- Requires covering the whole grid to get a correct estimate (the N-dimensional grid has a loooooot of cells).
Example 4.1: Estimate Pi with Monte Carlo, rejection sampling and stratified samples
5. Quasi Monte Carlo
Problem:
- If noise comes from randomness, can we choose the random? … … … Yes!
Solution:
- Low discrepancy sequences:
- Halton, Hammersley, Sobol, R2 / Rn, lattices.
- Sequences are often designed to minimize the discrepancy (a measure of space coverage).
- The error vanishes as fast as the discrepancy decreases.
- e.g. the Sobol error decreases with rate \(O(1/n)\) \(\rightarrow\) with 2 times more samples the error is divided by 2.
- Optimized point sets:
- Dart throwing [Cook:1986], BNOT [deGoes:2012], LDBN [Ahmed:2016], SOT [Paulin:2020].
- Point sets are often designed to minimize the optimal transport cost (but other measures exist).
- The error vanishes as fast as the optimal transport cost decreases.
- In production: OpenQMC [OpenQMC], Framestore’s open source sampling library, offers Owen-scrambled Sobol’, progressive multi-jittered (PMJ) and rank-1 lattice samplers, each with a spatial blue noise variant, behind one API for CPU and GPU renderers.
Comparison of low discrepancy sequences (see Martin Roberts’ blog [Roberts:2018] for an animated comparison):
Comparison of optimized point sets and production samplers, generated with UTK [UTK] and OpenQMC [OpenQMC], and with a simplified implementation of SOT [Paulin:2020]:
Downside:
- Don’t mess up the points … or they’ll mess your integrals up.
Example 5.1: Estimate Pi with Monte Carlo, rejection sampling and LDS samples
6. Importance sampling (IS)
Problem:
- Uniform sampling puts samples everywhere, even in unimportant areas.
- What if the integrand is non zero over a small part of the domain only?
Solution:
- Put more samples in the important regions and correct the bias (correctly modify the probability density \(p(x)\)) = non uniform distributions.
- Dramatically reduces variance when it works (zero variance estimators exist).
-
If the sample distribution is proportional to the integrand, \(\frac{f(x)}{p(x)}=k\), then the MC estimator is a zero variance estimator = perfect importance sampling:
\[\displaystyle \hat{I} = \frac{1}{n}\sum_{i=1}^n \frac{f(x_i)}{p(x_i)} = \frac{1}{n}\sum_{i=1}^n k = k \quad \text{and} \quad \mathbb{V}\left[\hat{I}\right]=0\]
Downside:
- Can completely fail …
- Choosing or designing a perfect non uniform distribution is hard; several methods exist, such as:
- the inverse CDF method (analytic or numeric, e.g. the triangle cut method),
- warping by a transformation (analytic or numeric),
- rejection sampling,
- generic model + learning,
- others I do not know yet …
- e.g. the first example integrand \(f(x)=x^2\) on \([0,2]\) is easy: \(p(x)=\frac{3x^2}{8}\) has the cdf \(\frac{x^3}{8}\), so \(x = 2u^{1/3}\) gives perfect importance sampling; most integrands have no invertible cdf, and rejection or numerical methods take over.
Example 6.1: integration of a Gaussian, uniform vs importance sampling
\[\displaystyle I=\int_{-10}^{10} 5\,e^{-x^2/2}\,\mathrm{d}x \approx 12.5331\]with a uniform density on \([-10, 10]\), the perfect density \(\mathcal{N}(0,1)\) and a bad density \(\mathcal{N}(-4,1)\).
7. Multiple importance sampling (MIS)
Problem:
- Several importance sampling strategies are available: \(p_1, p_2, \dots, p_k\).
- How to combine the associated estimators \(\hat{I}_1,\hat{I}_2, \dots, \hat{I}_k\)?
- Averaging them is not better than the individual estimators (per estimator weight).
- Use a weighted mixture of sampling strategies instead (per sample weight) \(\rightarrow\) MIS.
Solution:
-
Multi sample model: distribute a fixed number of samples \(n_i\) per strategy and weight the contributions:
\[\displaystyle \hat{I}_{\text{ms-mis}}=\sum_{i=1}^{k} \hat{I}_i = \sum_{i=1}^{k} \frac{1}{n_i}\sum_{j=1}^{n_i} \color{red}{w_i(x_{ij})}\frac{f(x_{ij})}{p_i(x_{ij})}\] -
One sample model: draw each sample from a strategy selected with a fixed probability \(c_i\) and weight the contributions:
\[\displaystyle \hat{I}_{\text{os-mis}}=\frac{1}{N}\sum_{j=1}^{N} \color{red}{w_i(x_{ij})}\frac{f(x_{ij})}{c_i p_i(x_{ij})}\] -
Condition on the weighting functions: \(\sum_i w_i(x) = 1\); in practice the balance heuristic weights are a provably good solution [Veach:1995]:
\[\displaystyle w_i(x) = \frac{c_i p_i(x)}{\sum_{j=1}^{k} c_j p_j(x)}\]
Downside:
- The strategy with the highest density is preponderant.
- What if that distribution is a bad importance sampler for the integrand?
- Weights are still dominant on unimportant parts of the domain \(\rightarrow\) more variance.
- Several references propose improvements over Veach MIS: variance-aware MIS [Grittmann:2019], optimal MIS [Kondapaneni:2019], …
Example 7.1: integration in 1D
- Complex multi term integrand: \(f(x) = \frac{\exp{\frac{-x^2}{50}} \cdot \lvert x\rvert \cdot \left(\cos{x}+1\right)}{5}\).
- Sampling with two Gaussians under the peaks, and uniform sampling as a defensive strategy.
- Equal sample count per strategy.
Example 7.2: Direct illumination sampling with Veach MIS
The scene of Veach and Guibas [Veach:1995], with the layout of Bitterli’s version [Bitterli:2016]: four glossy plates, from smooth (back) to rough (front), each tilted to reflect the lights towards the camera, lit by four spherical lights of equal power and increasing size. Four samples per pixel, each with two BSDF samples, two light samples, or one of each for MIS (balance heuristic):
8. Weighted importance sampling (WIS - SNIS)
Problem:
- What if we know how to sample from a distribution \(q\) but want to evaluate the estimator w.r.t. another density \(p\)? (target density \(\neq\) source density)
Solution:
“If we really accepted the idea that a sample from one distribution is a sample from any distribution (if appropriately weighted) then we should not be surprised at the next two results stated below.” - Trotter and Tukey [Trotter:1956]
-
Write the integral as an expectation w.r.t. \(p\), move it to \(q\) with the weight \(w = p/q\), and divide by the expectation of the weight, which is \(1\). The identity is exact provided \(p\) is normalized, \(p(x) > 0\) wherever \(f(x) \neq 0\), and \(q(x) > 0\) wherever \(p(x) > 0\):
\[\displaystyle \begin{aligned} I = \int_\Omega f(x)\,\mathrm{d}\mu(x) &= \mathbb{E}_p\left[\frac{f(X)}{p(X)}\right] = \mathbb{E}_q\left[w(X)\frac{f(X)}{p(X)}\right] = \frac{\mathbb{E}_q\left[w(X)\frac{f(X)}{p(X)}\right]}{\mathbb{E}_q\left[w(X)\right]} \\ &\text{with} \quad w(x)=\frac{p(x)}{q(x)} \quad \text{and} \quad \mathbb{E}_q\left[w(X)\right] = 1 \end{aligned}\]where \(\mathbb{E}_q\left[g(X)\right] = \int_\Omega g(x)\,q(x)\,\mathrm{d}\mu(x)\) denotes the expectation for \(X \sim q\).
-
Estimating the numerator and the denominator with the same samples \(X_1, \dots, X_n \sim q\) gives the self normalized (ratio) estimator, a weighted mean of the values \(f/p\):
\[\displaystyle \tilde{I} = \frac{ \frac{1}{n} \sum_{i=1}^n w(X_i)\frac{f(X_i)}{p(X_i)} }{ \frac{1}{n} \sum_{i=1}^n w(X_i)} = \frac{ \sum_{i=1}^n w(X_i)\frac{f(X_i)}{p(X_i)} }{ \sum_{i=1}^n w(X_i)}\] - The closer \(p\) is to the perfect importance distribution w.r.t. the integrand, the better the estimator: if \(f = k\,p\), every term \(f/p\) equals \(k\) and \(\tilde{I} = k = I\) for any number of samples.
- The weights only matter up to a constant factor, so \(q\) can be known up to a constant, but \(p\) must be normalized: with \(\hat{p} = Z\,p\) in place of \(p\) the weights still cancel, but the values \(f/\hat{p}\) are divided by \(Z\) and the estimator converges to \(I/Z\).
Downside:
- Biased but consistent: the ratio of two unbiased estimates is not an unbiased estimate of the ratio. The bias, of order \(1/n\), shows at low sample counts but vanishes faster than the noise, of order \(1/\sqrt{n}\) (proofs in section 13.5, WIS being the case \(k = 1\) of MWIS).
Example 8.1: integration with WIS
\[\displaystyle I=\int_1^{10} e^{-(x-1)/2}\,\mathrm{d}x \approx 1.9778\]with uniform samples \(q\) on \([1, 10]\), reweighted towards a truncated exponential \(p(x) \propto e^{-0.7\,(x-1)}\), or towards the perfect target \(p = f/I\) (a toy: it requires knowing \(I\)).
9. Resampled importance sampling (RIS)
Problem:
- Can we get rid of the bias in WIS? … … … yes, via discrete random resampling!
Solution:
- Resampled importance sampling, Talbot et al. [Talbot:2005a].
- Generate a set of \(M\) samples from \(q\) and select one sample with discrete resampling.
- Sampling routine:
- Generate \(M\) candidate samples \(x_1, \dots, x_M\) from \(q\).
- Evaluate for each candidate \(x_j\) the resampling weight \(w(x_j)=\frac{p(x_j)}{q(x_j)}\).
- Build the discrete CDF of the weights (covered in Ray Tracing Gems, section 16.3.4 [Shirley:2019]).
-
Randomly sample the discrete CDF to select a single candidate \(y = x_i\), approximately distributed according to \(p\), and associate it with:
\[\displaystyle p_{\text{RIS}}(y) = \frac{p(y)}{\underbrace{\frac{1}{M}\sum_{j=1}^M w(x_j)}_{\text{bias correction term}}}\]
- The number of candidates \(M\) interpolates from the source distribution \(q\) (\(M=1\)) to the target distribution \(p\) (\(M=\infty\)).
-
\(p_{\text{RIS}}\) is not the density of the selected sample (which has no simple closed form, see example 9.1), but the mean weight acts as a random normalization that makes the classic Monte Carlo estimator unbiased, provided \(p(x) > 0\) wherever \(f(x) \neq 0\) and \(q(x) > 0\) wherever \(p(x) > 0\):
\[\displaystyle \hat{I} = \frac{1}{n}\sum_{i=1}^n \frac{f(y_i)}{p_{\text{RIS}}(y_i)}, \qquad \mathbb{E}\left[\frac{f(y)}{p_{\text{RIS}}(y)}\right] = I\] - Unlike WIS, \(p\) can be unnormalized here: a constant factor on \(p\) cancels between \(p(y)\) and the mean weight.
Downside:
- Impractical if \(q\) is complex or costly to sample: generating \(M\) candidates is a waste of computation time.
Example 9.1: Density of RIS samples in 1D
Exact density of RIS samples for increasing numbers of uniform candidates \(M\) on \([-4, 4]\) and a normal target density:
The density of the selected sample can still be written with 1D integrals. With weights \(w = p/q\) (\(p\) possibly unnormalized, as above), candidate \(j\) lands at \(y\) with density \(q(y)\) and is then selected with probability \(w(y) / (w(y) + S)\), where \(S\) is the sum of the \(M - 1\) other weights. Summing over the candidates and writing \(\frac{1}{z} = \int_0^\infty e^{-tz}\,\mathrm{d}t\), the independence of the candidates turns the expectation into a power:
\[\displaystyle p_Y(y) = M\,p(y)\,\mathbb{E}\left[\frac{1}{w(y) + S}\right] = M\,p(y) \int_0^\infty e^{-t\,w(y)}\,\varphi(t)^{M-1}\,\mathrm{d}t, \qquad \varphi(t) = \mathbb{E}_q\left[e^{-t\,w(X)}\right]\]\(\varphi\) is the Laplace transform of the weights, a single integral over \(x\). For \(M = 1\) the density is \(q\), and it tends to \(p / \int p\) as \(M\) grows, since \(S / (M - 1)\) tends to \(\int p\).
Example 9.2: direct illumination sampling with RIS
A diffuse floor and a white sphere lit by a rectangular light with a textured emission: a grid of bright spots of random colors on a uniform white base of lower power. One shadow ray per sample, 4 samples per pixel. RIS takes \(M = 16\) uniform candidates on the light and selects one with a reservoir (section 10), for two targets: the geometric term \(\hat{p} = G = \frac{\cos\theta\,\cos\theta'}{d^2}\) alone, or the emission times the geometric term \(\hat{p} = L_e\,G\), the unoccluded contribution up to the constant diffuse BRDF:
10. Weighted reservoir sampling (WRS)
Problem:
- Can we resample from a stream of samples without
- building the discrete CDF,
- storing all the samples,
- knowing the number of samples to be drawn?
- Again … yes!
Solution:
- Popularized in rendering by Bitterli et al. [Bitterli:2020].
- Use a reservoir \(R(y, w_y, s)\): the kept sample, its weight and the running sum of weights.
- Reservoir resampling routine, for each new candidate:
- Sample \(x_j\) from \(q\).
- Evaluate the resampling weight \(w(x_j)=\frac{p(x_j)}{q(x_j)}\).
- Update the sum of weights in the reservoir: \(s=s+w(x_j)\).
- Replace the kept sample by the new candidate with probability \(\frac{w(x_j)}{s}\).
- If the candidate is accepted, update the reservoir accordingly: \(y=x_j, \ w_y=w(x_j)\).
- After \(M\) candidates, \(y\) is distributed exactly as the RIS selection from the same candidates and \(s/M\) is the mean weight of section 9, so the RIS estimator reads \(\frac{f(y)}{p(y)}\,\frac{s}{M}\).
- WRS = RIS without storing the candidates, inverting the CDF, or knowing the number of candidates in advance.
- WRS is covered in Ray Tracing Gems II, chapter 22 [Wyman:2021].
- A reservoir summarizes its candidates in a few numbers, so two reservoirs can be merged: this is the basis of ReSTIR (section 12).
Downside:
- Candidates are processed sequentially (one random number and one comparison each), and the quality is that of RIS with \(M\) candidates: the selected sample only approaches \(p\) as \(M\) grows.
Example 10.1: Density of WRS samples (same as RIS)
Same experiment as example 9.1, with the candidates streamed through a reservoir instead of resampled from a stored CDF. The WRS histograms follow the exact RIS density of example 9.1: the reservoir selects with exactly the same distribution.
11. Stratified resampling (bidirectional CDF sampling)
Problem:
- Stratified samples converge faster (section 4), but resampling destroys the stratification: a reservoir draws one random number per candidate, and inverse CDF sampling of the candidates, which could be stratified, needs to store them.
- Stratifying the selection index is not enough either: nearby indices must also be nearby points of the domain.
Solution:
- Single-pass stratified importance resampling, Ciklabakkal et al. [Ciklabakkal:2022].
- Bidirectional CDF sampling: walk the candidates from both ends with a single random number \(u\) and two running sums of weights:
- Start with \(\text{front} = 1\), \(\text{back} = M\), \(W_f = w_1\) and \(W_b = w_M\).
- While \(\text{front} < \text{back}\): if \(W_f \le u\,(W_f + W_b)\), advance the front and add its weight to \(W_f\), else move the back down and add its weight to \(W_b\).
- Return \(\text{front}\).
- The returned index is exactly the one inverse CDF sampling selects with the same \(u\), i.e. \(\sum_{i < j} w_i \le u\,W < \sum_{i \le j} w_i\) with \(W\) the sum of all weights (their Appendix A), so the output follows the RIS distribution of section 9. Like a reservoir it takes a single pass and constant memory, but stratified values of \(u\) now give stratified selections.
// Index selected by inverse CDF sampling with u in [0, 1), in a single pass over the weights from
// both ends, without storing the CDF (Ciklabakkal et al. 2022, Algorithm 1).
int bidirectionalCDF(const float* w, int M, float u)
{
int front = 0, back = M - 1;
float wf = w[front], wb = w[back];
while (front < back)
{
if (wf <= u * (wf + wb)) wf += w[++front];
else wb += w[--back];
}
return front;
}
- The weights do not have to be stored either: if candidate \(k\) can be generated from its index, e.g. a jittered point of stratum \(k\), it is generated when the front or the back reaches it.
- Candidate order: candidates are ordered along a space-filling curve (a Hilbert curve in the paper; in 1D, simply sorted), so that stratified indices give stratified points.
- Several samples: one pass gives one sample. Their variance analysis shows that, for independent candidates, taking one sample from each of \(N\) subsets of \(M/N\) candidates is better than \(N\) samples from all \(M\) candidates, so the candidates are split into subsets and \(u\) is stratified across them.
Downside:
- The candidates must be accessible from both ends, unlike the pure stream of a reservoir.
- It stratifies the primary sample space, and the mapping to the integration domain may not keep the stratification in high dimension.
Example 11.1: Stratified resampling in 1D
Same setup as example 9.1, uniform candidates on \([-4, 4]\) and a normal target, to estimate the integral of \(f(x) = p(x)\,(1 + \frac{1}{2}\cos 3x)\) with \(N\) samples, each selected from its own subset of 8 candidates:
- Independent resampling, RIS or WRS: the selected samples cluster and leave gaps, and the error decreases as \(1/\sqrt{N}\).
- Stratified \(u\) with candidates in random order: no gain, the stratification of the indices does not reach the domain.
- Stratified \(u\) with ordered candidates: here the subsets interleave a single jittered set of \(8N\) sorted candidates (every \(N\)-th candidate), so each subset covers the whole domain in order. The samples spread evenly and the error is about half as large, at the same \(1/\sqrt{N}\) rate. The strata of \(u\) are assigned to the subsets in random order: each subset alone must receive a uniform \(u\), otherwise the estimate is biased.
12. Spatiotemporal reservoir resampling (ReSTIR)
Problem:
- RIS needs many candidates to approach the target, and each pixel draws its own: in real time, a pixel can only afford a few.
- Neighboring pixels and successive frames often have similar targets: can they share their candidates?
Solution:
A reservoir summarizes all the candidates it has seen, so merging reservoirs costs a few evaluations of the target, whatever their number of candidates. ReSTIR [Bitterli:2020] uses this to reuse the candidates of neighboring pixels (spatial reuse) and of the previous frame (temporal reuse), examples 12.2 to 12.4.
Pros:
- The number of candidates grows with each pass and each frame, at the cost of a few target evaluations per merge, not of new samples or shadow rays.
- Unbiased with the right resampling MIS weights, for samples from different pixels, frames or even domains through shift mappings (GRIS [Lin:2022], section 13.7).
- Visibility reuse: tracing a shadow ray for the selected sample before reusing it discards occluded samples early (biased, but very effective in practice).
Downside:
- Correlation: neighbors share samples, which shows as blotches rather than noise, and the error no longer decreases as \(1/\sqrt{N}\) with the number of reuse passes.
- Bias or cost: the simple weights \(1/M\) are biased when a neighbor’s target vanishes where the pixel’s does not (horizon, occlusion); the generalized balance heuristic evaluates every target at every sample, \(O(k^2)\) for \(k\) reservoirs, while contribution weights computed at the selected sample only [Bitterli:2020] or pairwise MIS [Bitterli:2022] cost \(O(k)\).
- Temporal reuse lags behind moving lights and objects, and disoccluded pixels have no history: the history length \(M\) is capped, trading lag for noise.
- Reusing whole paths needs shift mappings and their Jacobians, which struggle with specular and caustic paths.
12.1 The ReSTIR family
ReSTIR has been extended to most of light transport. A few landmarks, by topic:
- Introduction: the SIGGRAPH course of Wyman et al. [Wyman:2023] presents the theory and the practice of path reuse.
- Direct lighting in production: Wyman and Panteleev [Wyman:2021b] rearchitect ReSTIR for games (decoupled shading, lower memory traffic); at AMD, Tokuyoshi rejects spatial neighbors whose target densities differ [Tokuyoshi:2023] and reduces the shadow noise of visibility reuse [Tokuyoshi:2024]; Zhang et al. resample shadow maps for many lights [Zhang:2025].
- Global illumination: ReSTIR GI [Ouyang:2021] resamples the secondary vertex of one-bounce paths; Boissé [Boisse:2021] stores reservoirs in world space; GRIS [Lin:2022] reuses whole paths with shift mappings (ReSTIR PT); ReSTIR BDPT [Hedstrom:2025] adds bidirectional paths and caustics, and ReSTIR PG [Zeng:2025] uses the resampled paths to guide path sampling.
- Participating media and subsurface scattering: Lin et al. [Lin:2021] resample paths in heterogeneous volumes, with cheap transmittance estimates in the target; Werner et al. [Werner:2024] resample subsurface scattering paths.
- Camera effects: Area ReSTIR [Zhang:2024] reuses samples over the lens and the pixel area for defocus and antialiasing, and reservoir splatting [Liu:2025] handles temporal reuse and motion blur.
- Correlation and theory: conditional RIS [Kettunen:2023] extends GRIS to resampling conditioned on part of a path, and Sawhney et al. [Sawhney:2024] decorrelate the reservoirs with MCMC mutations of their samples.
Example 12.2: Direct illumination with spatial reuse
Each pixel first runs RIS on its own candidates and keeps its reservoir: the selected sample \(y\), its contribution weight \(W\) and its candidate count \(M\). Then each pixel resamples its own reservoir and those of a few neighbors, as if their samples were candidates of its own, with its own target \(\hat{p}\). Merging a reservoir costs target evaluations, not shadow rays, so after a pass each pixel has effectively seen the candidates of its neighbors. The neighbors’ samples come from a different distribution, and the resampling MIS weights \(m_i(y) = M_i\,\hat{p}_i(y) \big/ \sum_j M_j\,\hat{p}_j(y)\) of GRIS [Lin:2022] keep the result unbiased.
Same scene as example 9.2, with one sample per pixel: RIS with the target \(L_e\,G\) and \(M = 16\), followed by one or two passes of spatial reuse with 5 neighbors in a radius of 30 pixels:
Example 12.3: Candidate strategies and resampling MIS weights
The same scene, still one sample and one shadow ray per pixel, with two strategies for the initial candidates: 16 points sampled uniformly on the light, or 8 light points and 8 cosine-weighted BSDF directions that hit the light, combined with the balance heuristic in the resampling weights (\(w = \hat{p} / (M_L\,q_L + M_B\,q_B)\), the per-candidate form of section 13.6). These reservoirs are then reused once, with 5 neighbors, and three kinds of resampling MIS weights for the \(k + 1 = 6\) reservoirs: constant weights \(m_i = M_i / \sum_j M_j\), the generalized balance heuristic \(m_i(y) = M_i\,\hat{p}_i(y) / \sum_j M_j\,\hat{p}_j(y)\), or pairwise MIS [Bitterli:2022], as generalized in GRIS [Lin:2022], which only balances each neighbor against the pixel itself:
Example 12.4: Temporal reuse, visibility reuse and PDF similarity
Real-time ReSTIR runs over frames: here the scene is static and each pixel resamples, every frame, its initial RIS reservoir, its reservoir of the previous frame (temporal reuse, with a history capped at \(20\,M\)) and the reservoir of one neighbor that passes a normal and depth test (spatial reuse). Images are taken after 16 frames, and three improvements are added in turn:
- Visibility reuse [Bitterli:2020] [Wyman:2021b]: a shadow ray is traced for the initial sample and for the spatial neighbor’s sample, an occluded initial sample is discarded, and the pixel is shaded with the visibility of the selected sample, which was already traced: 2 shadow rays per pixel, against 1 for the baseline. Discarding the occluded samples before the reuse darkens the shadows (biased).
- Averaged visibility [Tokuyoshi:2024]: the visibility is the weighted mean \(\sum_i \bar{V}_i\,w_i / \sum_i w_i\) of the reused visibilities, a WIS estimate, instead of the visibility of the selected sample alone; one line of code.
- PDF similarity, a simplified version of Tokuyoshi’s [Tokuyoshi:2023]: each pixel fits a von Mises-Fisher lobe to the temporal average of the directions of its visible selected samples, and a spatial neighbor whose lobe differs (normalized product of the lobes below one half) is rejected, which avoids reusing samples across shadow edges.
13. Multiple weighted importance sampling (MWIS)
Problem:
- We want to reuse samples from several strategies \(q_1, \dots, q_k\) (e.g. paths of other cameras or pixels) for an integral whose natural density is \(p\) (the density of the pixel’s own paths), weighted as if drawn from \(p\).
- MIS (section 7) combines several strategies, WIS (section 8) reweights one strategy towards a target: MWIS does both at once.
Solution:
- Volumetric multi-view rendering [Fraboni:2022].
- Combine WIS and MIS in a single self normalized ratio estimator: a ratio of sums of integrals, where MIS is a sum of integrals.
13.1 Setup and weights
- \(p\) is a normalized target density, \(\int_\Omega p\,\mathrm{d}\mu = 1\).
- Strategy \(i\) draws \(n_i\) independent samples \(X_{i,1}, \dots, X_{i,n_i} \sim q_i\). In total \(N = \sum_i n_i\) samples, with proportions \(c_i = n_i / N\) and mixture density \(\bar{q}(x) = \sum_{j=1}^k c_j\,q_j(x)\).
- Assumptions: \(p(x) > 0\) wherever \(f(x) \neq 0\), and \(\bar{q}(x) > 0\) wherever \(p(x) > 0\) (at least one strategy covers the target).
The MWIS weight of strategy \(i\) is the product of an MIS weight (here the balance heuristic of section 7, the \(q_i\) playing the \(p_i\)) and the WIS weight of section 8:
\[\displaystyle \begin{aligned} w_{i,\text{mis}}(x) &= \frac{c_i\,q_i(x)}{\sum_{j=1}^{k} c_j\,q_j(x)}, \qquad w_{i,\text{wis}}(x) = \frac{p(x)}{q_i(x)}, \\ w_{i,\text{mwis}}(x) &= w_{i,\text{mis}}(x)\,w_{i,\text{wis}}(x) = \frac{c_i\,p(x)}{\bar{q}(x)} \end{aligned}\]These weights are valid because their \(q_i\)-weighted sum rebuilds the target, the MIS weights summing to one (any MIS heuristic with \(\sum_i w_{i,\text{mis}} = 1\) works):
\[\displaystyle \begin{aligned} &\sum_{i=1}^k q_i(x)\,w_{i,\text{mwis}}(x) = p(x)\sum_{i=1}^k w_{i,\text{mis}}(x) = p(x), \\ &\text{so} \quad \sum_{i=1}^k \mathbb{E}_{q_i}\left[w_{i,\text{mwis}}(X)\,g(X)\right] = \int_\Omega g\,p\,\mathrm{d}\mu \quad \text{for any function } g \end{aligned}\]Unlike MIS weights, MWIS weights do not sum to one, \(\sum_{i} w_{i,\text{mwis}}(x) = p(x) / \bar{q}(x) \neq 1\), and need not: only the \(q_i\)-weighted sum above matters, and self normalization makes the estimator insensitive to a global constant factor on the weights.
13.2 The MWIS identity
The MIS weights split the target between the strategies: strategy \(i\) receives the share \(w_{i,\text{mis}}\,p\), of mass \(W_i\), on which \(f/p\) has the weighted mean \(I_i\):
\[\displaystyle \begin{aligned} W_i &= \int_\Omega w_{i,\text{mis}}\,p\,\mathrm{d}\mu = \mathbb{E}_{q_i}\left[w_{i,\text{mwis}}(X)\right], \\ I_i &= \frac{\int_\Omega w_{i,\text{mis}}\,f\,\mathrm{d}\mu}{\int_\Omega w_{i,\text{mis}}\,p\,\mathrm{d}\mu} = \frac{\mathbb{E}_{q_i}\left[w_{i,\text{mwis}}(X)\frac{f(X)}{p(X)}\right]}{\mathbb{E}_{q_i}\left[w_{i,\text{mwis}}(X)\right]} \end{aligned}\]The masses sum to one, \(\sum_i W_i = \int_\Omega p\,\mathrm{d}\mu = 1\), and \(I_i\) is the WIS integral of strategy \(i\), not an estimate of \(I\). Recombining the strategies by mass gives back the integral, since \(\sum_i W_i I_i = \sum_i \int_\Omega w_{i,\text{mis}}\,f\,\mathrm{d}\mu = I\):
\[\displaystyle \begin{aligned} I = \sum_{i=1}^k I_i\,W_i &= \sum_{i=1}^k \frac{\mathbb{E}_{q_i} \left[w_{i, \text{mwis}}(X)\frac{f(X)}{p(X)}\right]}{\mathbb{E}_{q_i}\left[w_{i, \text{mwis}}(X)\right]} \cdot \frac{\mathbb{E}_{q_i} \left[w_{i, \text{mwis}}(X)\right]}{\sum_{j=1}^k \mathbb{E}_{q_j}\left[w_{j,\text{mwis}}(X)\right]} \\ &= \frac{\sum_{i=1}^k\mathbb{E}_{q_i} \left[w_{i, \text{mwis}}(X)\frac{f(X)}{p(X)}\right]}{\sum_{j=1}^k\mathbb{E}_{q_j}\left[w_{j,\text{mwis}}(X)\right]} \end{aligned}\]The identity is exact (the denominator equals one), written as a ratio to be estimated as one.
13.3 The MWIS estimator
Estimating each expectation with its strategy’s samples gives the ratio estimator:
\[\displaystyle \tilde{I}_{\text{mwis}} = \frac{\sum_{i=1}^k \frac{1}{n_i}\sum_{s=1}^{n_i} w_{i,\text{mwis}}(X_{i,s})\,\frac{f(X_{i,s})}{p(X_{i,s})}}{\sum_{i=1}^k \frac{1}{n_i}\sum_{s=1}^{n_i} w_{i,\text{mwis}}(X_{i,s})}\]With the balance heuristic, \(\frac{1}{n_i}\,w_{i,\text{mwis}}(x) = \frac{p(x)}{N\,\bar{q}(x)}\) is the same for every strategy, and the estimator reduces to a weighted mean of the values \(f/p\) over all samples:
\[\displaystyle \begin{aligned} \tilde{I}_{\text{mwis}} &= \frac{\sum_{i,s} \omega(X_{i,s})\,\frac{f(X_{i,s})}{p(X_{i,s})}}{\sum_{i,s} \omega(X_{i,s})} \qquad \text{with} \qquad \omega(x) = \frac{p(x)}{\bar{q}(x)} \\ &= \frac{\frac{1}{N}\sum_{i,s} \frac{f(X_{i,s})}{\bar{q}(X_{i,s})}}{\frac{1}{N}\sum_{i,s} \frac{p(X_{i,s})}{\bar{q}(X_{i,s})}} \end{aligned}\]- The numerator is the balance heuristic MIS estimate of \(I\), the denominator the same estimate for \(p\), whose integral is one: balance MWIS is MIS divided by MIS, i.e. WIS (section 8) with the mixture \(\bar{q}\) as source density.
- Why it helps: the correlated errors of the two MIS estimates cancel in the ratio. The variance of MWIS behaves like that of \((f - I\,p)/\bar{q}\), where MIS has \(f / \bar{q}\) (section 13.5): MWIS removes the part of \(f\) proportional to \(p\), like a control variate of known integral one. If \(f = k\,p\), then \(\tilde{I}_{\text{mwis}} = k = I\) for any samples.
- Using the same samples in numerator and denominator is not required, but it is what makes the errors cancel.
- Cost: as with MIS, every sample needs all the densities \(q_j(x)\), plus the target \(p(x)\).
- As in WIS, and unlike RIS and ReSTIR, \(p\) must be normalized: the numerator does not depend on \(p\), so an unnormalized \(\hat{p} = Z\,p\) would make the estimator converge to \(I/Z\).
Note on the paper’s notation. The paper defines \(w_{i,\text{wis}} = p/(c_i\,q_i)\) (Eq. 19), so that \(w_{i,\text{mwis}} = p/\bar{q}\) for every strategy (Eq. 21), and writes the estimator without the \(1/n_i\) factors (Eq. 17), which is the same estimator. With this convention, the expectation form of the identity (Eq. 16) needs the proportions, \(I = \sum_i c_i\,\mathbb{E}_{q_i}\left[w_{i,\text{mwis}}\,f/p\right] / \sum_j c_j\,\mathbb{E}_{q_j}\left[w_{j,\text{mwis}}\right]\); without the \(c_i\) it only holds for equal \(n_i\). The estimator and the paper’s results are unaffected.
Downside:
- Same as WIS: biased but consistent; the bias is of order \(1/N\) (section 13.5).
13.4 Examples
In 1D. A target \(p\) made of two normal lobes, two strategies \(q_1 = \mathcal{N}(-1.5, 1)\) and \(q_2 = \mathcal{N}(1.5, 1.5^2)\) with equal sample counts (\(c_1 = c_2 = 1/2\)), and an integrand close to, but not proportional to, the target: \(f(x) = p(x)\,(2 + \sin(2x + 1))\).
Robustness to poor sources. Self normalization also makes MWIS robust to poor source samples, the motivation of the paper. A sample falling where \(p\) is negligible has a weight \(\omega = p/\bar{q}\) close to zero and drops out of both sums, while \(B_N\) rescales the estimate by the target mass that the remaining samples captured; in MIS this mass fluctuates and goes straight into the error. Here, with 200 samples per strategy, adding a third strategy that does not touch \(p\) (\(\mathcal{N}(6, 1)\) or \(\mathcal{N}(-4, 0.5^2)\)) leaves both RMSEs unchanged (MIS 0.047, MWIS 0.033): its samples are wasted but harmless. A broad, partly useful one (\(\mathcal{N}(0, 4^2)\)) helps MWIS (0.033 → 0.029) but not MIS (0.047 → 0.046).
In 2D, with uniform sources. Source 1 (orange) is uniform on the unit square, which is also the target \(p\) (as in Fig. 7.4 of my thesis [Fraboni:2021]). Source 2 is uniform on a polygon inside the square, with the same number of samples. The weight \(\omega = p/\bar{q}\) is large outside the polygon, where only source 1 contributes, and smaller inside, where the polygon samples are shared. For an integrand \(f = g\,p\), the balance MIS estimate is \(\frac{1}{N}\sum \omega\,g\) and the MWIS estimate \(\sum \omega\,g \big/ \sum \omega\). They only differ by the division by \(B_N\), a control variate with the fixed coefficient \(I\) (13.3), so the question is for which integrands it helps. (The MIS weights \(w_i = n_i q_i / \sum_k n_k q_k\) alone, as in the thesis figure, are not what MIS uses: they only apportion a sample among the strategies and do not turn it into a sample of \(p\).)
- When \(f\) has a large part proportional to \(p\), the ratio removes it. For \(f = p\) the MIS estimate is \(B_N\), so its whole error is the fluctuation of \(B_N\), and MWIS is exact.
- On small regions the two coincide: there is nothing proportional to \(p\) to remove. A sample from a strong source density where the integrand is small does not hurt MIS either, since its contribution \(f/\bar{q}\) is small, which is why a source that does not touch \(p\) changes neither error in the 1D example above.
- On the polygon, MIS wins. The target is not zero outside the polygon, so the orange samples there keep their large weights in \(B_N\) although they are not in the numerator, and only add noise. This is not a fair use of MWIS, since the target is free to choose.
The target is a design choice. MWIS needs a normalized, tractable \(p\) that is positive wherever \(f \neq 0\) and covered by the sources, not the natural density of the problem. With \(p'\) uniform on the polygon, the samples outside get a weight of exactly zero and vanish from both sums, and for \(f = \mathbb{1}_{\text{polygon}}\,(1 + \frac{1}{2}\sin 6\pi x)\) the ratio \(f/p'\) only varies with the sine.
Matching the target to the support of the integrand is what makes MWIS better than MIS in the right panel, a choice that MIS, which has no target, does not have. The coefficient of the control variate remains fixed at \(I\); whether one estimated from the samples would do better has yet to be tested.
Discarding samples with a Russian roulette. Back in 1D, with a third, poor strategy \(q_3 = \mathcal{N}(0, 4^2)\) added. Each sample \(x\) survives with probability \(a(x) = \min(1, p(x)/\tau)\) and \(f\) is only evaluated on the survivors, so most samples falling where \(p\) is small are dropped. The survival probability does not depend on the strategy: strategy \(i\) now has the density \(a(x)\,q_i(x)\) and the mixture is \(a(x)\,\bar{q}(x)\). The estimators are the same, restricted to the survivors, with \(a\,\bar{q}\) in place of \(\bar{q}\). MIS still divides by \(N\), the number of samples drawn, killed ones included:
\[\displaystyle \tilde{I}_{\text{mis}} = \frac{1}{N}\sum_{\text{kept}} \frac{f(X)}{a(X)\,\bar{q}(X)}, \qquad \tilde{I}_{\text{mwis}} = \frac{\sum_{\text{kept}} \frac{f(X)}{a(X)\,\bar{q}(X)}}{\sum_{\text{kept}} \frac{p(X)}{a(X)\,\bar{q}(X)}}\]- With the exact \(a\), MIS stays unbiased and the roulette adds no bias to MWIS, with about half the evaluations of \(f\). MIS loses precision, as much as plain MIS with as many evaluations. MWIS does not, and is slightly better than plain MWIS: the denominator is an unbiased estimate of one whichever samples are kept, so the ratio rescales the numerator by the mass of \(p\) that the survivors captured.
- If \(a\) is only known up to a constant factor \(\kappa\), as when the survival probability comes from a clamped or approximate ratio, MIS is wrong by that factor, since nothing in the estimator can absorb it. In MWIS the constant cancels between numerator and denominator, and so would the unknown number of samples drawn and killed: only the survivors are needed.
- Ignoring the roulette is not an option: the estimators converge to \(\int a f \big/ \int a\,p\) (MWIS) or \(\int a f\) (MIS) instead of \(I\).
- The cost of the roulette is paid on \(p\) and \(\bar{q}\), which are still evaluated at every sample; only \(f\) is skipped.
- The survival probability must be computable at every sample for every strategy, since \(\bar{q}\) uses all of them: it cannot depend on the other samples, and it must be positive wherever \(f \neq 0\).
13.5 Convergence and bias (proofs)
WIS and MWIS are both a ratio \(\tilde{I} = A_N / B_N\) of two sample means over all samples,
\[\displaystyle \begin{aligned} A_N &= \frac{1}{N}\sum_{i,s} a(X_{i,s}), \qquad a = \frac{f}{\bar{q}}, \\ B_N &= \frac{1}{N}\sum_{i,s} b(X_{i,s}), \qquad b = \frac{p}{\bar{q}} \end{aligned}\](WIS is the case \(k = 1\), \(\bar{q} = q\)). Since \(\sum_i c_i\,q_i = \bar{q}\), their means are \(\mathbb{E}\left[A_N\right] = \sum_i c_i\,\mathbb{E}_{q_i}\left[a(X)\right] = \int_\Omega f\,\mathrm{d}\mu = I\) and \(\mathbb{E}\left[B_N\right] = \int_\Omega p\,\mathrm{d}\mu = 1\). These expectations are finite whenever \(f\) is integrable: \(c_i\,q_i \leq \bar{q}\) gives \(\mathbb{E}_{q_i}\left[\,\lvert a(X) \rvert\,\right] \leq \frac{1}{c_i}\int_\Omega \lvert f \rvert\,\mathrm{d}\mu\) and \(\mathbb{E}_{q_i}\left[b(X)\right] \leq \frac{1}{c_i}\). Below, \(N \to \infty\) with fixed proportions \(c_i\), and \(\tilde{I} = 0\) by convention if \(B_N = 0\) (no sample where \(p > 0\); then \(A_N = 0\) too).
Convergence. By the strong law of large numbers for each strategy, \(\frac{1}{n_i}\sum_s a(X_{i,s}) \to \mathbb{E}_{q_i}\left[a(X)\right]\) almost surely, hence \(A_N = \sum_i c_i\,\frac{1}{n_i}\sum_s a(X_{i,s}) \to I\), and likewise \(B_N \to 1\). As \((u, v) \mapsto u/v\) is continuous at \((I, 1)\),
\[\displaystyle \tilde{I} = \frac{A_N}{B_N} \xrightarrow[N\to\infty]{} I \quad \text{almost surely:}\]the estimator is consistent under the support conditions of 13.1, for any integrable \(f\).
Error. If moreover \(a\) and \(b\) have finite second moments under every \(q_i\), the central limit theorem (per strategy, the strategies being independent) gives \(\sqrt{N}\,(A_N - I,\, B_N - 1) \to \mathcal{N}(0, \Sigma)\) with \(\Sigma = \sum_i c_i\,\mathrm{Cov}_{q_i}\left[(a, b)\right]\). With the gradient \((1, -I)\) of \(u/v\) at \((I, 1)\), the delta method gives
\[\displaystyle \begin{aligned} &\sqrt{N}\,(\tilde{I} - I) \xrightarrow[N\to\infty]{} \mathcal{N}(0, \sigma^2), \\ &\sigma^2 = \sum_{i=1}^k c_i\,\mathrm{Var}_{q_i}\left[a(X) - I\,b(X)\right] = \sum_{i=1}^k c_i\,\mathrm{Var}_{q_i}\left[\frac{f(X) - I\,p(X)}{\bar{q}(X)}\right] \end{aligned}\]so, under the boundedness assumptions of the next paragraph (which make \(N(\tilde{I}-I)^2\) uniformly integrable), the RMSE behaves as \(\sigma/\sqrt{N}\), against \(\sigma_{\text{mis}}/\sqrt{N}\) with \(\sigma^2_{\text{mis}} = \sum_i c_i\,\mathrm{Var}_{q_i}\left[f(X)/\bar{q}(X)\right]\) for balance MIS.
The bias vanishes in \(O(1/N)\). Assume now bounded values and weights: \(\lvert f/p \rvert \leq M\) wherever \(p > 0\), and \(b = p/\bar{q} \leq K\) (both hold in the 1D example). Then \(\lvert I \rvert \leq M\), and \(\lvert \tilde{I} \rvert \leq M\) since \(\tilde{I}\) is a weighted mean of values \(f/p\) with non negative weights. Multiply the exact expansion \(\frac{1}{B} = 1 - (B - 1) + \frac{(B-1)^2}{B}\) for \(B > 0\) by \(A\), with \(A/B = \tilde{I}\):
\[\displaystyle \tilde{I} = A_N - A_N\,(B_N - 1) + \tilde{I}\,(B_N - 1)^2\]which also holds when \(B_N = 0\) (all terms vanish). Taking expectations: \(\mathbb{E}\left[A_N\right] = I\); since \(\mathbb{E}\left[B_N - 1\right] = 0\), \(\mathbb{E}\left[A_N\,(B_N - 1)\right] = \mathrm{Cov}(A_N, B_N)\); and \(\mathbb{E}\left[\tilde{I}\,(B_N - 1)^2\right] = I\,\mathrm{Var}(B_N) + \mathbb{E}\left[(\tilde{I} - I)(B_N - 1)^2\right]\). Hence
\[\displaystyle \begin{aligned} \mathbb{E}\left[\tilde{I}\right] - I = \ &I\,\mathrm{Var}(B_N) - \mathrm{Cov}(A_N, B_N) \\ &+ \mathbb{E}\left[(\tilde{I} - I)(B_N - 1)^2\right] \end{aligned}\]By independence of the samples, \(\mathrm{Var}(B_N) = \frac{1}{N}\sum_i c_i\,\mathrm{Var}_{q_i}\left[b\right]\) and \(\mathrm{Cov}(A_N, B_N) = \frac{1}{N}\sum_i c_i\,\mathrm{Cov}_{q_i}\left[a, b\right]\). For the last term, Cauchy-Schwarz gives \(\left\lvert \mathbb{E}\left[(\tilde{I} - I)(B_N - 1)^2\right] \right\rvert \leq \mathbb{E}\left[(\tilde{I} - I)^2\right]^{1/2}\,\mathbb{E}\left[(B_N - 1)^4\right]^{1/2}\), where \(\mathbb{E}\left[(B_N - 1)^4\right] = O(1/N^2)\) for a mean of \(N\) independent, bounded, centered terms, and \(\mathbb{E}\left[(\tilde{I} - I)^2\right] \to 0\) by dominated convergence (\(\tilde{I} \to I\) almost surely and \(\lvert \tilde{I} - I \rvert \leq 2M\)). The last term is therefore \(o(1/N)\), and
\[\displaystyle \begin{aligned} \mathbb{E}\left[\tilde{I}\right] - I &= \frac{b_1}{N} + o\left(\frac{1}{N}\right), \\ b_1 &= \sum_{i=1}^k c_i\left(I\,\mathrm{Var}_{q_i}\left[b\right] - \mathrm{Cov}_{q_i}\left[a, b\right]\right) = -\sum_{i=1}^k c_i\,\mathrm{Cov}_{q_i}\left[a - I\,b,\ b\right] \end{aligned}\]This is the second order (delta method) expansion of \(\mathbb{E}\left[X/Y\right]\) around the means: \(\frac{\mu_X}{\mu_Y} + \frac{\mu_X\,\mathrm{Var}(Y)}{\mu_Y^3} - \frac{\mathrm{Cov}(X, Y)}{\mu_Y^2}\), with \(\mu_X = I\) and \(\mu_Y = 1\).
- The bias is \(O(1/N)\), while the standard deviation is \(O(1/\sqrt{N})\): the squared bias quickly becomes negligible in the mean squared error.
- If \(f = k\,p\), then \(a = k\,b\) and \(I = k\), so \(b_1 = 0\) and \(\sigma = 0\): the estimator is exactly \(k\) for any \(N\).
- The boundedness assumptions are sufficient, not necessary; with unbounded weights the bias still vanishes under moment conditions, but the remainder needs more care.
13.6 Relation to Talbot’s resampling weights
Justin Talbot’s master’s thesis [Talbot:2005b], which extends the RIS paper of section 9 [Talbot:2005a], already combines several strategies with resampling (its section 4.6, a part that is not in the EGSR paper). I was not aware of it when writing the MWIS paper [Fraboni:2022].
Talbot’s weights. In the notation of 13.1, with an unnormalized target \(\hat{p}\), strategy \(i\) draws \(n_i\) candidates (his \(m_i\), out of \(N\) in total, his \(M\)). All the candidates are pooled into a single RIS step (section 9), the resampling weight of each one being multiplied by an MIS weight, for the balance heuristic
\[\displaystyle w(x) = \frac{n_i\,q_i(x)}{\sum_{k} n_k\,q_k(x)}\,\frac{\hat{p}(x)}{q_i(x)} = w_{i,\text{mis}}(x)\,\frac{\hat{p}(x)}{q_i(x)}\]and the RIS estimator is kept as is: select \(Y\) among the candidates with probability proportional to \(w\), and estimate \(\frac{f(Y)}{\hat{p}(Y)}\,\frac{1}{N}\sum_{i,s} w(X_{i,s})\). This weight is our \(w_{i,\text{mwis}}\) with \(\hat{p}\) in place of \(p\): the MIS times WIS structure of 13.1 is already there. The thesis also presents WIS, but only combines MIS with resampling.
What is odd in the formula. Averaged over the selection, the estimate is \(\frac{1}{N}\sum_{i,s} w(X_{i,s})\,\frac{f(X_{i,s})}{\hat{p}(X_{i,s})}\), and its expectation, strategy by strategy, is
\[\displaystyle \mathbb{E} = \sum_{i=1}^k c_i\,\mathbb{E}_{q_i}\left[w_{i,\text{mis}}(X)\,\frac{f(X)}{q_i(X)}\right] = \int_\Omega f \sum_{i=1}^k c_i\,w_{i,\text{mis}}\,\mathrm{d}\mu\]which equals \(I\) only if \(\sum_i c_i\,w_{i,\text{mis}} = 1\). With two strategies or more this cannot hold, since the MIS weights sum to one and every \(c_i < 1\): with equal allocation the estimator converges to \(I/k\), so two strategies with half the candidates each give exactly half the integral, whatever the heuristic. The weight \(w_{i,\text{mis}}\,\hat{p}/q_i\) is a per-technique weight, made for an estimator that averages each strategy over its own \(n_i\) samples (the \(1/n_i\) of 13.3). Pooling all the candidates under a single \(1/N\) average needs a per-candidate weight instead, \(1/c_i = N/n_i\) times larger:
\[\displaystyle w(x) = \frac{1}{c_i}\,w_{i,\text{mis}}(x)\,\frac{\hat{p}(x)}{q_i(x)} = \frac{\hat{p}(x)}{\bar{q}(x)}\]which is \(\omega\) of 13.3 up to the normalization of the target (the form of the paper’s Eq. 21), and is unbiased in RIS. With equal allocation the printed weight is only off by the constant \(1/k\), which leaves the selection unchanged and scales the normalization alone; the images of the thesis’s Fig. 5.5 do not look half as bright, which suggests a slip in the write-up rather than in the renderer.
Same weight, two estimators. With the corrected weight, RIS selects one candidate \(Y\) with probability proportional to \(\omega\) and returns, unbiased,
\[\displaystyle \hat{I}_{\text{ris}} = \frac{f(Y)}{p(Y)}\,\frac{1}{N}\sum_{i,s}\omega(X_{i,s}) = \frac{f(Y)}{p(Y)}\,B_N\](a constant factor on \(p\) cancels), while MWIS keeps all the candidates in a ratio. The two are exactly linked:
\[\displaystyle \tilde{I}_{\text{mwis}} = \frac{\sum_{i,s}\omega(X_{i,s})\,\frac{f(X_{i,s})}{p(X_{i,s})}}{\sum_{i,s}\omega(X_{i,s})} = \mathbb{E}\left[\frac{f(Y)}{p(Y)} \;\middle\vert\; X_{1,1}, \dots, X_{k,n_k}\right]\]MWIS is the resampling estimate averaged over the selection, with the normalizer \(B_N\) dropped, i.e. replaced by its expectation, one. In the terms of 13.5, RIS averaged over the selection gives \(A_N\), the balance MIS estimate, and MWIS gives \(A_N / B_N\).
- RIS is unbiased, accepts an unnormalized target, and evaluates the integrand at the selected samples only, which pays off when it is costly (visibility) and lets one trade candidates for samples.
- MWIS has no selection noise, every sample contributes, and the division by \(B_N\) cancels the correlated errors (13.3), at the price of a bias in \(O(1/N)\), a normalized target and the integrand at every sample.
When the strategies do not share a domain, the thesis also runs RIS separately for each strategy, with its own target \(\hat{p}_i\), and combines the selected samples with MIS weights computed from the \(\hat{p}_i\) (its section 4.6.2). Any weights that sum to one keep this combination unbiased, but with unnormalized targets the balance heuristic depends on their arbitrary scales.
13.7 Relation to GRIS
Generalized resampled importance sampling (GRIS) [Lin:2022], the theory behind ReSTIR, is concurrent work with the same weight structure, put to a different use. Its preprint appeared in early May 2022; the MWIS paper was online from February 2022 and presented at Eurographics in April, after my thesis (December 2021).
GRIS weights. GRIS resamples one of \(M\) candidates \(X_j\), possibly correlated and coming from other domains through shift mappings \(T_j\), each with an unbiased contribution weight \(W_j\) that stands for \(1/p_{X_j}(X_j)\) when that density is intractable, e.g. after a previous resampling pass. The resampling weights and the contribution weight of the selected sample \(Y\) are (its Eqs. 19 and 22)
\[\displaystyle \begin{aligned} w_j &= m_j(Y_j)\,\hat{p}(Y_j)\,W_j \left\lvert \frac{\partial T_j}{\partial X_j} \right\rvert, \qquad Y_j = T_j(X_j), \\ W_Y &= \frac{1}{\hat{p}(Y)}\sum_{j=1}^M w_j \end{aligned}\]and \(f(Y)\,W_Y\) is an unbiased estimate of \(I\). The resampling MIS weights \(m_j\) must be non negative and sum to one over the candidates that can produce a given point of the target’s support (its Eqs. 4 and 20). The \(1/M\) of basic RIS lives in these weights, which is why \(W_Y\) has none (its footnote 6), and this per-candidate condition is exactly what Talbot’s printed weights miss (13.6); GRIS states them per candidate, \(m_j = p_j / \sum_l p_l\) (its Eq. 5, which it attributes to Talbot’s thesis, written there per candidate as in the corrected form of 13.6). The generalized Talbot weights replace the densities by \(\hat{p}_{\leftarrow j}\), a proxy target of candidate \(j\) carried to the target domain with the shift Jacobian, \(m_j = \hat{p}_{\leftarrow j} / \sum_l \hat{p}_{\leftarrow l}\) (its Eq. 36), and pairwise MIS (Eqs. 37 and 38) lowers the cost from \(O(M^2)\) to \(O(M\,\lvert R \rvert)\) for \(\lvert R \rvert\) canonical candidates. The supplemental document derives both families from a bound on the resampling weights, gives the variants with tractable densities in place of the proxies (its Section S.1.4), and contains no self normalized estimator.
In our notation. With \(n_i\) candidates from \(q_i\), \(N\) in total, tractable densities (\(W = 1/q_i\)) and an unnormalized target \(\hat{p} = Z\,p\), the generalized Talbot weight of a candidate from strategy \(i\) is the balance heuristic split per candidate, and the resampling weight is our \(\omega\):
\[\displaystyle \begin{aligned} m(x) &= \frac{q_i(x)}{N\,\bar{q}(x)} = \frac{w_{i,\text{mis}}(x)}{n_i}, \\ w(x) &= \frac{\hat{p}(x)}{N\,\bar{q}(x)} = \frac{Z}{N}\,\omega(x) = \frac{Z}{n_i}\,w_{i,\text{mwis}}(x) \end{aligned}\]so that \(f(Y)\,W_Y = \frac{f(Y)}{p(Y)}\,B_N\), the corrected RIS estimator of 13.6. With shifts, \(q_i\) is the density of the shifted samples in the target domain, Jacobian included, as for the shifted prefixes of the application below, and the same identity holds with GRIS’s \(p_{\leftarrow i}\) in place of \(q_i\). The weights are the same; the estimators are not:
- GRIS keeps one sample and its random normalization: \(\sum_j w_j = \hat{p}(Y)\,W_Y\) is an unbiased estimate of \(\lVert \hat{p} \rVert = \int \hat{p}\) (its Eq. 24), and \(W_Y \approx \lVert \hat{p} \rVert / \hat{p}(Y)\) for large \(M\) (its Eq. 25).
- MWIS uses that limit in place of \(W_Y\), which requires a normalized target, and averages over the selection: \(\tilde{I}_{\text{mwis}} = \mathbb{E}\left[f(Y)/p(Y) \;\middle\vert\; \text{candidates}\right] = A_N / B_N\), where averaging \(f(Y)\,W_Y\) over the selection gives \(A_N\), the balance MIS estimate.
Neither is a special case of the other: every GRIS estimator has the unbiased form \(f(Y)\,W_Y\), while MWIS divides by the weight sum that GRIS multiplies by. GRIS brings unbiasedness, unnormalized targets, intractable source densities, shift mappings with partial domains, cheap pairwise weights and convergence guarantees for correlated, chained resampling. MWIS brings the self normalization, with no selection noise, the cancellation of correlated errors (13.3) and its \(O(1/N)\) bias analysis (13.5), at the price of tractable source densities, a normalized target and the integrand evaluated at every sample.
13.8 Application: multi-view rendering with the MWIS estimator
- Sequence of N frames: reuse paths sampled from other cameras to reduce the variance of the whole sequence. Instead of rendering frames separately, we render the whole sequence at once.
- Each pixel also receives path prefixes shifted from other cameras: the target \(p\) is the density of the pixel’s own paths, and each camera is a strategy \(q_i\).
- MIS needs the sample count per strategy fixed beforehand: it can keep or discard all the shifted prefixes, but not select the useful ones on the fly without bias. MWIS weights each reused path towards the pixel’s own density, so poorly matching paths get small weights.
- Self normalization only absorbs a global constant factor: a path dependent reuse probability must be included in the densities \(q_i\).
- Can work with animated scenes: reuse paths at a fixed time, overlap the shutter windows of the cameras \(\rightarrow\) variance reduction in motion blur.
14. To learn for next time
- Markov Chain Monte Carlo: it is easier without pdfs ¯\_(ツ)_/¯
- idea: start from a random sample, try random mutations of the sample, accept a mutation with probability \(\alpha=\frac{f(x_{i+1})}{f(x_i)}\); after a lot of mutations the target distribution is reproduced.
- Metropolis, Primary Sample Space Metropolis, Reversible Jump Metropolis, Monte Carlo Langevin (Metropolis + gradient), Hamiltonian Monte Carlo (Metropolis + momentum), …
- Adaptive importance sampling: learn the pdf.
- idea: start from proposal pdfs \(q_i\) and iteratively refine them during the integration to match a target distribution \(p\) (multi stage methods).
- Cross entropy.
- Population Monte Carlo.
- Piecewise AIS: Vegas, …
- Control variates: learn (a part of) the estimator.
- idea: use an unbiased estimate of \(I\) to reduce the error of the estimator.
- often multi stage, to estimate the parameters that allow the error reduction.
- Antithetic variates.
- idea: take antithetic samples (\(u'=1-u\)) to reduce the variance of the estimator.
-
Still, there is room for improvement and for new applications of self normalized ratio estimators (WIS, MWIS, others), which have been shunned in offline rendering:
“Why did offline-rendering people publish several papers on control variates and (to our knowledge) never published a ratio estimator, which is simpler and better?” - Eric Heitz [Heitz:2018]
References
- A. G. M. Ahmed, H. Perrier, D. Coeurjolly, V. Ostromoukhov, J. Guo, D.-M. Yan, H. Huang, O. Deussen, Low-Discrepancy Blue Noise Sampling, ACM Transactions on Graphics 35(6) (SIGGRAPH Asia), 2016.
- B. Bitterli, Rendering resources, scene “Veach, MIS” (CC0), 2016.
- B. Bitterli, C. Wyman, M. Pharr, P. Shirley, A. Lefohn, W. Jarosz, Spatiotemporal Reservoir Resampling for Real-Time Ray Tracing with Dynamic Direct Lighting, ACM Transactions on Graphics 39(4) (SIGGRAPH), 2020.
- B. Bitterli, Correlations and Reuse for Fast and Accurate Physically Based Light Transport, PhD thesis, Dartmouth College, 2022.
- G. Boissé, World-Space Spatiotemporal Reservoir Reuse for Ray-Traced Global Illumination, SIGGRAPH Asia 2021 Technical Communications.
- P. Christensen, A. Kensler, C. Kilpatrick, Progressive Multi-Jittered Sample Sequences, Computer Graphics Forum 37(4) (EGSR), 2018.
- E. Ciklabakkal, A. Gruson, I. Georgiev, D. Nowrouzezahrai, T. Hachisuka, Single-Pass Stratified Importance Resampling, Computer Graphics Forum 41(4) (EGSR), 2022 (project page).
- R. L. Cook, Stochastic Sampling in Computer Graphics, ACM Transactions on Graphics 5(1), 1986.
- F. de Goes, K. Breeden, V. Ostromoukhov, M. Desbrun, Blue Noise through Optimal Transport, ACM Transactions on Graphics 31(6) (SIGGRAPH Asia), 2012.
- B. Fraboni, Self-normalized estimators and joint path construction for efficient multi-view rendering, PhD thesis, INSA Lyon, 2021.
- B. Fraboni, A. Webanck, N. Bonneel, J.-C. Iehl, Volumetric Multi-View Rendering, Computer Graphics Forum 41(2) (Eurographics), 2022.
- P. Grittmann, I. Georgiev, P. Slusallek, J. Křivánek, Variance-Aware Multiple Importance Sampling, ACM Transactions on Graphics 38(6) (SIGGRAPH Asia), 2019.
- T. Hedstrom, M. Kettunen, D. Lin, C. Wyman, T.-M. Li, ReSTIR BDPT: Bidirectional ReSTIR Path Tracing with Caustics, ACM Transactions on Graphics 44(5), 2025.
- E. Heitz, S. Hill, M. McGuire, Combining Analytic Direct Illumination and Stochastic Shadows, ACM SIGGRAPH Symposium on Interactive 3D Graphics and Games 2018.
- W. Jarosz, A. Enayet, A. Kensler, C. Kilpatrick, P. Christensen, Orthogonal Array Sampling for Monte Carlo Rendering, Computer Graphics Forum 38(4) (EGSR), 2019.
- M. Kettunen, D. Lin, R. Ramamoorthi, T. Bashford-Rogers, C. Wyman, Conditional Resampled Importance Sampling and ReSTIR, SIGGRAPH Asia 2023 Conference Papers.
- I. Kondapaneni, P. Vévoda, P. Grittmann, T. Skřivan, P. Slusallek, J. Křivánek, Optimal Multiple Importance Sampling, ACM Transactions on Graphics 38(4) (SIGGRAPH), 2019.
- D. Lin, C. Wyman, C. Yuksel, Fast Volume Rendering with Spatiotemporal Reservoir Resampling, ACM Transactions on Graphics 40(6) (SIGGRAPH Asia), 2021.
- D. Lin, M. Kettunen, B. Bitterli, J. Pantaleoni, C. Yuksel, C. Wyman, Generalized Resampled Importance Sampling: Foundations of ReSTIR, ACM Transactions on Graphics 41(4) (SIGGRAPH), 2022 (project page, supplemental document).
- J. Liu, D. Lin, M. Kettunen, C. Wyman, R. Ramamoorthi, Reservoir Splatting for Temporal Path Resampling and Motion Blur, SIGGRAPH 2025 Conference Papers.
- Framestore, Academy Software Foundation, OpenQMC: a quasi-Monte Carlo sampling library for rendering, header-only C++17 library, 2025 (announcement).
- Y. Ouyang, S. Liu, M. Kettunen, M. Pharr, J. Pantaleoni, ReSTIR GI: Path Resampling for Real-Time Path Tracing, Computer Graphics Forum 40(8) (HPG), 2021.
- L. Paulin, N. Bonneel, D. Coeurjolly, J.-C. Iehl, A. Webanck, M. Desbrun, V. Ostromoukhov, Sliced Optimal Transport Sampling, ACM Transactions on Graphics 39(4) (SIGGRAPH), 2020.
- M. Roberts, The Unreasonable Effectiveness of Quasirandom Sequences, blog post, 2018.
- R. Sawhney, D. Lin, M. Kettunen, B. Bitterli, R. Ramamoorthi, C. Wyman, M. Pharr, Decorrelating ReSTIR Samplers via MCMC Mutations, ACM Transactions on Graphics 43(1), 2024.
- P. Shirley, S. Laine, D. Hart, M. Pharr, P. Clarberg, E. Haines, M. Raab, D. Cline, Sampling Transformations Zoo, Ray Tracing Gems, Chapter 16, Apress, 2019.
- J. F. Talbot, D. Cline, P. Egbert, Importance Resampling for Global Illumination, Eurographics Symposium on Rendering 2005.
- J. F. Talbot, Importance Resampling for Global Illumination, Master’s thesis, Brigham Young University, 2005.
- Y. Tokuyoshi, Efficient Spatial Resampling Using the PDF Similarity, Proceedings of the ACM on Computer Graphics and Interactive Techniques 6(1) (I3D), 2023.
- Y. Tokuyoshi, Efficient Visibility Reuse for Real-time ReSTIR, SIGGRAPH Talks 2024.
- H. F. Trotter, J. W. Tukey, Conditional Monte Carlo for Normal Samples, Symposium on Monte Carlo Methods (H. A. Meyer, ed.), Wiley, pp. 64–79, 1956.
- H. Perrier, D. Coeurjolly, V. Ostromoukhov, Uni(corn|form) Tool Kit, point set generation and analysis library.
- E. Veach, L. J. Guibas, Optimally Combining Sampling Techniques for Monte Carlo Rendering, SIGGRAPH 1995.
- M. Werner, V. Schüßler, C. Dachsbacher, ReSTIR Subsurface Scattering for Real-Time Path Tracing, Proceedings of the ACM on Computer Graphics and Interactive Techniques 7(3) (HPG), 2024.
- C. Wyman, Weighted Reservoir Sampling: Randomly Sampling Streams, Ray Tracing Gems II, Chapter 22, Apress, 2021.
- C. Wyman, A. Panteleev, Rearchitecting Spatiotemporal Resampling for Production, High-Performance Graphics 2021.
- C. Wyman, M. Kettunen, D. Lin, B. Bitterli, C. Yuksel, W. Jarosz, P. Kozlowski, A Gentle Introduction to ReSTIR: Path Reuse in Real-Time, SIGGRAPH 2023 Courses.
- Z. Zeng, M. Kettunen, C. Wyman, L. Wu, R. Ramamoorthi, L.-Q. Yan, D. Lin, ReSTIR PG: Path Guiding with Spatiotemporally Resampled Paths, SIGGRAPH Asia 2025 Conference Papers.
- S. Zhang, D. Lin, M. Kettunen, C. Yuksel, C. Wyman, Area ReSTIR: Resampling for Real-Time Defocus and Antialiasing, ACM Transactions on Graphics 43(4) (SIGGRAPH), 2024.
- S. Zhang, D. Lin, C. Wyman, C. Yuksel, Many-Light Rendering Using ReSTIR-Sampled Shadow Maps, Computer Graphics Forum 44(2) (Eurographics), 2025.