Assimilating Almost Anything into Almost Any Stochastic Model

Lachlan Astfalck

UNSW Sydney | STREAM


“Almost any stochastic model”


  • Take a stochastic model you can run forward. This could be
    • a physical solver with uncertain parameters/boundaries/initial conditions etc.
    • a stochastic/mathematical parameterisation
    • a computer simulator
    • a neural network or surrogate model
  • We will call this a stochastic process \(f\).


Working assumption: running the unconditional model forward is easy, conditioning is hard.


“Assimilating almost anything”


  • We want runs/samples of \(f\) that assimilate/agree with some information \(\mathcal{D}\):
    • direct, imperfect observations
    • indirect observations (e.g. bounded, censored, related);
    • a budget or a boundary condition the analysis has to respect;
    • an event we want to impose.

We are targeting the quantity \(p(f \mid \mathcal{D})\).

\[ p(f \mid \mathcal{D}) \;\propto\; \underbrace{p(\mathcal{D} \mid f)}_{e^{-\text{loss}(f;\,\mathcal{D})}} \; \times \; \underbrace{p(f)}_{\text{a way to sample } f} \]

A distribution is a curve, or a bunch of samples


\[ p(f \mid \mathcal{D}) \;\propto\; p(\mathcal{D} \mid f) \; \cdot \; p(f) \]

  • We can view a distribution as a function \(p(f)\), or as samples \(f^{(1)}, \dots, f^{(K)}\).
  • As \(K \to \infty\), the histogram of the samples becomes the curve.
  • In this talk, “getting \(p(f \mid \mathcal{D})\)” means being able to draw samples from it.


All Cats Are Stochastic Processes

A cat is a random vector

Diffusion modelling simply asks “how do I sample from an inconvenient distribution?”

Noising a cat



Reversing a cat

  • Write \(p_t\) for the distribution of \(\boldsymbol{f}_t\), the process after noising until time \(t\)
    • (so \(p_0 = p_\text{cat} = \mathcal{SP}\) and \(p_1 \approx \mathcal{N}(\boldsymbol{0}, \mathbf{I})\))
  • Anderson (1982) showed that the time reversal is also an SDE, \[\begin{aligned} \text{Forwards:}& \qquad \mathrm{d}\boldsymbol{f}_t = - \tfrac{1}{2}\beta(t) \boldsymbol{f}_t \mathrm{d}t + \sqrt{\beta(t)}\,\mathrm{d}\boldsymbol{W}_t. \\ \text{Backwards:}& \qquad \mathrm{d}\boldsymbol{f}_t = \beta(t)\left[\tfrac{1}{2}\boldsymbol{f}_t - \nabla_{\boldsymbol{f}}\log p_t(\boldsymbol{f}_t)\right]\mathrm{d}t + \sqrt{\beta(t)}\,\mathrm{d}\bar{\boldsymbol{W}}_t. \end{aligned}\]
  • One unknown object: the time-dependent score \(\nabla_{\boldsymbol{f}} \log p_t\).
  • If we know the score we can push noise backwards into cats - but how do we know \(p_t\) if we don’t know \(p_0\)??

Anderson (1982), Reverse-time diffusion equation models, Stochastic Processes and their Applications 12(3):313–326.

Reversing a cat


Success Stories - GenCast & AlphaFold 3

Price, Ilan, et al. (2025), Probabilistic weather forecasting with machine learning, Nature 637(8044): 84-90.

Abramson, Josh, et al. (2024), Accurate structure prediction of biomolecular interactions with AlphaFold 3, Nature 630(8016): 493-500.

What does machine learning do?


  • For cats, \(\nabla_\boldsymbol{f} \log p_t\) is unknown. Diffusion models learn it by fitting a network \(s_\theta(\boldsymbol{f}, t)\).
  • That is the entire “ML” content of a diffusion model; everything else is stochastic calculus.
    • find a few hundred million photographs of cats;
    • noise every one of them along the forward process;
    • train \(s_\theta(\boldsymbol{f}, t) \approx \nabla_\boldsymbol{f} \log p_t\);
    • sample from \(p_\text{cats}\) by pushing white noise through the reverse SDE.


Conditional cats


  • Want a grumpy cat? Bayes: \[ \nabla \log p_t(\boldsymbol{f}_t \mid \mathcal{D} = \text{grumpy}) = \nabla \log p_t(\boldsymbol{f}_t) + \underbrace{\nabla \log p_t(\mathcal{D} = \text{grumpy} \mid \boldsymbol{f}_t)}_{\text{guidance = the pull towards } \mathcal{D}}. \]
  • Add a likelihood term to the drift and the trajectory bends towards draws satisfying \(\mathcal{D}\): \[\mathrm{d}\boldsymbol{f}_t = \beta(t)\left[\tfrac{1}{2}\boldsymbol{f}_t - \nabla_{\boldsymbol{f}}\log p_t(\boldsymbol{f}_t \mid \mathcal{D})\right]\mathrm{d}t + \sqrt{\beta(t)}\,\mathrm{d}\bar{\boldsymbol{W}}_t.\]
  • Machine learning calls this guidance.

