← Notes · December 2026

Bayesian nonparametric ensembles: some theory

Combining exposure models with spatially varying weights, a bias process and a calibrated predictive distribution: the Gaussian process structure, shrinkage, uncertainty decomposition and distributional warping, with proofs.

Air pollution exposure is usually estimated by several models at once: chemical transport models, satellite-based models and machine learning models. Each is accurate in some places and biased in others. A simple average ignores this, and a fixed set of weights cannot follow it across space and time. The Bayesian Nonparametric Ensemble (BNE) of Liu et al. (2019) combines models with weights that vary in space and time, corrects their joint bias, and calibrates the full predictive distribution. These notes set out the mathematics behind it.

1. The model

Let \(f_1(x),\dots,f_K(x)\) be predictions from \(K\) base models at a space-time location \(x\), and \(y\) the observed concentration. BNE models the predictive distribution as

\[ \Pr(y \le v \mid x) = G_x\big[\Phi(v \mid x, \mu)\big], \qquad \mu(x) = \sum_{k=1}^K f_k(x)\,\omega_k(x) + \delta(x), \]

where \(\Phi(\cdot\mid x,\mu)\) is a Gaussian CDF with mean \(\mu(x)\) and variance \(\sigma_\varepsilon^2\), and

2. Constant weights: Bayesian stacking

Start with the simplest case: constant weights, no \(\delta\), no warping. With \(\mathbf f(x) = (f_1(x),\dots,f_K(x))^\top\) and data \((x_i,y_i)_{i=1}^N\), the model is \(y_i = \mathbf f(x_i)^\top\omega + \varepsilon_i\) with \(\varepsilon_i\sim\mathcal N(0,\sigma_\varepsilon^2)\) and prior \(\omega\sim\mathcal N(0,\sigma_\omega^2 I)\).

Proposition 1. Let \(F\) be the \(N\times K\) matrix with rows \(\mathbf f(x_i)^\top\). The posterior is \(\omega \mid y \sim \mathcal N(m, S)\) with \[ S = \Big(\frac{F^\top F}{\sigma_\varepsilon^2} + \frac{I}{\sigma_\omega^2}\Big)^{-1}, \qquad m = \frac{S F^\top y}{\sigma_\varepsilon^2}, \] and the predictive distribution at a new \(x\) is Gaussian with mean \(\mathbf f(x)^\top m\) and variance \[ \underbrace{\sigma_\varepsilon^2}_{\text{noise}} \;+\; \underbrace{\mathbf f(x)^\top S\, \mathbf f(x)}_{\text{weight uncertainty}} . \]

Proof. The log posterior is \(-\frac{1}{2\sigma_\varepsilon^2}\|y - F\omega\|^2 - \frac{1}{2\sigma_\omega^2}\|\omega\|^2\) up to a constant, a quadratic in \(\omega\). Completing the square gives precision \(S^{-1}\) and mean \(m\). For prediction, \(y = \mathbf f(x)^\top\omega + \varepsilon\) is a sum of independent Gaussians with variances \(\mathbf f(x)^\top S\mathbf f(x)\) and \(\sigma_\varepsilon^2\). \(\square\)

The second term depends on direction. When base models are nearly collinear, the posterior is tight along the direction in which they agree and wide in the direction of their difference. So predictions are confident where the models agree, and uncertain where they disagree (Exercise 2).

3. Spatially varying weights as a Gaussian process

Lemma 2 (additive kernel). Suppose \(\omega_k \sim \mathcal{GP}(m_k, k_\omega)\) independently for \(k=1,\dots,K\), and \(\delta \sim \mathcal{GP}(0, k_\delta)\) independently of them. Then \(\mu(x) = \sum_k f_k(x)\omega_k(x) + \delta(x)\) is a Gaussian process with mean \(\sum_k f_k(x) m_k(x)\) and covariance \[ K_\mu(x,x') = \Big(\sum_{k=1}^K f_k(x) f_k(x')\Big) k_\omega(x,x') + k_\delta(x,x'). \]

