Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Posterior Linearization for non-conjugate GPs

Posterior Linearization (PL) is the moment-aware sibling of Laplace. Where Laplace evaluates the gradient and Hessian of log⁡p(y∣f)\log p(y \mid f) at a single point (the current iterate), PL evaluates them as expectations under the cavity distribution:

gˉn=Eq∖n(fn) ⁣[∂log⁡p(yn∣fn)∂fn],hˉn=Eq∖n(fn) ⁣[∂2log⁡p(yn∣fn)∂fn2].\bar g_n = \mathbb{E}_{q^{\setminus n}(f_n)}\!\left[\frac{\partial \log p(y_n \mid f_n)}{\partial f_n}\right], \qquad \bar h_n = \mathbb{E}_{q^{\setminus n}(f_n)}\!\left[\frac{\partial^2 \log p(y_n \mid f_n)}{\partial f_n^2}\right].

Then a Newton-style site update with these averaged derivatives and the cavity mean μnc\mu^c_n:

Λn=−hˉn,λn(1)=gˉn+Λn μnc.\Lambda_n = -\bar h_n, \qquad \lambda_n^{(1)} = \bar g_n + \Lambda_n \,\mu^c_n.

Where it sits. PL interpolates between Laplace and EP:

  • Laplace: g,hg, h at the current point. No averaging, fastest, mode-fit.
  • PL: gˉ,hˉ\bar g, \bar h averaged over the cavity. One quadrature per site per iteration.
  • EP: full tilted-distribution moments (zeroth, first, second). Two extra integrals per site.

PL is also known under several other names: Iterated Posterior Linearization Filter (IPLF) in state-space tracking, the Bayesian Newton’s Rule (BNR) in variational optimization (Khan & Rue), and Statistical Linear Regression (SLR) updates in Kalman literature. They’re all the same idea: replace point derivatives with expected derivatives.

What this notebook shows. PL’s posterior on Bernoulli falls between Laplace and EP — closer to EP because it captures more of the cavity’s spread than Laplace’s point-derivative does, but not as accurate as full moment matching. Damping behaves similarly to EP.

/home/azureuser/localfiles/pyrox/.venv/lib/python3.13/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

Bernoulli classification — Laplace vs PL vs EP

Same dataset as the previous notebooks. Three strategies compared head-to-head.

Laplace  iters=  6  conv=True  log_marg≈-25.691
PL       iters= 22  conv=True  log_marg≈-25.752
EP       iters= 27  conv=True  log_marg≈-25.660

Pairwise differences in posterior (max absolute):
  |Laplace - PL| mean=1.735e-01  var=2.136e-02
  |PL      - EP| mean=4.824e-03  var=2.599e-02
  |Laplace - EP| mean=1.691e-01  var=2.202e-02

Reading the numbers: PL sits between Laplace and EP, exactly as theory predicts. The Laplace↔PL difference is comparable to (or smaller than) Laplace↔EP, and the PL↔EP difference is smaller still — they’re computing similar things, just with EP using full tilted moments rather than just expected derivatives.

Decomposing the site update — point vs averaged derivatives

To make the difference between Laplace and PL concrete, plot the per-site gradient and Hessian Laplace uses (at the posterior mean) versus what PL averages over the cavity:

<Figure size 1210x385 with 2 Axes>

What to notice: averaging over the cavity flattens both the gradient and the negative Hessian relative to the point-evaluation at Laplace’s mode. That’s because the Bernoulli sigmoid saturates — wherever Laplace lands at a point with high curvature, PL’s cavity average pulls in nearby tail values where the sigmoid is flatter. The flatter hˉn\bar h_n translates to smaller site precision, which in turn means larger posterior variance under PL than Laplace. Same direction as EP, smaller magnitude.

Predictive comparison

<Figure size 1210x396 with 2 Axes>
<Figure size 880x385 with 1 Axes>

Reading the std panel: the typical ordering on log-concave likelihoods is Laplace ≤ PL ≤ EP — Laplace’s point-Hessian gives the tightest credible intervals (mode-fitting underestimates spread); EP’s full moment matching gives the widest; PL sits between. The differences are biggest in data-sparse regions (here the extrapolation tails) and vanish near densely-observed points where the cavity is tight.

Summary

  • PL = Newton with averaged derivatives. Each site update uses cavity expectations of gradient and Hessian instead of point evaluations.
  • Sits between Laplace and EP in both philosophy and numerical results: more accurate than Laplace’s mode-fit, less expensive than EP’s full tilted moments. On log-concave likelihoods you get most of EP’s calibration improvement at lower cost per iteration.
  • Same convergence story as EP. Damping is a speed knob on benign problems, a stability knob on hard ones. Defaults damping=0.5 is reasonable; bump up if convergence is slow, drop if oscillating.
  • When to pick PL: a sweet-spot for non-Gaussian likelihoods where you want better calibration than Laplace without paying EP’s full cubature cost. Particularly useful for state-space / Markov-GP non-Gaussian inference, where the IPLF formulation is the de facto standard.
cond = prior.condition_nongauss(BernoulliLikelihood(), y,
                                strategy=PosteriorLinearization(damping=0.5))
m, v = cond.predict(X_star)