Conditional cats


Stoch. Models Are Boring Cats

A Gaussian process as a random field

  • Assume an uncertain field \(f(x)\) in space and/or time.
  • To describe \(f(x)\) with a Gaussian process (GP) we need a mean \(m(x)\), the best guess before any data, and a covariance \(k(x, x')\), how strongly two locations move together.
  • For finite observation locations, the field is one multivariate normal, \(\boldsymbol{f} \sim \mathcal{N}(\mathbf{m}_*, \mathbf{K}_{**})\), with \([\mathbf{K}_{**}]_{ij} = k(x_i, x_j)\).


Kriging/OI/KF is conditioning a Gaussian process

  • Measure a few points with noise: \(\boldsymbol{y} = \mathbf{L}\boldsymbol{f} + \boldsymbol{\varepsilon}\), \(\boldsymbol{\varepsilon} \sim \mathcal{N}(\boldsymbol{0}, \boldsymbol{\Gamma})\).
  • Everything stays Gaussian, so \(\boldsymbol{f} \mid \boldsymbol{y} \sim \mathcal{N}(\mathbf{m}_{*|\boldsymbol{y}}, \mathbf{K}_{**|\boldsymbol{y}})\) is again a GP. With the gain \(\mathbf{G} = \mathbf{K}_{**}\mathbf{L}^{\mathsf{T}}(\mathbf{L}\mathbf{K}_{**}\mathbf{L}^{\mathsf{T}} + \boldsymbol{\Gamma})^{-1}\), \[ \mathbf{m}_{*|\boldsymbol{y}} = \underbrace{\mathbf{m}_*}_{\text{prior guess}} + \mathbf{G}\,\underbrace{(\boldsymbol{y} - \mathbf{L}\mathbf{m}_*)}_{\text{misfit}}, \qquad \mathbf{K}_{**|\boldsymbol{y}} = \underbrace{\mathbf{K}_{**}}_{\text{prior spread}} - \underbrace{\mathbf{G}\mathbf{L}\mathbf{K}_{**}}_{\text{removed by the data}} \]
  • This is also known as kriging in geostatistics, optimal interpolation in the environmental sciences and it is also the Kalman filter update.

Targeting a GP with a Diffusion

The marginal \(p_t\) stays Gaussian, and we know \[ p_t = \mathcal{N}\big(\boldsymbol{b}(t),\, \mathbf{A}(t)\big), \qquad \boldsymbol{b}(t) = \alpha(t)\,\underbrace{\mathbf{m}_*}_{\text{or } \mathbf{m}_{*|\boldsymbol{y}}}, \qquad \mathbf{A}(t) = \alpha^2(t)\underbrace{\mathbf{K}_{**}}_{\text{or } \mathbf{K}_{**|\boldsymbol{y}}} + (1-\alpha^2(t))\mathbf{I}. \]

So the score is closed form, and no network is required:

\[ \nabla_{\boldsymbol{f}}\log p_t(\boldsymbol{f}_t) = -\mathbf{A}(t)^{-1}\big(\boldsymbol{f}_t - \boldsymbol{b}(t)\big). \]

Drop it into the reverse-time SDE and integrate from \(t=1\) to \(t=0\):

\[ \mathrm{d}\boldsymbol{f}_t = \beta(t)\left[\tfrac{1}{2}\boldsymbol{f}_t - \nabla_{\boldsymbol{f}}\log p_t(\boldsymbol{f}_t)\right]\mathrm{d}t + \sqrt{\beta(t)}\,\mathrm{d}\bar{\boldsymbol{W}}_t. \]

Watch it happen

⟵

Prior score \[ \begin{aligned} \nabla\log p_t(\boldsymbol{\varphi}_t) &= -\mathbf{A}_t^{-1}\big(\boldsymbol{\varphi}_t - \alpha_t\mathbf{m}_*\big) \\ \mathbf{A}_t &= \alpha_t^2\mathbf{K}_{**} + (1-\alpha_t^2)\mathbf{I} \end{aligned} \]

⟵

Posterior score \[ \begin{aligned} \nabla\log p_t(\boldsymbol{\varphi}_t \mid \boldsymbol{y}) &= -\mathbf{A}_{t|\boldsymbol{y}}^{-1}\big(\boldsymbol{\varphi}_t - \alpha_t\mathbf{m}_{*|\boldsymbol{y}}\big) \\ \mathbf{A}_{t|\boldsymbol{y}} &= \alpha_t^2\mathbf{K}_{**|\boldsymbol{y}} + (1-\alpha_t^2)\mathbf{I} \end{aligned} \]

The model is already the generator

  • Write the model as a deterministic map of standard normal noise, \[ \boldsymbol{f}_0 = T_\vartheta(\boldsymbol{\xi}_0), \qquad \boldsymbol{\xi}_0 \sim \mathcal{N}(\boldsymbol{0}, \mathbf{I}), \] where \(T_\vartheta\) is your simulator and \(\boldsymbol{\xi}_0\) its random numbers. Any discretised process can be written this way (Rosenblatt, 1952).
  • \(\boldsymbol{\xi}_0\) is a really boring GP (\(\mathbf{m}_* = \boldsymbol{0}\), \(\mathbf{K}_{**} = \mathbf{I}\)), so we can do the same Gaussian trick: \[ \underbrace{\boldsymbol{\xi}_1 \;\longrightarrow\; \boldsymbol{\xi}_0}_{\text{diffusion with score } -\boldsymbol{\xi}_t} \;\xrightarrow{\;\;T_\vartheta\;\;}\; \boldsymbol{f}_0. \]
  • This gives prior runs, but not conditioning/assimilating yet.

Rosenblatt (1952), Remarks on a multivariate transformation, The Annals of Mathematical Statistics 23(3):470–472.

Where we stand


  • Push \(\boldsymbol{\xi}_0 \sim \mathcal{N}(\boldsymbol{0},\mathbf{I})\) through \(T_\vartheta\)
  • This gives samples of the stochastic model. (We could already do this, it’s just simulation.)
  • The score of the latent noising process with respect to \(\boldsymbol{\xi}_t\) is closed form.
  • Thus the boring-cat property survives in latent space for every process in the gallery.


  • Now we need a framework for conditioning…

Sneak Peak - Physics as conditioning information


\[ \nabla \log p_t(\boldsymbol{f}_t \mid \mathcal{D}) = \nabla \log p_t(\boldsymbol{f}_t) + \nabla \log p_t(\mathcal{D} \mid \boldsymbol{f}_t). \]


Optimal interpolation, conditioned on the observations alone

Conditioned on the observations and on the non-linear damped pendulum equation

Grumpy Stochastic Models

Guidance is just Bayes


We work in latent space. Target the pulled-back posterior: \[ \pi(\boldsymbol{\xi}_0 \mid \mathcal{D}) \propto p\big(\mathcal{D} \mid T_\vartheta(\boldsymbol{\xi}_0)\big) \rho(\boldsymbol{\xi}_0). \]

Along the latent flow, the score decomposes: \[ \nabla_{\boldsymbol{\xi}} \log p_t(\boldsymbol{\xi}_t \mid \mathcal{D}) = \underbrace{\nabla_{\boldsymbol{\xi}} \log p_t(\boldsymbol{\xi}_t)}_{=\,-\boldsymbol{\xi}_t\ \text{(exact)}} + \underbrace{\nabla_{\boldsymbol{\xi}} \log p_t(\mathcal{D} \mid \boldsymbol{\xi}_t)}_{\text{guidance}}. \]

Run the same SDE in \(\boldsymbol{\xi}\)-space, add the guidance term, then push through \(T_\vartheta\).


The latent prior is exact at every \(t\). Guidance is the only thing to approximate.

Guidance is an integral

  • We know exactly where the current draw can end up: \(\boldsymbol{\xi}_0 \mid \boldsymbol{\xi}_t \sim \mathcal{N}(\alpha_t\boldsymbol{\xi}_t,\, \sigma_t^2\mathbf{I})\).
  • Tilting that Gaussian by the data gives the posterior denoising density, \[ \pi_{0|t}(\boldsymbol{\xi}_0 \mid \boldsymbol{\xi}_t) = \underbrace{\frac{p\big(\mathcal{D} \mid T_\vartheta(\boldsymbol{\xi}_0)\big)}{p_t(\mathcal{D} \mid \boldsymbol{\xi}_t)}}_{\text{tilt}}\;\mathcal{N}(\boldsymbol{\xi}_0;\, \alpha_t\boldsymbol{\xi}_t, \sigma_t^2\mathbf{I}). \]
  • The guidance is an expectation \[ \begin{aligned} \nabla_{\boldsymbol{\xi}} \log p_t(\mathcal{D} \mid \boldsymbol{\xi}_t) &= \alpha_t\,\mathbb{E}_{\pi_{0|t}}\Big[\nabla_{\boldsymbol{\xi}} \log p\big(\mathcal{D} \mid T_\vartheta(\boldsymbol{\xi}_0)\big)\Big] \\ &= \alpha_t\,\mathbb{E}_{\pi_{0|t}}\Big[\underbrace{\big[\partial_{\boldsymbol{\xi}} T_\vartheta(\boldsymbol{\xi}_0)\big]^{\!\mathsf T}}_{\text{Jacobian}}\, \nabla_{\boldsymbol{f}}\underbrace{\log p(\mathcal{D}\mid\boldsymbol{f}_0)}_{-\text{loss}(f;\,\mathcal{D})}\Big]. \end{aligned} \]

Approximating the guidance



We can evaluate \(\pi_{0|t}\) up to a constant and sample its Gaussian part, so standard tools apply.

  • Laplace: fit a Gaussian at the mode of \(\pi_{0|t}\).
  • Importance Sampling: draw end points from the Gaussian, run the model forward, weight by the likelihood.

A trained score network does not give \(\pi_{0|t}\). It only recovers its mean, so ML guidance only uses the mean in the likelihood.

A Computational Caveat

  • We are not cheapening a hard computation. An expensive model is expensive to condition.
  • Cost per posterior draw \(\approx\) \(\mathcal{O}\)(reverse-SDE steps) forward model integrations.
  • Ensemble members can be generated in parallel.
  • Where a model is prohibitively expensive, we may still use an emulator, but this is a matter of practicality not feasibility.


Error source Image diffusion Simulator-based
1 Marginal score \(\nabla\log p_t\) uncontrolled exact
2 Guidance approximation uncontrolled explicit
3 Discretisation controllable solver order \(h^q\), same bound

When do neural networks still help?


  • Our thesis so far: if you can simulate, the score is free and the network goes away
  • This does nothing for computation
  • A generative emulator may still be helpful to enable computation
  • A NN provides an adjoint. An emulator is differentiable by construction; forty years of Fortran can be … problematic
  • A learned emulator might account for model misspecification (e.g. GenCast vs ENS)

The conditioning mechanism does not care where the score comes from. Closed form from your solver, or learned from data.



Spatial fields, awkward observations

HF Radar Currents with known Boundaries

A toy land–atmosphere feedback model

\[ \mathrm{d}T = -\kappa(S)\,\bigl(T - T^{*}(S)\bigr)\,\mathrm{d}t + \sigma_T\,\mathrm{d}W_T, \qquad \mathrm{d}S = 1/C_S \bigl(P(t) - E(T,S)\bigr)\,\mathrm{d}t \]

\(\kappa(S)\) relaxation rate · \(T^{*}(S)\) equilibrium temperature · \(C_S\) soil water storage capacity · \(P(t)\) precipitation · \(E(T,S)\) evaporative water loss

An insultingly simplified version of Brubaker & Entekhabi (1996).

A toy land–atmosphere feedback model

Spatio-temporal SPDEs


Ocean currents from satellite SST

\[ \frac{\partial T}{\partial t} + \underbrace{u\,\frac{\partial T}{\partial x} + v\,\frac{\partial T}{\partial y}}_{\text{unknown current } (u,\,v)} = \kappa\,\nabla^{2} T + S \]

Methane Flux Inversion


NN + Diffusion based inversion of methane flux




Computational scaling vs true-model inversion

Conditioning on Natural Language



“A small UK company’s daily stock price in GBP over 50 trading days. On day 30 the company enters compulsory liquidation and is permanently delisted from the London Stock Exchange.”
“A small UK company’s daily stock price in GBP over 50 trading days. The company has no notable news during the period, but performs well. Ending with a value over 5 GBP per share.”
“Monthly average precipitation in San Diego in inches over 50 months, starting in January.”

What’s here and what’s next


We’ve done a lot of theory this year:

  • Moss\(^*\), Astfalck\(^*\), …, Zammit-Mangion, Conditioning Gaussian Processes on Almost Anything, NeurIPS2026
  • Sharrock, Astfalck, Moss, A General Framework for Conditioning Stochastic Processes, ICLR2027
  • Zammit-Mangion, Astfalck, …, Spatial Prediction with Guided Diffusion, arXiv:2610.12967
  • Cowperthwaite, Astfalck, Sharrock, Moss, Scalable Gaussian Process Flows, arXiv:2610.11459
  • Riffel, Astfalck, Moss, Zammit-Mangion, Inference for Non-Ignorable Missingness with Diffusion Models
  • Astfalck, Moss, …, Zammit-Mangion, Diffusion-based Sampling for Bayesian Computation, coming soon…


Now, what can we actually DO?!


Questions?

Slides and code: astfalckl.github.io/presentations

STREAM: unsw.edu.au/science/our-schools/maths/our-research/stream

l.astfalck@unsw.edu.au

UNSW Sydney UNSW Sydney STREAM