Proof. For any finite set of locations, \(\mu\) is a linear combination of jointly Gaussian variables, so it is jointly Gaussian. Its mean is linear. By independence, \(\operatorname{Cov}(\mu(x),\mu(x')) = \sum_k f_k(x)f_k(x')\operatorname{Cov}(\omega_k(x),\omega_k(x')) + \operatorname{Cov}(\delta(x),\delta(x'))\). \(\square\)

So, before warping, BNE is Gaussian process regression with a kernel built from the base models themselves. Two locations are strongly correlated when they are close and the base models predict similar values there. Posterior means and variances follow from the standard formulas: with \(\mathbf K\) the kernel matrix at the data, \(\mathbf k_x\) the vector \(K_\mu(x,x_i)\) and prior mean \(\bar\mu\),

\[ \mathbb E[\mu(x)\mid y] = \bar\mu(x) + \mathbf k_x^\top(\mathbf K + \sigma_\varepsilon^2 I)^{-1}(y - \bar\mu), \qquad \operatorname{Var}[\mu(x)\mid y] = K_\mu(x,x) - \mathbf k_x^\top(\mathbf K+\sigma_\varepsilon^2 I)^{-1}\mathbf k_x . \]
Proposition 3 (shrinkage away from data). Suppose \(k_\omega(x,x')\to0\) and \(k_\delta(x,x')\to0\) as \(\|x-x'\|\to\infty\), and the \(f_k\) are bounded. As a location \(x\) moves away from all observations, the posterior mean of \(\mu(x)\) tends to the prior mean \(\sum_k f_k(x)m_k(x)\), and the posterior variance tends to the prior variance \(K_\mu(x,x)\).

Proof. Each entry \(K_\mu(x,x_i)\) is a bounded multiple of \(k_\omega(x,x_i)\) plus \(k_\delta(x,x_i)\), so \(\mathbf k_x\to0\). Both correction terms above are continuous in \(\mathbf k_x\) and vanish at \(\mathbf k_x=0\). \(\square\)

With equal prior weights \(m_k = 1/K\), this means BNE falls back to the plain average of the base models where there are no monitors, and it says so by reporting larger uncertainty. Near monitors, it learns which models to trust and corrects their shared bias. This is the behaviour one wants for exposure maps, where monitors are sparse and unevenly placed.

4. Decomposing uncertainty

Write \(\Theta\) for all unknowns (weights, residual process, warping, hyperparameters).

Proposition 4 (law of total variance). For the posterior predictive distribution at \(x\), \[ \operatorname{Var}(y\mid x, \mathcal D) = \underbrace{\mathbb E_{\Theta\mid\mathcal D}\big[\operatorname{Var}(y\mid x,\Theta)\big]}_{\text{aleatoric}} + \underbrace{\operatorname{Var}_{\Theta\mid\mathcal D}\big(\mathbb E[y\mid x,\Theta]\big)}_{\text{epistemic}} . \] If \(\Theta = (\Theta_1,\Theta_2)\), the epistemic part splits further as \[ \operatorname{Var}\big(\mathbb E[y\mid\Theta]\big) = \mathbb E_{\Theta_2}\Big[\operatorname{Var}_{\Theta_1\mid\Theta_2}\big(\mathbb E[y\mid\Theta]\big)\Big] + \operatorname{Var}_{\Theta_2}\Big(\mathbb E_{\Theta_1\mid\Theta_2}\,\mathbb E[y\mid\Theta]\Big). \]

Proof. Both identities are the law of total variance, \(\operatorname{Var}(Z) = \mathbb E[\operatorname{Var}(Z\mid W)] + \operatorname{Var}(\mathbb E[Z\mid W])\), applied first with \(Z = y\), \(W = \Theta\), and then with \(Z = \mathbb E[y\mid\Theta]\), \(W = \Theta_2\). \(\square\)

Remark. The aleatoric part is the noise that remains even with a perfect model; the epistemic part comes from not knowing the model. The finer split, for example into uncertainty due to the weights and due to the residual process, depends on the order of conditioning unless the two are independent in the posterior. Reported decompositions should state the order they use.

5. Calibrating the predictive distribution

A Gaussian predictive distribution may be too narrow, too wide or skewed compared with reality. The warping \(G_x\) fixes this, and the next result shows it is flexible enough to fix any such error.

Proposition 5 (warping is fully general). Let \(\Phi\) be a continuous, strictly increasing model CDF and \(F\) the true continuous CDF of \(Y\) at \(x\). Define \(G(u) = F(\Phi^{-1}(u))\) for \(u\in(0,1)\). Then
  1. \(G\) is non-decreasing, with \(G(u)\to0\) as \(u\to0\) and \(G(u)\to1\) as \(u\to1\);
  2. \(F = G\circ\Phi\);
  3. \(G\) is the CDF of the probability integral transform \(U = \Phi(Y)\);
  4. \(G\) is the identity if and only if \(\Phi = F\), that is, the model is calibrated.

Proof. (1) is a composition of non-decreasing functions with the stated limits. (2) is immediate: \(G(\Phi(v)) = F(\Phi^{-1}(\Phi(v))) = F(v)\). For (3), \(\Pr(\Phi(Y)\le u) = \Pr(Y \le \Phi^{-1}(u)) = F(\Phi^{-1}(u)) = G(u)\). For (4), \(G(u) = u\) for all \(u\) means \(F(\Phi^{-1}(u)) = u\), so \(F = \Phi\), and conversely. \(\square\)

So a monotone warping of a Gaussian CDF can represent any continuous predictive distribution, and the correct warping is simply the distribution of the PIT values \(\Phi(y_i\mid x_i)\). That is why BNE places a Gaussian process prior on \(G\) constrained to be monotone: it learns, from the PIT values, how the Gaussian shape should be bent, and lets the bending vary in space. A PIT histogram that is flat means \(G\) is close to the identity.

6. Computation

Exact Gaussian process inference costs \(O(N^3)\) time per step, because of the factorisation of \(\mathbf K + \sigma_\varepsilon^2 I\). Splitting the data into \(B\) subsets of size \(N/B\) and fitting them in parallel costs \(B\cdot O\big((N/B)^3\big) = O(N^3/B^2)\) in total, and the subsets can run on separate processors. Splitting by region and time is natural for exposure data. The price is that subsets do not share information, so results near subset boundaries need care.

A minimal Python version of the Gaussian process part (Lemma 2), tested on a synthetic example with two base models that are each biased in a different region. Inside the data it beats the simple average, and outside it falls back to the average with larger uncertainty (Proposition 3).

import numpy as np

def matern32(a, b, ell, var):
    r = np.abs(a[:, None] - b[None, :]) / ell
    return var * (1 + np.sqrt(3) * r) * np.exp(-np.sqrt(3) * r)

def bne_mean(x, y, xs, F, Fs, ell_w=2.0, s_w=0.5, ell_d=1.0, s_d=0.5, s_e=0.3):
    """Posterior of mu(x) = sum_k f_k(x) w_k(x) + delta(x), 1-D inputs.
    F, Fs: base-model predictions at training and test points (columns = models).
    Prior weights 1/K; kernels Matern 3/2 (Lemma 2)."""
    K_ = F.shape[1]
    kern = lambda A, B, FA, FB: (FA @ FB.T) * matern32(A, B, ell_w, s_w**2) + matern32(A, B, ell_d, s_d**2)
    K, Ks = kern(x, x, F, F), kern(xs, x, Fs, F)
    Kss = (Fs**2).sum(1) * s_w**2 + s_d**2
    m, ms = F.mean(1), Fs.mean(1)
    L = np.linalg.cholesky(K + s_e**2 * np.eye(len(x)))
    a = np.linalg.solve(L.T, np.linalg.solve(L, y - m))
    v = np.linalg.solve(L, Ks.T)
    return ms + Ks @ a, np.sqrt(np.maximum(Kss - (v**2).sum(0), 0))

The full model adds the warping \(G_x\) and hyperparameter priors, and is fitted by Hamiltonian Monte Carlo. The bneR workflow below packages this for exposure modeling.

7. Applications

Liu et al. (2019) introduced BNE and applied it to air pollution exposure in Eastern Massachusetts. With colleagues at Columbia, we built bneR, a workflow that applies BNE to combine existing exposure models into estimates with spatio-temporal uncertainty. We used it to estimate daily NO2 at 1 km resolution over New York State for 2015, and discussed the results with stakeholders and modelers (Benavides et al., 2025). To handle larger domains, we developed a scalable version that runs on high-performance computing (Kumar et al., 2025; code on GitHub).

Exercises

  1. With \(k_\omega(x,x) = \sigma_\omega^2\) and \(k_\delta(x,x)=\sigma_\delta^2\), compute the prior variance of \(\mu(x)\). Where is the prior least certain, and is that sensible?
    Show answer

    From Lemma 2, \(\operatorname{Var}\mu(x) = \sigma_\omega^2\sum_k f_k(x)^2 + \sigma_\delta^2\). The weight part grows with the size of the base predictions, so the prior is least certain where predicted concentrations are high. That is sensible for pollution, where errors tend to grow with the level, but it also means the prior scale depends on units. Working on a log scale, or standardising the base predictions, makes the prior easier to interpret.

  2. Two base models with constant weights. Suppose \(f_1(x_i)\approx f_2(x_i)\) at all monitors. Using Proposition 1, show that \(\omega_1+\omega_2\) is well determined but \(\omega_1-\omega_2\) is not. At which new locations is the predictive variance large?
    Show answer

    If the two columns of \(F\) are nearly equal, \(F^\top F\) has a large eigenvalue along \((1,1)/\sqrt2\) and a small one along \((1,-1)/\sqrt2\). So the posterior variance \(S\) is small along \((1,1)\), meaning \(\omega_1+\omega_2\) is well determined, and close to the prior variance \(\sigma_\omega^2\) along \((1,-1)\). The weight uncertainty \(\mathbf f(x)^\top S\mathbf f(x)\) is small when \(\mathbf f(x)\) points along \((1,1)\), meaning the models agree at \(x\), and large when \(f_1(x)-f_2(x)\) is large. The ensemble is uncertain exactly where its members disagree and the data cannot say which one is right.

  3. A model predicts \(\mathcal N(\mu,\sigma^2)\), but the truth is \(\mathcal N(\mu,\tau^2)\). Find the warping \(G\) of Proposition 5 and sketch it when the model is overconfident (\(\tau > \sigma\)).
    Show answer

    \(\Phi^{-1}(u) = \mu + \sigma z_u\) with \(z_u\) the standard normal quantile, and \(F(v) = \Phi_{\mathcal N}\big((v-\mu)/\tau\big)\). So \(G(u) = \Phi_{\mathcal N}\big((\sigma/\tau)\,z_u\big)\). When \(\tau>\sigma\), the factor \(\sigma/\tau<1\) flattens \(G\) in the middle and steepens it near 0 and 1: too many PIT values fall in the tails, and the PIT histogram is U-shaped. For example, with \(\tau = 2\sigma\), \(G(0.1) \approx 0.26\): a nominal 10% lower tail actually holds 26% of the observations.

References