arXiv:2611.05238stat.MENov 2026

Manuscript Offprint

arXiv:2611.05238

Post-stratified importance sampling

Yuling Yao, Sergei Tikhonov

Abstract

Importance sampling is a building block of modern statistical computing, but the weighted estimate is prone to high or infinite variance. Moreover, its empirical standard error is often unreliable, leaving importance sampling without practical uncertainty quantification. Motivated by multilevel regression and poststratification (MRP) in survey sampling, we propose post-stratified importance sampling (PIS) for estimating target expectations from proposal draws. PIS reformulates arbitrarily high-dimensional weighting into two one-dimensional probabilistic modeling problems: regression for the conditional mean given the importance ratio and marginal density estimation for the importance ratio. Different modeling choices yield a family of PIS estimators, encompassing ordinary importance sampling as a special case. We develop a model-based implementation that combines one-dimensional Gaussian process regression for the conditional mean and score-informed heavy-tailed density estimation for the marginal law, using both the observed weights and the available density evaluations. We study the oracle gains of PIS and establish consistency under general and model-specific conditions. Simulations and applications to cross-validation demonstrate improvements in estimation accuracy and uncertainty quantification.

Keywords: Bayesian computation, importance sampling, heavy-tailed density, poststratification, score-based Monte Carlo, uncertainty quantification

1. Introduction

The task of importance sampling. Consider the general task of computing expectations: we are given a target density p(θ)p(\theta) on θ∈Rd\theta \in \mathbb{R}^d, and our goal is to compute the target expectation of an arbitrary scalar function h(θ)h(\theta),

μ=Ep[h(θ)]:=∫Rdh(θ)p(θ)dθ.(1)\mu = \mathbb{E}_p[h(\theta)] := \int_{\mathbb{R}^d} h(\theta)p(\theta)d\theta. \tag{1}

Instead of sampling from the target pp, we draw an independent and identically distributed (IID) sample from a given proposal density qq,

θ1,θ2,…,θS∼q(θ).\theta_1, \theta_2, \ldots, \theta_S \sim q(\theta).

In practice, target and proposal densities may be known only up to normalizing constants. We write pp and qq for the evaluable, possibly unnormalized density functions, and use Ep[⋅]\mathbb{E}_p[\cdot] for expectation under the normalized distribution proportional to pp. Define the importance ratio function

w=r(θ):=p(θ)q(θ).w = r(\theta) := \frac{p(\theta)}{q(\theta)}.

Here we denote r(⋅):Rd→[0,∞)r(\cdot): \mathbb{R}^d \to [0, \infty) as a deterministic function of θ\theta, and ww as the induced scalar random variable. We also write ws=r(θs)w_s = r(\theta_s), the ss-th realized importance weight sample.

*Department of Statistics and Data Science, University of Texas at Austin

Depending on whether pp and qq are normalized, the classical importance sampling (IS) or self-normalized importance sampling estimate of the target expectation μ\mu is the weighted sample mean

Ep[h(θ)]={μ^IS≔S−1∑s=1Swsh(θs),when normalized,μ^SNIS≔∑s=1Swsh(θs)∑s=1Sws,when unnormalized.(2)\mathbb{E}_{p}[h(\theta)]=\begin{cases}\hat{\mu}_{\mathrm{IS}}\coloneqq S^{-1}\sum_{s=1}^{S} w_{s} h(\theta_{s}),&\text{when normalized},\\\hat{\mu}_{\mathrm{SNIS}}\coloneqq\frac{\sum_{s=1}^{S} w_{s} h(\theta_{s})}{\sum_{s=1}^{S} w_{s}},&\text{when unnormalized}.\end{cases} \tag{2}

Why importance sampling is still important, and why it is fragile. Beyond its use as a stand-alone estimator, importance sampling often serves as a reweighting step within larger downstream algorithms, many of which are widely used in modern statistical workflows. To name a few, In Bayesian model evaluation, the leave-one-out (LOO) predictive quantities are expectations under the leave-one-out posterior pi(θ)∝π(θ∣y−i)p_i(\theta) \propto \pi(\theta \mid y_{-i}). Exact LOO requires refitting the model for deleting every data point. Instead, importance-sampling-based LOO (Gelfand et al., 1992; Peruggia, 1997; Vehtari et al., 2017; Magnusson et al., 2019; Bürkner et al., 2020) reuses the full posterior proposal q(θ)∝π(θ∣y)q(\theta) \propto \pi(\theta \mid y) weighted by the inverse likelihood ri(θ)=π−1(yi∣θ)r_i(\theta) = \pi^{-1}(y_i|\theta). In recursive Bayesian computing (Doucet et al., 2001; Chopin, 2002; Hooten et al., 2021), importance sampling is used to approximate expectations under a sequence of on-line targets. Draws from a previous distribution are reweighted by an incremental likelihood factor ri(θ)=π(θ∣yi)r_i(\theta) = \pi(\theta \mid y_i) to approximate the updated posterior expectations. In sensitivity analysis, given posterior draws under one fixed model, prior, temperature, or dataset, importance sampling can approximate expectations under a tilted posterior (Smith and Gelfand, 1992; Kallioinen et al., 2024). In approximate inference, importance sampling reweighs variational samples for better calibration and diagnostics (Yao et al., 2018b). Conversely, using importance sampling inside variational objective tightens the evidence lower bound and leads to importance weighted variational inference (Burda et al., 2016; Domke and Sheldon, 2018).

Despite its wide deployment and asymptotic consistency, the weighted estimate (2) remains fragile (Vehtari et al., 2024). The usual central limit theorem requires a finite second moment of the weighted integrand, which often fails in practice. For example, even for a pair of Gaussian target and proposal, p=normal(0,σp)p = \text{normal}(0, \sigma_p) and q=normal(0,σq)q = \text{normal}(0, \sigma_q), then Eq[w2]=∞\mathbb{E}_q[w^2] = \infty as soon as 2σq2≤σp22\sigma_q^2 \leq \sigma_p^2. That is, under a modest scale mismatch, the S−1/2S^{-1/2} Monte Carlo convergence rate no longer applies to the IS estimate. In general, the required sample size SS grows exponentially in the target-proposal discrepancy (Chatterjee and Diaconis, 2018); when this discrepancy scales linearly with parameter dimension dd, the sample size SS is required at the order exp⁡(d)\exp(d). This curse of dimensionality rapidly makes direct importance weighting prohibitive in a moderate dimensional space.

Uncertainty quantification is challenging. Beyond its instability and potentially high or infinite variance, the weighted estimator (2) often lacks reliable uncertainty quantification. The usual sample variance estimate (Geweke, 1989) relies on the weighted empirical second moments:

Var^(μ^)={1S2∑s=1S(wsh(θs)−μ^IS)2,normalized IS,∑s=1Sws2(h(θs)−μ^SNIS)2(∑s=1Sws)2,self-normalized IS.(3)\widehat{\mathrm{Var}}(\hat{\mu})=\begin{cases}\frac{1}{S^{2}}\sum_{s=1}^{S}\left(w_{s}h(\theta_{s})-\hat{\mu}_{\mathrm{IS}}\right)^{2},&\text{normalized IS},\\\frac{\sum_{s=1}^{S}w_{s}^{2}\left(h(\theta_{s})-\hat{\mu}_{\mathrm{SNIS}}\right)^{2}}{\left(\sum_{s=1}^{S}w_{s}\right)^{2}},&\text{self-normalized IS}.\end{cases} \tag{3}

This variance estimate can be unreliable for three reasons: (i) The underlying population variance may not exist. When Eq[w2]=∞\mathbb{E}_q[w^2] = \infty, the variance of the IS estimate can be infinite even for bounded hh, and the sample variance is meaningless. (ii) Even when the variance is finite, when the importance ratios ww are heavy-tailed, this empirical variance is dominated by a small number of extreme weights ww, even more severely than the mean as the variance involves the quadratic weight w2w^2. (iii) The self-normalized IS estimator is a ratio of dependent random variables and is O(1/S)O(1/S) biased. The empirical variance does not fully assess the mean squared error.

The limitation of the sample variance has motivated several alternative IS diagnostics. Pareto smoothed importance sampling (PSIS, Vehtari et al., 2024) instead reports the estimated Pareto tail index k^\hat{k} of the marginal distribution of ww, while Chatterjee and Diaconis (2018) proposes to monitor max⁡ws/∑ws\max w_s / \sum w_s. These diagnostics appear more stable than the classical effective sample size (ESS, Kong, 1992; Elvira et al., 2022), and are useful qualitative indicators of whether an IS estimate should be trusted at all, but they still do not provide a calibrated uncertainty statement or confidence interval for the IS estimate. For this difficulty, the Monte Carlo uncertainty is often ignored or reduced to a diagnostic warning in many current statistical workflows involving importance sampling, such as model comparison, selection, and averaging (e.g., Vehtari et al., 2017; Yao et al., 2018a), despite the necessity to propagate it to downstream decision analysis.

Proposed method: Outline of poststratified importance sampling (PIS). We aim at the general importance sampling task: we can evaluate the continuous but potentially unnormalized target and proposal densities p(θ)p(\theta) and q(θ)q(\theta), and we have IID draws θ1,θ2,…,θS∼q(θ)\theta_1, \theta_2, \ldots, \theta_S \sim q(\theta). Our new strategy is to continuously stratify the distribution by the scalar importance ratio w=r(θ)w = r(\theta). Then we rearrange the target expectation using the law of total expectation

Ep[h(θ)]=Ep[Ep[h(θ)∣w]]=∫0∞pw(w)Ep[h(θ)∣w]dw.(4)\mathbb{E}_{p}[h(\theta)]=\mathbb{E}_{p}\left[\mathbb{E}_{p}[h(\theta)\mid w]\right]=\int_{0}^{\infty}p_{w}(w)\mathbb{E}_{p}[h(\theta)\mid w]dw. \tag{4}

Here Ep[h(θ)∣w]\mathbb{E}_{p}[h(\theta)\mid w] denotes the conditional expectation given r(θ)=wr(\theta)=w, and pw(w)p_{w}(w) denotes the marginal density of the scalar random variable ww, both under θ∼p\theta\sim p; see Section 1.1 for a formal notation.

We develop poststratified importance sampling (PIS), a framework for computing Ep[h(θ)]\mathbb{E}_{p}[h(\theta)] based on the identity (4). It follows the motivation of multilevel regression and poststratification (MRP, Gelman and Little, 1997) in survey sampling. While MRP partitions a population into demographic strata and averages fitted stratum-level outcomes, PIS uses the scalar importance ratio w=r(θ)w=r(\theta) as a continuous stratification variable. This representation admits a Rao-Blackwellization interpretation: we replace the original integrand h(θ)h(\theta) with the conditional expectation Ep[h(θ)∣w]\mathbb{E}_{p}[h(\theta)\mid w], and then average over the marginal law pw(w)p_{w}(w).

Both the (a) conditional expectation and (b) marginal law are unknown and must be estimated. Different modeling choices for these two objects yield a family of PIS estimators by plugging in (4),

μ^PIS=∫0∞p^w(w)E^p[h(θ)∣w]dw.(5)\hat{\mu}_{\mathrm{PIS}}=\int_{0}^{\infty}\hat{p}_{w}(w)\hat{\mathbb{E}}_{p}[h(\theta)\mid w]dw. \tag{5}

This general PIS framework recovers the classical importance weighting (2) as a degenerate special case. That is, if we adopt a “model-free” implementation,

  • estimate the conditional expectation using an unsmoothed estimate E^p[h(θ)∣wi]≈h(θi)\hat{\mathbb{E}}_{p}[h(\theta)\mid w_{i}] \approx h(\theta_{i}),

  • estimate the marginal law empirically q^w(w)≈S−1∑i=1S1(w=wi)\hat{q}_{w}(w) \approx S^{-1} \sum_{i=1}^{S} \mathbf{1}(w=w_{i}).

For the equivalence that we will develop in Section (2), this empirical q^(w)\hat{q}(w) implies p^(w)=S−1wi∑i=1S1(w=wi)\hat{p}(w) = S^{-1}w_{i} \sum_{i=1}^{S} \mathbf{1}(w=w_{i}) (when normalized) or p^(w)≈∑i=1Swi1(w=wi)/∑i=1Swi\hat{p}(w) \approx \sum_{i=1}^{S} w_{i} \mathbf{1}(w=w_{i}) / \sum_{i=1}^{S} w_{i} (when unnormalized). Thus, plugging-in this E^p[h(θ)∣w]\hat{\mathbb{E}}_{p}[h(\theta)\mid w] and p^(w)\hat{p}(w), the PIS estimate μ^PIS\hat{\mu}_{\mathrm{PIS}} becomes the classical (self-normalized) importance weighting (2).

Unsurprisingly, both Ep[h(θ)∣w]\mathbb{E}_{p}[h(\theta)\mid w] and qw(w)q_{w}(w) can admit more efficient estimates:

  • The unsmoothed conditional mean estimate amounts to a degenerating, interpolating regression. It infers the conditional mean at input wsw_s using a single observation h(θi)h(\theta_i), without pooling information across samples.

  • The empirical estimate puts mass only on the observed weights, applies no tail smoothing, and discards additional information available from the density evaluation. Its extrapolation can be especially poor when qw(w)q_w(w) is heavy-tailed.

These limitations motivate regularization and information sharing. We implement PIS in three steps:

  1. Conditional mean via one-dimensional regression. We fit a model-based regression to estimate the conditional expectation Ep[h(θ)∣wi]\mathbb{E}_p[h(\theta) \mid w_i] using θ\theta samples from qq, typically a Gaussian process regression. This step uses the identity Ep[h(θ)∣w]=Eq[h(θ)∣w]\mathbb{E}_p[h(\theta) \mid w] = \mathbb{E}_q[h(\theta) \mid w].

  2. Marginal law via one-dimensional score-based heavy-tail estimation. We estimate the marginal density pw(w)p_w(w) and qw(w)q_w(w) using a flexible Dirichlet process mixture with a generalized Pareto tail for the distribution of ww. Our density estimation not only uses the sample wiw_i, but also incorporates score evaluations of the densities p(θi)p(\theta_i) and q(θi)q(\theta_i), and this score information improves the tail estimation.

  3. Aggregation via one-dimensional quadrature. After obtaining functional estimates of Ep[h(θ)∣w]\mathbb{E}_p[h(\theta) \mid w] and pw(w)p_w(w), we adopt one-dimensional numerical integration in (5) to obtain the PIS estimate.

The modeling formulation also supports uncertainty quantification and model checking. The modeling formulation also supports uncertainty quantification and model checking. Monte Carlo draws propagate uncertainty in the regression and marginal density estimates to the final PIS estimate, while posterior predictive checks can assess the adequacy of both models.

References (38)