betaFeedback

WorksMathematics

Conditional Mean Flows: Few-Step Densities for Simulation-Based Inference

Abstract

Flow matching has emerged as a powerful generative family for simulation-based inference (SBI). However, sampling and density evaluation require numerical integration at inference time. This makes posterior sampling in neural posterior estimation costly. More importantly, it can make repeated likelihood evaluation prohibitively expensive and impractical for Markov chain Monte Carlo (MCMC) sampling, which may require thousands of repeated density evaluations. Here, we develop conditional mean flows for posterior and likelihood approximation, combining few-step sampling with tractable density evaluation. We show that the mean flow objective identifies conditional flow maps and that independent masking enables direct estimation of marginal likelihoods. We evaluate both posterior and likelihood estimation across several tasks and show that conditional mean flows retain the flexibility of flow-based density estimators while significantly reducing inference time. In particular, single-step conditional mean flow density evaluation yields estimation error comparable to 200-step flow matching while enabling about 200-fold faster downstream MCMC sampling.

INTRODUCTION

Mechanistic simulators are used to describe processes ranging from cognitive science (Ratcliff et al., 2016) to disease modeling (Ye et al., 2025). Yet, while practically important, their likelihoods are often unavailable in closed form. Simulation-based inference (SBI; [16, 3] (Sisson et al. 2018; Cranmer et al. 2020)) addresses this challenge by using simulated parameter-observation pairs (θ,y)(\theta, y) to infer unknown parameters, and amortized methods reuse the trained network across datasets (Bürkner et al., 2023).

Two popular forms of SBI are neural posterior estimation (NPE) and neural likelihood estimation (NLE). NPE learns a posterior model qψ(θ∣y)q_\psi(\theta\mid y) which can sample from the approximate posterior directly. NLE, instead, learns a likelihood model qψ(y∣θ)q_\psi(y \mid\theta) which requires Markov chain Monte Carlo (MCMC) to sample from the posterior. NPE amortizes over datasets but is usually tied to the prior and data format used in training, whereas NLE needs MCMC for every dataset, but allows the prior to be changed after training and composes exchangeable likelihoods across any number of i.i.d. observations (Cranmer et al., 2020).

Many SBI methods demand neural estimators that are both flexible and inexpensive to evaluate. In NLE, MCMC requires thousands of likelihood evaluations per posterior, making each evaluation a practical bottleneck. Further, hierarchical approaches [2] or self-consistency objectives that improve NPE (Schmitt et al., 2024a; Mishra et al., 2026) and enable model comparison (Kucharský and Bürkner, 2026) rely on density evaluation during training or inference.

So far, normalizing flows have been a standard choice in these applications because they evaluate densities in a single pass [17, 19] (Papamakarios et al. 2021). However, their transformations must remain invertible with tractable Jacobians, which restricts how inductive biases can be built into the architecture [27]. Autoregressive flows based on causal transformers (e.g., TARFlow and STARFlow) relax this restriction (Zhai et al., 2025; Gu et al., 2025), but impose a fixed variable ordering and require sequential inversion for sampling. Moreover, tractable joint densities do not generally imply tractable marginals, which are required with missing observations (Yalavarthi et al., 2024).

Flow matching and diffusion models instead learn a velocity or score field with an unconstrained neural network [34, 36, 3] (Wildberger et al. 2023; Sharrock et al. 2024), and diffusion transformers can flexibly represent arbitrary conditionals and marginals (Gloeckler et al., 2024). Yet, their densities require solving an ordinary differential equation (ODE), which can take hundreds of network evaluations and makes repeated likelihood calls during training or within MCMC costly. Few-step generative models reduce the sampling cost, but consistency models, for instance, provide no tractable density (Song et al., 2023; Schmitt et al., 2024b). Thus, current SBI approaches either restrict the network architecture or make every density evaluation expensive.

To overcome this limitation, we present conditional mean flows for SBI, which learn the average velocity between two times, so that one network evaluation defines a finite-time map based on mean flows [22, 23]. We first evaluate direct posterior sampling and density estimation, then focus on learned likelihoods for compositional inference, missing observations, and gradient-based and delayed acceptance MCMC. Concretely, we develop and showcase

  1. a conditional mean flow formulation for posterior and likelihood approximation, with exact stepwise Jacobian determinants, and a proof that the mean flow objective suffices to identify conditional flow maps (Section 3.1, Proposition 1);

  1. marginal density estimation for missing targets with a masked transformer backbone, and a proof that the masked objective targets the correct marginal likelihood (Section 3.3, Proposition 2);

  1. and a benchmark against normalizing flows and regular flow matching on four tasks covering both NLE and NPE, including a single-trial likelihood comparison in which one mean flow step matches the error of 200-step flow matching with two orders of magnitude faster sampling (Section 4);

BACKGROUND AND RELATED WORK

Simulation-based inference. For conditionally independent observations yny_n, simulation-based inference targets p(θ∣yobs)∝p(θ)∏n=1Np(yn∣θ)p(\theta\mid y_{\mathrm{obs}}) \propto p(\theta) \prod_{n=1}^{N} p(y_n \mid\theta) when the likelihood is unavailable. Classical approximate Bayesian computation compares simulated and observed data directly, but becomes less effective as dimension increases (Sisson et al., 2018). Neural posterior estimation (NPE) fits qψ(θ∣y)q_\psi(\theta\mid y) to simulated pairs and draws approximate posterior samples without running MCMC for each dataset. Neural likelihood estimation (NLE), instead, fits a conditional density to prior-predictive pairs and uses it within MCMC (for an overview, see Cranmer et al. [15]). A per-observation estimator can be reused across dataset

sizes, making single-trial likelihoods useful for models with exchangeable trials [6], and spline coupling flows are the standard tractable-density baseline [19].

Flow matching and diffusion-based inference. Flow matching learns a velocity field v(zt,t)\mathbf{v}(\mathbf{z}_t,t) that transports a Gaussian distribution to the target along a prescribed interpolation [34, 36]. It has been applied to both NPE and NLE, alongside score-based generative models (for a review, see Arruda et al. [3]). Sampling requires ODE integration, and density evaluation additionally integrates the velocity divergence through the continuous change-of-variables formula [10], so repeated integration can dominate the cost of NLE.

Few-step generative models. Consistency models learn transitions from intermediate noisy states toward data, enabling generation in one or a few steps (Song et al., 2023). They also support fast posterior sampling in SBI [3] (Schmitt et al. 2024b), although the standard formulation does not provide a tractable posterior density. Flow maps learn finite-time ODE transitions between arbitrary time pairs, and mean flows parameterize these maps through average velocities and can be trained without distillation [22, 23]. Rehman et al. (2026) combined mean flows with a cycle loss that encourages invertibility to obtain few-step densities for Boltzmann generators.

MCMC with learned and multi-fidelity likelihoods. The no-U-turn sampler (NUTS; Hoffman and Gelman, [28]; Betancourt, [5]) uses density and gradient evaluations to construct proposals, and probabilistic programming frameworks allow learned likelihoods to enter these calculations as model components [9]. Delayed acceptance MCMC uses a cheap approximation to screen proposals while leaving the fine target invariant [13]. Moreover, its multilevel variant organizes several approximations (Lykkegaard et al., 2023), and related approaches in SBI use simulators at different resolutions (Prescott and Baker, 2021; Tatsuoka et al., 2026).

METHOD

A note on notation. We write z\mathbf{z} for the density target and x\mathbf{x} for the conditioning variables. In posterior estimation, the network learns qψ(θ∣y)q_\psi(\theta\mid\mathbf{y}) with parameters z≡θ\mathbf{z} \equiv\theta as the target and data x≡y\mathbf{x} \equiv\mathbf{y} as the condition. In likelihood estimation, it learns qψ(y∣θ)q_\psi(\mathbf{y} \mid\theta) with z≡y\mathbf{z} \equiv\mathbf{y} and x≡θ\mathbf{x} \equiv\theta. The same formulation applies to either direction by choosing the target and condition:VEVENT accordingly.

Flow-Based Density Evaluation

Flow matching vs. normalizing flows. We consider flows that transport the target distribution p(z∣x)p(\mathbf{z}\mid\mathbf{x}) to a spherical Gaussian base distribution. Time runs from data to noise: t=0t=0 is the clean target and t=1t=1 is pure noise, along the flow matching interpolation zt=(1−t)z0+tϵ\mathbf{z}_t=(1-t)\mathbf{z}_0+t\boldsymbol{\epsilon} with ϵ∼N(0,I)\boldsymbol{\epsilon}\sim\mathcal{N}(\mathbf{0},\mathbf{I}). Flow matching for SBI learns the marginal velocity vψ(zt,t,x)\mathbf{v}_{\psi}(\mathbf{z}_t,t,\mathbf{x}) by regressing the conditional velocity ϵ−z0\boldsymbol{\epsilon}-\mathbf{z}_0. For sampling, it draws the initial condition z1∼N(0,I)\mathbf{z}_1\sim\mathcal{N}(\mathbf{0},\mathbf{I}) and then integrates dzt=vψ dtd\mathbf{z}_t=\mathbf{v}_{\psi}\,dt from t=1t=1 to t=0t=0 (Wildberger et al., 2023). The density follows from the continuous change of variables,

log⁡qψ(z0∣x)=log⁡N(z1;0,I)+∫01∇⋅vψ(zt,t,x) dt,(1)\log q_{\psi}(\mathbf{z}_0\mid\mathbf{x})=\log\mathcal{N}(\mathbf{z}_1;\mathbf{0},\mathbf{I})+\int_0^1\nabla\cdot\mathbf{v}_{\psi}(\mathbf{z}_t,t,\mathbf{x})\,dt, \tag*{(1)}

which can be integrated with any ODE solver (Arruda et al., [3]). Normalizing flows instead learn an invertible map fψ(⋅;x)f_{\psi}(\cdot;\mathbf{x}) from the target to the base distribution and evaluate

log⁡qψ(z∣x)=log⁡N(fψ(z;x);0,I)+log⁡∣det⁡∇zfψ(z;x)∣(2)\log q_{\psi}(\mathbf{z}\mid\mathbf{x})=\log\mathcal{N}(f_{\psi}(\mathbf{z};\mathbf{x});\mathbf{0},\mathbf{I})+\log\left|\det\nabla_{\mathbf{z}}f_{\psi}(\mathbf{z};\mathbf{x})\right| \tag*{(2)}

in a single pass (Papamakarios et al., 2021). To keep the determinant tractable, fψf_{\psi} is composed of invertible layers with triangular Jacobians (Dinh et al., [17]; Durkan et al., [19]), which avoids the integral in (1) but restricts the neural network architecture (Figure 1).

Learned two-moons posteriors as samplers and as densities

Figure 1. Learned two-moons posteriors as samplers and as densities. Top row: 5,000 draws per method for the canonical observation y=(0,0)\mathbf{y}=(0,0); bottom row: the learned log-density on a 512×512512 \times512 grid with the exact 95% highest-density region dashed. (A) A normalizing flow; (B) a consistency model with S=32S=32 steps, which has no tractable density; (C) a mean flow with S=1S=1. (D) The same mean flow with S=32S=32 and (E) a separately trained flow matching model integrated with 32 Euler steps. (F) The velocity head of the mean flow and (G) the flow matching model, both integrated with the adaptive Tsit5 ODE solver.

Average velocity and the flow map

Extending Geng et al. [22] to conditional models, we train a network to predict the average velocity

uψ(z,s,t,x)≈1t−s∫stv(zτ,τ,x) dτ,(3)\mathbf{u}_{\psi}(\mathbf{z},s,t,\mathbf{x})\approx\frac{1}{t-s}\int_s^t\mathbf{v}(\mathbf{z}_{\tau},\tau,\mathbf{x})\,d\tau, \tag*{(3)}

the mean of the instantaneous field along the ODE trajectory started at zs=z\mathbf{z}_s=\mathbf{z} conditioned on x\mathbf{x}. Since x\mathbf{x} is constant along the trajectory, the conditional velocity defines one ODE per condition. One network evaluation then applies the finite-time flow map

Φψ(z;s,t,x)=z+(t−s)uψ(z,s,t,x),(4)\mathbf{\Phi}_{\psi}(\mathbf{z};s,t,\mathbf{x})=\mathbf{z}+(t-s)\mathbf{u}_{\psi}(\mathbf{z},s,t,\mathbf{x}), \tag*{(4)}

with the boundary case uψ(z,t,t,x)\mathbf{u}_{\psi}(\mathbf{z},t,t,\mathbf{x}) corresponding to the instantaneous velocity v\mathbf{v}.

Training with a self-consistent tangent and a cycle loss. Differentiating (t−s)u=∫stv dτ(t-s)\mathbf{u}=\int_s^t\mathbf{v}\,d\tau along the trajectory gives the Mean Flow identity (Geng et al., [22]),

v(zs,s,x)=uψ(zs,s,t,x)−(t−s)ddsuψ(zs,s,t,x),(5)\mathbf{v}(\mathbf{z}_s,s,\mathbf{x})=\mathbf{u}_{\psi}(\mathbf{z}_s,s,t,\mathbf{x})-(t-s)\frac{d}{ds}\mathbf{u}_{\psi}(\mathbf{z}_s,s,t,\mathbf{x}), \tag*{(5)}

where d/ds=v⋅∇z+∂sd/ds=\mathbf{v}\cdot\nabla_{\mathbf{z}}+\partial_s is the total derivative along (zs,s,t)=(v,1,0)(\mathbf{z}_s,s,t)=(\mathbf{v},1,0) at fixed x\mathbf{x}. Following Geng et al. [23], we use the right-hand side as a prediction of the instantaneous velocity,

Vψ=uψ(zs,s,t,x)−(t−s)sg⁡[ddsuψ(zs,s,t,x)],(6)\mathbf{V}_{\psi}=\mathbf{u}_{\psi}(\mathbf{z}_s,s,t,\mathbf{x})-(t-s)\operatorname{sg}\left[\frac{d}{ds}\mathbf{u}_{\psi}(\mathbf{z}_s,s,t,\mathbf{x})\right], \tag*{(6)}

where sg⁡[⋅]\operatorname{sg}[\cdot] denotes the stop-gradient and the total derivative is computed by one Jacobian-vector product with tangent (sg⁡[v^ψ],1,0)(\operatorname{sg}[\hat{\mathbf{v}}_{\psi}],1,0). Since the marginal velocity vv is unknown, the tangent v^ψ(zs,s,x)\hat{v}_{\psi}(z_s,s,x) is predicted by an auxiliary velocity head, which shares all but the last two layers with uψu_{\psi}. With zs=(1−s)z0+sϵz_s=(1-s)z_0+s\epsilon, both outputs regress onto the conditional velocity,

LMF(ψ)=E[w∥vψ−(ϵ−z0)∥2+1d∥v^ψ−(ϵ−z0)∥2](7)\mathcal{L}_{\mathrm{MF}}(\psi)=\mathbb{E}\left[w\left\|v_{\psi}-(\epsilon-z_0)\right\|^2+\frac{1}{d}\left\|\hat{v}_{\psi}-(\epsilon-z_0)\right\|^2\right] \tag*{(7)}

with the adaptive weight w=sg⁡([∥vψ−(ϵ−z0)∥2+c]−p)w=\operatorname{sg}\left(\left[\left\|v_{\psi}-(\epsilon-z_0)\right\|^2+c\right]^{-p}\right) of Geng et al. [22] and dd the dimension of zz (all hyperparameters are defined in Appendix C). The expectation is taken over simulations (z0,x)(z_0,x), noise ϵ∼N(0,I)\epsilon\sim\mathcal{N}(0,I), and independent times s,ts,t drawn from a power-law distribution. Hence, times are sampled more often closer to the target, similar to Wildberger et al. (2023). For some of the pairs we set t=st=s, where Vψ=uψ(zs,s,s,x)V_{\psi}=u_{\psi}(z_s,s,s,x) and (7) reduces to flow matching. Besides stabilizing training, the velocity head allows us to use the trained mean flow as a flow matching model. To encourage invertibility of the flow map, we add the cycle loss of Rehman et al. (2026), which penalizes the discrepancy between a state and its image after mapping s→ts\to t and back,

Lcyc(ψ)=E[1d∥zs−Φψ(Φψ(zs;s,t,x);t,s,x)∥2](8)\mathcal{L}_{\mathrm{cyc}}(\psi)=\mathbb{E}\left[\frac{1}{d}\left\|z_s-\Phi_{\psi}\left(\Phi_{\psi}(z_s;s,t,x);t,s,x\right)\right\|^2\right] \tag*{(8)}

and minimize LMF+λLcyc\mathcal{L}_{\mathrm{MF}}+\lambda\mathcal{L}_{\mathrm{cyc}} with the cycle weight λ>0\lambda>0. We further replace some xx in (8) by the condition of another simulation, to encourage Φψ\Phi_{\psi} to be invertible for every condition and to make the map robust to any MCMC proposal.

Exact densities from composed steps. We fix a schedule 0=t0<t1<⋯<tS=10=t_0<t_1<\cdots<t_S=1 and let Gi(z)=Φψ(z;ti−1,ti,x)G_i(z)=\Phi_{\psi}(z;t_{i-1},t_i,x) be the step maps toward noise. With z(0)=zz^{(0)}=z and z(i)=Gi(z(i−1))z^{(i)}=G_i(z^{(i-1)}), the change-of-variables expression is

log⁡qψ(S)(z∣x)=log⁡N(z(S);0,I)+∑i=1Slog⁡∣det⁡∇zGi(z(i−1))∣(9)\log q_{\psi}^{(S)}(z\mid x)=\log\mathcal{N}(z^{(S)};0,I)+\sum_{i=1}^{S}\log\left|\det\nabla_zG_i(z^{(i-1)})\right| \tag*{(9)}

where each Jacobian can be computed via autodiff. If the composed map T=GS∘⋯∘G1T=G_S\circ\cdots\circ G_1 is a diffeomorphism of Rd\mathbb{R}^d, the chain rule gives det⁡∇zT=∏idet⁡∇zGi\det\nabla_zT=\prod_i\det\nabla_zG_i, so (9) is the pullback of the base density through TT. We place the nodes by an EDM schedule (Karras et al. [29]), ti=(σi−σmin⁡)/(1−σmin⁡)t_i=(\sigma_i-\sigma_{\min})/(1-\sigma_{\min}) with

σi=(σmin⁡1/ρ+iS(1−σmin⁡1/ρ))ρ,\sigma_i=\left(\sigma_{\min}^{1/\rho}+\frac{i}{S}\left(1-\sigma_{\min}^{1/\rho}\right)\right)^\rho,

which concentrates the steps near the data for ρ>1\rho>1 and has been shown to outperform other schedules for few-step density evaluation (Rehman et al. (2026)).

Conditioning. Although the mean flow only receives xx as an additional input and regresses the same target ϵ−z0\epsilon-z_0 as an unconditional model, we show that it learns the correct conditional flow map. Similar to conditional diffusion models ([4, 3] (Vincent 2011)), the condition only restricts which targets z0z_0 contribute to the regression.

Proposition 1 (Conditional mean flows). Under the assumptions of Appendix A.1, every population minimizer of the unweighted loss LMF\mathcal{L}_{\mathrm{MF}} satisfies uψ=u∗u_{\psi}=u^* for p(x)p(x)-almost every xx, where u∗u^* is uniquely identified by (3) of v∗(z,s,x)=E[ϵ−z0∣zs=z,x]v^*(z,s,x)=\mathbb{E}[\epsilon-z_0\mid z_s=z,x]. Hence, (9) equals log⁡p(z∣x)\log p(z\mid x) for every schedule.

The proof is given in Appendix A.1.

Sampling and Posterior Inference

For sampling, we draw z(S)∼N(0,I)z^{(S)}\sim\mathcal{N}(0,I) and apply the flow map backward along the same schedule, z(i−1)=Φψ(z(i);ti,ti−1,x)z^{(i-1)}=\Phi_{\psi}(z^{(i)};t_i,t_{i-1},x) for i=S,…,1i=S,\ldots,1, so that SS steps yield a sample z(0)z^{(0)}. In the posterior direction, these are parameter draws conditional on the observed data; in the likelihood direction, they are observation draws conditional on the parameters. These samples follow the density in (9) only if the backward maps invert the forward maps GiG_i, which the cycle loss encourages.

In the likelihood direction, the joint log-posterior of NN i.i.d. observations is proportional to log⁡p(θ)+∑n=1Nlog⁡qψ(S)(yn∣θ)\log p(\theta)+\sum_{n=1}^{N}\log q_{\psi}^{(S)}(y_n\mid\theta), which is differentiable in θ\theta for any fixed SS with nonsingular step Jacobians. We expose it to PyMC as a distribution (Salvatier et al. (2016)) and sample with nutpie’s NUTS on the JAX backend (Seyboldt et al. (2026)).

Additionally, we can construct a two-level sampler as a trained mean flow provides a coarse likelihood qψcq_{\psi}^{c} with few steps and a fine likelihood qψfq_{\psi}^{f} by integrating its velocity head with an accurate ODE solver (1). This defines a coarse and a fine posterior,

πc(θ)∝p(θ)∏n=1Nqψc(yn∣θ),πf(θ)∝p(θ)∏n=1Nqψf(yn∣θ),(10)\pi_c(\theta)\propto p(\theta)\prod_{n=1}^{N}q_{\psi}^{c}(y_n\mid\theta), \qquad \pi_f(\theta)\propto p(\theta)\prod_{n=1}^{N}q_{\psi}^{f}(y_n\mid\theta), \tag*{(10)}

which we combine in two-level delayed acceptance MCMC ([13] (Lykke­gaard et al. 2023)). From the current state θ\theta, a subchain of JJ random-walk Metropolis steps targeting πc\pi_c yields a proposal θ′\theta', which is accepted with probability

α(θ,θ′)=min⁡{1,πf(θ′)πc(θ)πf(θ)πc(θ′)}.(11)\alpha(\theta,\theta')=\min\left\{1,\frac{\pi_f(\theta')\pi_c(\theta)}{\pi_f(\theta)\pi_c(\theta')}\right\}. \tag*{(11)}

Since the subchain is reversible with respect to πc\pi_c, this correction makes πf\pi_f the invariant distribution (Lykke­gaard et al., 2023), while the fine likelihood is evaluated only once per subchain instead of at every proposal.

Masked Transformers for Marginal Densities

Inspired by the Simformer [24], we use masked attention to learn marginal densities p(zO∣x)p(z_O \mid x) for subsets OO of the target coordinates. Our transformer tokenizes each coordinate of zz and xx and receives (s,s−t)(s, s-t) through adaptive layer normalization (Peebles and Xie, 2023). The mask excludes omitted target tokens, so outputs depend on zz only through zOz_O; the mean-flow and cycle losses are restricted to OO.

Proposition 2 (Marginalization by masking). Under the assumptions of Appendix § 6.§ 2, every population minimizer of the unweighted masked loss satisfies uψ,O=uO∗u_{\psi,O}=u_O^* for every training mask OO and p(x)p(\mathbf{x})-almost every x\mathbf{x}, where uO∗u_O^* is the average velocity of vO∗(zO,s,x)=E[ϵO−z0,O∣zs,O=zO,x]v_O^*(z_O,s,\mathbf{x})=\mathbb{E}[\epsilon_O-z_{0,O}\mid z_{s,O}=z_O,\mathbf{x}]. Hence, (9) in ∣O∣|O| dimensions equals log⁡p(zO∣x)\log p(z_O\mid x) for every schedule.

The proof is given in Appendix § 6.§ 2. Choosing z=θz=\theta gives marginal posterior densities p(θO∣y)p(\theta_O\mid y); choosing z=yz=y gives marginal likelihoods p(yO∣θ)p(y_O\mid\theta). We evaluate the latter for missing observations in § 4.3.

EXPERIMENTS

We evaluate direct posterior approximation on two moons and likelihood approximation on the three further benchmarks, where the learned densities enter MCMC. The benchmarks show the following:

  • Two moons: few steps give accurate samples, so sampling has only a minor speed-accuracy trade-off, and densities improve with more steps (§ 4.1).

  • Cognitive model: exchangeable likelihoods yield precision comparable to 200-step flow matching with about 200× faster MCMC (§ 4.2).

  • Epidemic renewal: a masked transformer marginalizes missing observations and is more accurate than a normalizing flow (§ 4.3).

  • g-and-k: at a shared budget, more draws beat more steps, and delayed acceptance MCMC is as accurate as NUTS without gradients (§ 4.4).

We compare samples with exact references using the classifier two-sample test (C2ST; Lopez-Paz and Oquab, [37]), and densities through the Hellinger distance (Appendix § 7). Reference-free evaluations use normalized root mean squared error (NRMSE), effective sample size (ESS) and predictive checks, and the calibration for every trained estimator is assessed using tests of accuracy with random points (TARP; Lemos et al., [33]) prior to any other evaluation (Table S1). Tasks, architectures and generative models are described in Appendix § 7 to § 10.

ExperimentMethodATC
Two moonsNormalizing flow−0.008 (0.019)
Two moonsMean flow, S=1S=1 / S=2S=2 / S=32S=32−0.001 (0.010) / +0.007 (0.011) / +0.008 (0.011)
Two moonsConsistency model, S=1S=1 / S=2S=2 / S=32S=32+0.102 (0.011)† / +0.113 (0.011) / +0.001 (0.014)
Two moonsMean flow (v-head), Euler S=1S=1 / S=2S=2 / S=32S=32−0.179 (0.013)† / −0.134 (0.015) / −0.007 (0.012)
Two moonsFlow matching, Euler S=1S=1 / S=32S=32−0.176 (0.011)† / −0.004 (0.014)
Two moonsMean flow (v-head), Flow matching, adaptive−0.007 (0.012) / +0.000 (0.011)
g-and-kMean flow, S=1S=1 / S=8S=8−0.004 (0.012) / −0.009 (0.011)
g-and-kNormalizing flow+0.001 (0.011)
g-and-kFlow matching, Euler S=200S=200+0.004 (0.007)
RenewalMean flow, masked transformer−0.025 (0.013)
RenewalNormalizing flow, sentinel+0.130 (0.011)†
DDMMean flow, S=1S=1 / S=8S=8−0.003 (0.009) / −0.006 (0.013)
DDMFlow matching, Euler S=200S=200−0.003 (0.016)

Table S1. TARP calibration of every trained estimator. Area between the TARP curve and the diagonal (ATC; 0 is calibrated, positive is overdispersed), mean (standard deviation) over 10 folds of 200 prior-predictive validation pairs (2,000 in total) with 200 draws each. Two moons calibrates the posterior; g-and-k, the renewal model and the DDM calibrate the likelihood. † marks methods whose Kolmogorov-Smirnov pp-value is below 0.01; the ATC closest to zero per experiment is in bold.

Few Steps Suffice for High Posterior Sample and Density Quality

Setup and baseline. The two moons task has a two-dimensional parameter and observation, a bimodal crescent posterior, and an exact likelihood and posterior sampler [26] (Lueckmann et al. 2021). All methods learn the posterior direction and are sampled directly with 5,000 draws per dataset, which we score against 32,000 exact reference draws. We compare a conditional mean flow at step counts S∈{1,2,4,8,16,32}S \in\{1,2,4,8,16,32\} with three baselines: a conditional normalizing flow, a conditional consistency model as the established few-step method (Song et al., 2023; Schmitt et al., 2024b), and a separately trained conditional flow matching model integrated with SS Euler steps or an adaptive Tsit5 solver (Tsitouras, 2011). We integrate the velocity head of the mean flow with the same Euler or adaptive scheme, which repurposes the mean flow as a flow matching model. For both the consistency model and the mean flow, we tuned the sampling schedule for each step count on held-out observations, which are disjoint from the evaluation datasets.

Sample quality. The conditional mean flow reaches a similar C2ST at every step count (Figure 1 and Figure S1A), so a single step suffices for sampling and already outperforms the normalizing flow (0.523 against 0.543). In contrast, the consistency model needs at least 4 steps to approach this accuracy, and both flow matching variants need at least 32 Euler steps. The adaptive solver further improves the accuracy, but requires more than 300 solver steps. Hence, the mean flow with S=1S=1 draws 5,000 samples about 23 times faster than flow matching with 32 Euler steps and 140 times faster than with the adaptive solver (Figure S2). It is also about 6 times faster than the normalizing flow and only reaches its sampling time at S=8S=8.

Figure S1. Sample and density quality against step count on two moons. (A) C2ST against the reference posterior over mean flow steps SS (0.5 indicates indistinguishable samples). (B) Hellinger distance of the learned density from the exact posterior on a 512×512512 \times512 grid. Lines show the mean over 10 independent datasets, bands the standard deviation.

Figure S2. Wall time of every method across experiments. Warm wall times by method (log scale), mean over 10 datasets, for (A) two-moons sampling (5,000 draws), (B) g-and-k MCMC under the shared budget, with the flow matching baseline outside it, (C) renewal MCMC at equal draws and (D) DDM MCMC per trial count.

Since the velocity head of the mean flow and the separately trained model perform similarly under both solvers, mean flow training does not seem to degrade the learned velocity field. The consistency model is also sensitive to its discretization exponent, whose candidates span a C2ST from 0.54 to 0.98 at S=4S=4, whereas the EDM schedule of the mean flow changes the C2ST by at most 0.015 (Table S3).

S=2S=2S=4S=4S=8S=8S=16S=16S=32S=32
Consistency modelρ\rho1233.53.5
C2ST, selected0.9180.5420.5550.5390.535
C2ST, worst0.9730.9750.9460.7000.666
Mean flowρ\rho4.543.824.128.347.42
σmin⁡\sigma_{\min}1.1×10−41.1 \times10^{-4}4.9×10−24.9 \times10^{-2}5.7×10−55.7 \times10^{-5}7.0×10−27.0 \times10^{-2}2.0×10−32.0 \times10^{-3}
C2ST, selected0.5020.5040.5090.5050.507
C2ST, worst0.5130.5190.5190.5170.521

Table S3. Sampling schedules selected on two moons. Discretization exponent ρ\rho of the consistency model and EDM schedule (ρ,σmin⁡)(\rho, \sigma_{\min}) of the conditional mean flow for each step count SS, tuned on held-out observations; at S=1S=1, the schedule has no free parameter. To show how much the selection matters, we report the tuning C2ST (3 held-out observations, 2,000 draws each) of the selected and of the worst of the 7 candidates.

Density quality. In contrast to sampling, we find that additional mean flow steps improve the density, and the Hellinger distance to the exact posterior decreases with SS (Figure S1B and Table S4). With S=1S=1, the mean flow places mass between the two modes (Figure 1C), but it still outperforms the normalizing flow. Euler integration of either velocity field remains less accurate than the mean flow with S≥2S \ge2 up to 32 steps. The adaptive solver is most accurate, with the velocity head of the mean flow ahead of the separately trained flow matching model. Moreover, the mean flow density is close to normalized, whereas the Euler densities overshoot unit mass by many orders of magnitude at S=1S=1 and remain far from normalized at S=32S=32 (Table S4). We attribute this to the Euler scheme approximating both the trajectory and the divergence integral in (1), whereas the mean flow computes the exact Jacobian determinant of each step. The normalizing flow is exactly normalized, but its density shows fold artifacts and places mass outside the prior support (Figure 1A). Flow matching models with adaptive solvers provide the most accurate densities, but more than 300 steps per evaluation make them too expensive for repeated density evaluation.

MethodStepsMassKLHellinger
Normalizing flowS=1S=10.977 (0.055)0.446 (0.073)0.383 (0.023)
Mean flowS=1S=11.066 (0.017)0.347 (0.137)0.322 (0.052)
Mean flowS=2S=21.045 (0.030)0.179 (0.077)0.230 (0.042)
Mean flowS=8S=81.085 (0.093)0.165 (0.053)0.219 (0.050)
Mean flowS=32S=321.003 (0.025)0.160 (0.052)0.169 (0.027)
Mean flow (v-head)Euler, S=1S=17.2×10397.2 \times10^{39} (2.3 ×1040\times10^{40})73.2 (19.0)1.000 (0.000)
Mean flow (v-head)Euler, S=8S=857.3 (45.5)4.10 (1.20)0.902 (0.076)
Mean flow (v-head)Euler, S=32S=321.783 (0.077)0.385 (0.033)0.363 (0.020)
Mean flow (v-head)adaptive, S=311S=3110.993 (0.016)0.031 (0.013)0.087 (0.017)
Flow matchingEuler, S=1S=15.5×10235.5 \times10^{23} (1.7 ×1024\times10^{24})37.8 (9.5)1.000 (0.001)
Flow matchingEuler, S=32S=321.825 (0.073)0.271 (0.021)0.304 (0.017)
Flow matchingadaptive, S=302S=3020.991 (0.023)0.048 (0.019)0.117 (0.016)

Table S4. Density metrics on two moons.

Single-Step Likelihoods Yield Error Comparable to 200-Step Flow Matching

Setup and baseline. The cognitive model describes two-alternative decisions as a Wiener first-passage process with drift ν\nu, boundary separation aa and non-decision time t0t_0 ((Ratcliff et al., 2016)), and is a standard benchmark for learned single-trial likelihoods ([20]). We train one conditional mean flow on the signed response time y=(2c−1)ty=(2c-1)t, with choice c∈{0,1}c \in\{0,1\} and response time tt, and compose the learned trial likelihood into joint posteriors over N∈{4,16,64,256}N \in\{4,16,64,256\} trials, which we sample with NUTS. Since a response cannot be faster than t0t_0, we truncate the prior of t0t_0 at the fastest observed response time of each run. We compare mean flow step counts S∈{1,2,4,8}S \in\{1,2,4,8\} with a flow matching model integrated with 200 Euler steps.

Results. With S=1S=1, the NRMSE and posterior contraction of the mean flow are comparable to the flow matching baseline at every NN (Figure 2, Table S5 and Figure S3), while sampling is 182 to 216× faster (Figure S2). Additional steps increase the cost and the number of convergence failures without clearly reducing the parameter error (Figure S4). From all MCMC runs, 8.5% failed to converge, and all failed runs used S≥4S \ge4 (Table S5). We attribute this to the fact that the mean flow is trained for few-step sampling and evaluation only, and hence the intermediate maps might be poorly trained and additional steps, unlike in the discretization of an ODE, need not reduce the approximation error.

Figure 2. Composing one learned trial likelihood over NN trials of a cognitive model. (A) NRMSE of the composed posterior to the generating parameter. (B) Worst posterior predictive discrepancy across choice proportion, conditional response-time quantiles and timeout rate. (C) Posterior contraction relative to the prior. Lines show the mean over 10 independent datasets, bands the sample standard deviation.

MethodNNNRMSECov. 95%Min ESSDiv.max⁡k∣zk∣\max_k \lvert z_k \rvert
Mean flow S=1S=140.268 (0.079)0.90 (0.16)1,396 (312)1.0 (1.9)0.73 (0.14)
Mean flow S=1S=1160.161 (0.033)0.90 (0.16)1,174 (378)6.6 (11.5)0.90 (0.30)
Mean flow S=1S=1640.102 (0.028)0.90 (0.16)1,205 (186)2.4 (4.0)1.13 (0.47)
Mean flow S=1S=12560.070 (0.019)0.60 (0.31)1,146 (335)7.8 (21.7)2.15 (1.03)
Mean flow S=2S=22560.061 (0.016)0.73 (0.21)1,094 (335)0.6 (1.6)1.93 (0.77)
Mean flow S=4S=42560.066 (0.018)0.77 (0.27)503 (620)50.7 (50.1)2.02 (0.77)
Mean flow S=8S=82560.064 (0.023)0.70 (0.29)513 (504)31.8 (29.0)1.99 (0.83)
Flow matching, Euler S=200S=20040.267 (0.081)0.90 (0.16)1,279 (228)0.3 (0.7)0.72 (0.13)
Flow matching, Euler S=200S=200160.151 (0.032)0.90 (0.16)1,285 (270)0.1 (0.3)0.88 (0.22)
Flow matching, Euler S=200S=200640.099 (0.031)0.87 (0.23)1,127 (228)0.0 (0.0)1.03 (0.57)
Flow matching, Euler S=200S=2002560.067 (0.033)0.70 (0.33)1,275 (329)0.1 (0.3)1.79 (0.57)

Table S5. Composing the DDM trial likelihood, per method and trial count. NRMSE to the generating parameter, coverage of the 95% central interval, minimum bulk ESS, divergent transitions, and worst predictive discrepancy; mean (standard deviation) over 10 independent datasets.

Figure S3. Composed DDM posteriors on one dataset, over the trial count. Rows are N∈{4,16,64,256}N \in\{4, 16, 64, 256\}; columns are the marginals of (A) the drift ν\nu, (B) the boundary separation aa and (C) the non-decision time t0t_0 for S=1S=1, S=8S=8 and the 200-step baseline, with the generating parameter dashed and the sampled t0t_0 bound dotted. (D) Posterior predictive CDF of the signed response time (bands: mean ±\pm one standard deviation over 200 replicates) against the observed trials. Shown for one of 10 datasets.

Effect of step count on DDM inference

Figure S4. Figure S4: Effect of step count on DDM inference. A NRMSE over mean flow steps SS, one line per trial count NN, with the flow matching baseline with 200 Euler steps dashed. B Step count selected within each dataset by NRMSE among converged settings, over the trial count NN. C Minimum bulk ESS over SS, with the baseline dash-dotted. Lines show the mean over 10 independent datasets, bands the standard deviation.

However, for every method the coverage of the 95% central interval decreases and the worst posterior predictive discrepancy increases with NN (Figure 2B). Composing many approximate likelihoods accumulates their errors while the posterior contracts, which makes even the 200-step baseline overconfident. With S=1S=1, the additional discretization error further lowers the coverage at N=256N=256, whereas with S=2S=2 coverage and predictive discrepancy are comparable to the baseline.

Masked Transformer Backbone Reduces Error under Missing Observations

Setup and baseline. Since conditional mean flows do not constrain the network architecture, we can tailor the backbone to observations with missing entries. We consider a stochastic renewal process, a standard forward model for estimating time-varying reproduction numbers RtR_t ([21, 14, 25]), in which the incidence is driven by a generation-interval force (Appendix § 10.§ 3 and Figure S5). The parameter is the 128-dimensional coefficient vector z\mathbf{z} with log⁡R=Lz\log R = L\mathbf{z}, where LL is the Cholesky factor of a squared-exponential kernel (Rasmussen and Williams, 2005), such that the prior is N(0,I)\mathcal{N}(\mathbf{0}, \mathbf{I}). We withhold 30% of the observed steps completely at random and redraw this pattern for each dataset. Under this mechanism, inference only requires the marginal likelihood p(yO∣z)p(y_{\mathcal{O}} \mid\mathbf{z}) of the observed entries O\mathcal{O} [35]. We parameterize the mean flow with a masked transformer trained with missing coordinates and a causal mask over time. In contrast, the normalizing flow has a fixed input width, so we train and evaluate it with a value of −1-1 in the missing entries (Figure S5C). Both models are trained on a low budget of 8,192 simulations, and the mean flow is evaluated with S=1S=1.

Figure S5. Figure S5: Renewal-model observations and what each method is shown of them. (A) The observation: four log-incidence curves at one parameter, with the latent log ItI_t of the first behind them and the seeded steps shaded, giving 123 observed values on a 128-step grid. (B) The reproduction number that generated them, against the R=1R=1 line and the prior’s 90% interval, for comparison with the generating trajectory. (C) The same curve under one 30% missingness pattern, as each method receives it: the observed coordinates alone for the masked transformer, against the vector with sentinel values for the normalizing flow.

Posterior accuracy and sampling cost. Both methods converge on every dataset without divergent transitions. The conditional mean flow with the masked transformer has a lower NRMSE to the generating coefficients than the normalizing flow, its posterior draws reproduce the observed yty_t more closely under the learned likelihood and the simulator (Table 1), and its ESS per network evaluation is six times higher. However, each evaluation of the transformer is computationally more costly, such that the normalizing flow finishes sampling 22× sooner, despite requiring more leapfrog steps inside NUTS.

Mean flowNormalizing flow
NRMSE0.187 (0.008)0.199 (0.009)
RMSE y~t\tilde{y}_t0.055 (0.007)0.159 (0.036)
RMSE yty_t0.060 (0.013)0.125 (0.031)
ESS4,234 (247)2,700 (629)
Leapfrog steps121 (4)480 (57)
Wall time (s)36,146 (6,157)1,624 (285)

Table 1. Likelihoods with missing observations. Mean (sample standard deviation) over 10 datasets. y~t\tilde{y}_t is simulated with the learned likelihood.

Posterior predictive. Simulations from the learned likelihoods at posterior draws reveal the problem of sentinel values (Figure 3). The predictive bands of the mean flow contract around the observed data at every observed time point. In contrast, the normalizing flow frequently generates the sentinel value −1-1 also at observed time points, which is reflected in a higher predictive RMSE (Table 1).

Posterior predictive simulations of the renewal model on one dataset

Figure 3. Posterior predictive simulations of the renewal model on one dataset. Observations y~\tilde{y} simulated from the learned likelihood at posterior draws of (A) our conditional mean flow with the masked transformer and (B) the normalizing flow with sentinel values; median with 50 and 90% bands against the observed data (black). The gray strip is the seeded window, and the striped columns mark the missing time points.

In summary, the flexible architecture of mean flows allows a masked transformer to marginalize missing observations. This yields a lower posterior error than a normalizing flow with sentinel values, but at a higher cost per density evaluation.

More Posterior Draws Are Better Than More Flow Steps

Setup and baseline. The g-and-k distribution is a standard benchmark with an intractable likelihood, defined through its quantile function (Rayner and MacGillivray, 2002; Drovandi and Pettitt, 2011). We use a bivariate version with a Gaussian copula and parameters (g,k,ρ)(g,k,\rho), and datasets of N=50N=50 observations (Appendix § 10.§ 2). The conditional mean flow learns the likelihood of a single observation, and we sample the posterior with NUTS. To assess whether a computational budget should be spent on more mean flow steps or on more posterior draws, we fix the product of requested draws per chain and network evaluations per density (Appendix § 9). Under this budget, we compare mean flow step counts S∈{1,4,8}S \in\{1, 4, 8\} with a normalizing flow. In addition, we evaluate delayed acceptance MCMC, which screens proposals with the mean flow at ScS_c steps and accepts them against a 100-step Tsit5 evaluation of the velocity head of the same network (§ 3.3 and Appendix § 9). A separately trained flow matching model integrated with 200 Euler steps serves as a baseline outside the budget, with 28 times more network evaluations.

Steps against draws. All mean flow settings converge on every dataset and reach a similar accuracy, with the lowest mean C2ST at S=4S=4, although these differences are smaller than the spread across datasets (Figure 4A, Table S6). Fewer steps permit longer chains, and the minimum bulk ESS per network evaluation drops by an order of magnitude from S=1S=1 to S=8S=8 (Figure 4B–C). Hence, beyond S=4S=4, a more accurate likelihood does not compensate for fewer posterior draws, and in practice, we recommend S=2S=2 for this benchmark. Under the same budget, the normalizing flow has a higher C2ST than every mean flow setting and requires more than four times the wall time of the mean flow (S=2S=2; Figure S2B). Regular flow matching also has a higher C2ST despite requiring more evaluations, and the same mean flow is about 50× faster.

Figure 4. Budget-matched posterior accuracy on g-and-k. (A) C2ST against the exact posterior over mean flow steps SS, at the shared budget of Appendix D. (B) Minimum bulk ESS per 1,000 network evaluations. (C) Draws kept per chain under the shared budget. Lines show the mean over 10 independent datasets, bands the standard deviation; the delayed acceptance MCMC line is indexed by its coarse step count, and horizontal lines mark the normalizing flow and the flow matching model with 200 Euler steps outside the budget.

MethodStepsSamplesMin ESSC2ST
Mean flow S=1S=1132,00010,498 (1,552)0.604 (0.049)
Mean flow S=2S=2216,0004,856 (939)0.587 (0.046)
Mean flow S=4S=448,0002,436 (708)0.577 (0.039)
Mean flow S=8S=884,0001,143 (476)0.599 (0.030)
Normalizing flow132,0008,023 (3,169)0.679 (0.039)
Flow matching, Euler S=200S=2002004,0001,270 (331)0.614 (0.048)
Delayed acceptance MCMC, Sc=1S_c=11003,656642 (246)0.592 (0.031)
Delayed acceptance MCMC, Sc=2S_c=21003,492649 (200)0.594 (0.030)
Delayed acceptance MCMC, Sc=4S_c=41003,200581 (133)0.595 (0.033)
Delayed acceptance MCMC, Sc=8S_c=81002,744544 (157)0.599 (0.033)

Table S6. Budget-matched MCMC on g-and-k. Every method except the flow matching baseline shares the same budget of requested draws times network evaluations per density. The realized totals in forward passes are 0.9 to 2.0×1072.0 \times10^7 for the NUTS arms and 1.0 to 1.4×1081.4 \times10^8 for delayed acceptance MCMC. Mean (standard deviation) over 10 independent datasets; the best minimum ESS and C2ST are in bold.

Delayed acceptance MCMC. Screening proposals with a coarse mean flow and accepting them against the fine evaluation of the same network gives an accuracy comparable to NUTS (Table S6). With the coarse acceptance rate adapted to 0.3, the fine level accepts 80 to 85% of the evaluated proposals, rising with ScS_c. Delayed acceptance MCMC is about 26–37 times faster than the flow matching baseline, but slower than NUTS with the mean flow likelihoods and yields a lower ESS.

In summary, a few mean flow steps with more posterior draws give a lower posterior error than both the normalizing flow and the flow matching baseline, at lower wall time. Delayed acceptance MCMC with the same network gives comparable accuracy without gradients.

DISCUSSION

Neural density estimators for SBI have so far traded flexibility for fast density evaluation. Conditional mean flows relax this trade-off by allowing the step count to be chosen after training. In low-dimensional benchmarks, one or two steps matched the accuracy of flow matching while reducing MCMC time by up to two orders of magnitude. Few steps also yielded accurate posterior samples, and under a fixed MCMC budget, more draws were more valuable than more steps.

Limitations. The main limitation is the cost of density evaluation in high dimensions. Each step requires its full Jacobian and a log-determinant, whose cost grows cubically with the dimension, and differentiating the log-determinant for NUTS involves second-order derivatives. Together with the higher cost of each transformer evaluation, this made MCMC in the renewal application slower than with the normalizing flow despite using fewer network evaluations. In addition, the cycle loss encourages but does not guarantee invertibility, so the learned densities may not exactly be normalized. Finally, the coverage of every method, including flow matching with 200 steps, decreased at large trial counts, consistent with error accumulation.

Outlook. Beyond MCMC, fast mean flow densities can support self-consistency objectives ((Schmitt et al., 2024a)) and, together with prior and likelihood evaluations, evidence estimation ([31]). Since these methods also rely on repeated density evaluation, our work could make flexible flow-based estimators practical in any SBI setting that requires densities.

Proofs

Conditional Mean Flows

Conditioning reduces the main population objective to an unconditional mean flow objective for each conditional target, as in conditional diffusion and flow matching [4, 3] (Vincent 2011). We write Ψs→tx\Psi^{\mathbf{x}}_{s\to t} for the ODE flow of v∗\mathbf{v}^{*} and u∗\mathbf{u}^{*} for its average velocity, defined by Ψs→tx(z)=z+(t−s)u∗(z,s,t,x)\Psi^{\mathbf{x}}_{s\to t}(\mathbf{z})=\mathbf{z}+(t-s)\mathbf{u}^{*}(\mathbf{z},s,t,\mathbf{x}), with diagonal value u∗(z,s,s,x)=v∗(z,s,x)\mathbf{u}^{*}(\mathbf{z},s,s,\mathbf{x})=\mathbf{v}^{*}(\mathbf{z},s,\mathbf{x}).

Assumptions.

(A1) Noise. ϵ∼N(0,I)\epsilon\sim\mathcal{N}(\mathbf{0},\mathbf{I}) is independent of (z0,x)(\mathbf{z}_0,\mathbf{x}), and E∥z0∥2<∞\mathbb{E}\lVert\mathbf{z}_0\rVert^2<\infty.

(A2) Time pairs. (s,t)(s,t) is independent of (z0,x,ϵ)(\mathbf{z}_0,\mathbf{x},\epsilon), and its distribution has an absolutely continuous component whose density is strictly positive on (0,1)2(0,1)^2.

(A3) Regularity. For p(x)p(\mathbf{x})-almost every x\mathbf{x}, the conditional target p(z0∣x)p(\mathbf{z}_0\mid\mathbf{x}) has a density, and v∗(⋅,⋅,x)\mathbf{v}^{*}(\cdot,\cdot,\mathbf{x}) is continuously differentiable in state and time and globally Lipschitz in the state, uniformly over [0,1][0,1].

(A4) Realizability. The admissible pairs (uψ,v^ψ)(\mathbf{u}_{\psi},\hat{\mathbf{v}}_{\psi}) are jointly measurable in x\mathbf{x}, continuously differentiable in state and time, and have finite population loss, and they contain the exact pair (u∗,v∗)(\mathbf{u}^{*},\mathbf{v}^{*}) simultaneously for all conditions.

(A3) gives a global continuously differentiable flow through both endpoints. For targets with compact support or discontinuous densities, such as the uniform priors in two moons, v∗\mathbf{v}^{*} is in general not Lipschitz near t=0t=0. For such targets, the argument below applies on [δ,1][\delta,1] for every δ>0\delta>0 and, for schedules starting at t0=δt_0=\delta, yields the density of the slightly smoothed target zδ=(1−δ)z0+δϵ\mathbf{z}_{\delta}=(1-\delta)\mathbf{z}_0+\delta\epsilon, which converges to the target as δ→0\delta\to0. In practice, we do not truncate the schedule and keep t0=0t_0=0, since s=0s=0 is almost surely never sampled, and the network’s value at s=0s=0 is the continuous extension of the fitted values at small ss.

Proposition 1 (Conditional mean flows). Assume (A1)–(A4), and let LMF\mathcal{L}_{\mathrm{MF}} be unweighted (w=1w=1). Then every population minimizer satisfies, for p(x)p(\mathbf{x})-almost every x\mathbf{x},

v^ψ(z,s,x)=v∗(z,s,x)anduψ(z,s,t,x)=u∗(z,s,t,x)\hat{\mathbf{v}}_{\psi}(\mathbf{z},s,\mathbf{x})=\mathbf{v}^{*}(\mathbf{z},s,\mathbf{x}) \quad\text{and} \quad\mathbf{u}_{\psi}(\mathbf{z},s,t,\mathbf{x})=\mathbf{u}^{*}(\mathbf{z},s,t,\mathbf{x})

for all z∈Rd\mathbf{z}\in\mathbb{R}^{d}, s,t∈[0,1]s,t\in[0,1].

Consequently, for every schedule 0=t0<⋯<tS=10=t_0<\cdots<t_S=1, the composed map TT equals Ψ0→1x\Psi^{\mathbf{x}}_{0\to1}, a diffeomorphism that transports p(z0∣x)p(\mathbf{z}_0\mid\mathbf{x}) to N(0,I)\mathcal{N}(\mathbf{0},\mathbf{I}), and (9) equals log⁡p(z∣x)\log p(\mathbf{z}\mid\mathbf{x}).

Proof of Proposition 1. Let Y=ϵ−z0\mathbf{Y}=\epsilon-\mathbf{z}_0 and m=v∗(zs,s,x)\mathbf{m}=\mathbf{v}^{*}(\mathbf{z}_s,s,\mathbf{x}). By (A1) and (A2), E[Y∣zs,s,t,x]=m\mathbb{E}[\mathbf{Y}\mid\mathbf{z}_s,s,t,\mathbf{x}]=\mathbf{m}, and (A1) ensures that all terms are finite. Both predictions in the main loss are functions of these inputs, so the conditional-expectation decomposition gives

LMF=(1+1d)E∥Y−m∥2+E∥Vψ−m∥2+1dE∥v^ψ−m∥2.\mathcal{L}_{\mathrm{MF}}=\left(1+\frac{1}{d}\right)\mathbb{E}\lVert\mathbf{Y}-\mathbf{m}\rVert^2+\mathbb{E}\lVert\mathbf{V}_{\psi}-\mathbf{m}\rVert^2+\frac{1}{d}\mathbb{E}\lVert\hat{\mathbf{v}}_{\psi}-\mathbf{m}\rVert^2.

By (A4) and the MeanFlow identity, the exact pair (u∗,v∗)(\mathbf{u}^{*},\mathbf{v}^{*}) makes the last two terms zero. Every minimizer therefore satisfies v^ψ=Vψ=v∗\hat{\mathbf{v}}_{\psi}=\mathbf{V}_{\psi}=\mathbf{v}^{*} almost everywhere under the training distribution. For almost every condition, the Gaussian interpolation has full support at interior times. Together with the time-pair density and continuity, this extends the equalities to all states and times.

Fix such a condition and a trajectory zτ=Ψs→τx(z)\mathbf{z}_{\tau}=\Psi^{\mathbf{x}}_{s\to\tau}(\mathbf{z}). Since v^ψ=v∗\hat{\mathbf{v}}_{\psi}=\mathbf{v}^{*}, the total derivative in Vψ\mathbf{V}_{\psi} is taken along this trajectory, and for fixed tt,

ddτΦψ(zτ;t,t,x)=v∗(zτ,τ,x)−Vψ(zτ,t,t,x)=0.\frac{\mathrm{d}}{\mathrm{d}\tau}\Phi_{\psi}(\mathbf{z}_{\tau};t,t,\mathbf{x})=\mathbf{v}^{*}(\mathbf{z}_{\tau},\tau,\mathbf{x})-\mathbf{V}_{\psi}(\mathbf{z}_{\tau},t,t,\mathbf{x})=\mathbf{0}.

Since Φψ(zt;t,t,x)=zt\Phi_{\psi}(\mathbf{z}_t;t,t,\mathbf{x})=\mathbf{z}_t, we obtain Φψ=Ψx\Phi_{\psi}=\Psi^{\mathbf{x}} and hence uψ=u∗\mathbf{u}_{\psi}=\mathbf{u}^{*}, with the diagonal identity following by continuity. Since z1=ϵ\mathbf{z}_1=\epsilon, the flow of v∗\mathbf{v}^{*} transports p(z0∣x)p(\mathbf{z}_0\mid\mathbf{x}) to N(0,I)\mathcal{N}(\mathbf{0},\mathbf{I}) under (A3) [34, 36]. Flow composition gives T=Ψ0→1xT=\Psi^{\mathbf{x}}_{0\to1} for every schedule, and change of variables gives (9). □\square

The exact flow map satisfies Ψt→sx∘Ψs→tx=id\Psi_{t\to s}^{x} \circ\Psi_{s\to t}^{x} = \mathrm{id} for every condition, including swapped ones, so the exact pair also attains the minimum Lcyc=0\mathcal{L}_{\mathrm{cyc}} = 0. Hence, adding λLcyc\lambda\mathcal{L}_{\mathrm{cyc}} does not change the set of population minimizers. For p>0p > 0, the weight ww depends on the regression target YY through the residual, and the decomposition above no longer applies. The adaptive weight thus acts as a robust loss that down-weights large residuals [22], and in general changes the learned velocity, but empirically seems to stabilize training (see Table S2).

HyperparameterSearch spaceSelected
Cycle weight λ\lambda (log)[1,100][1, 100]2.5
Probability of replacing the condition in Lcyc\mathcal{L}_{\mathrm{cyc}}[0,0.8][0, 0.8]0.6
Fraction of time pairs with t=st=s[0.2,0.8][0.2, 0.8]0.7
Exponent pp of the adaptive weight{0,0.25,0.5,0.75,1}\{0, 0.25, 0.5, 0.75, 1\}0.25
Offset cc of the adaptive weight (log)[10−5,1][10^{-5}, 1]0.1
Scale of the Fourier time embedding (log)[0.02,30][0.02, 30]0.3
Exponent α\alpha of the training times[−0.5,4][-0.5, 4]0.5
Final layers not shared by the velocity head{0,…,5}\{0, \ldots, 5\}2
Adaptive weight on the velocity head{yes,no}\{\text{yes}, \text{no}\}no

Table S2. Hyperparameters of the conditional mean flow. Search space of the Optuna search and the selected configuration used in all experiments.

Marginalization by Masking

We show that the masked objective of Section 3.3 targets the marginal distribution of the retained target coordinates. For a set O⊆{1,…,d}\mathcal{O} \subseteq\{1,\ldots,d\}, we write zO\mathbf{z}_{\mathcal{O}} for the retained coordinates of z\mathbf{z}, and uψ,O\mathbf{u}_{\psi,\mathcal{O}} and v^ψ,O\hat{\mathbf{v}}_{\psi,\mathcal{O}} for the outputs of the network on O\mathcal{O}.

Proposition 2 (Marginalization by masking). Let the mask O⊆{1,…,d}\mathcal{O} \subseteq\{1,\ldots,d\} be nonempty with law π\pi, independent of (z0,x,ϵ,s,t)(\mathbf{z}_0,\mathbf{x},\boldsymbol{\epsilon},s,t), let the network outputs on O\mathcal{O} depend on the target only through zO\mathbf{z}_{\mathcal{O}}, and let the unweighted loss be restricted to the coordinates in O\mathcal{O}. Assume (A1)–(A3) for each marginal target z0,O\mathbf{z}_{0,\mathcal{O}} with π(O)>0\pi(\mathcal{O}) > 0, and (A4) simultaneously for all such masks. Then every population minimizer satisfies, for every O\mathcal{O} with π(O)>0\pi(\mathcal{O}) > 0 and p(x)p(\mathbf{x})-almost every x\mathbf{x}, v^ψ,O=vO∗\hat{\mathbf{v}}_{\psi,\mathcal{O}} = \mathbf{v}_{\mathcal{O}}^* and uψ,O=uO∗\mathbf{u}_{\psi,\mathcal{O}} = \mathbf{u}_{\mathcal{O}}^*, where uO∗\mathbf{u}_{\mathcal{O}}^* is the average velocity of

vO∗(zO,s,x)=E[ϵO−z0,O∣zs,O=zO,x].\mathbf{v}_{\mathcal{O}}^*(\mathbf{z}_{\mathcal{O}},s,\mathbf{x}) = \mathbb{E}\left[\boldsymbol{\epsilon}_{\mathcal{O}}-\mathbf{z}_{0,\mathcal{O}} \mid\mathbf{z}_{s,\mathcal{O}}=\mathbf{z}_{\mathcal{O}},\mathbf{x}\right].

Consequently, (9), with the base density and Jacobians evaluated in ∣O∣|\mathcal{O}| dimensions, equals log⁡p(zO∣x)\log p(\mathbf{z}_{\mathcal{O}} \mid\mathbf{x}) for every schedule.

Proof of Proposition 2. For a fixed mask, independence leaves the simulation law unchanged, and the coordinatewise interpolation is

zs,O=(1−s)z0,O+sϵO,ϵO∼N(0,I∣O∣).\mathbf{z}_{s,\mathcal{O}} = (1-s)\mathbf{z}_{0,\mathcal{O}} + s\boldsymbol{\epsilon}_{\mathcal{O}}, \qquad\boldsymbol{\epsilon}_{\mathcal{O}} \sim\mathcal{N}(\mathbf{0},\mathbf{I}_{|\mathcal{O}|}).

The masked main loss is therefore a positively weighted sum of the conditional mean flow objectives for the marginal targets. By the simultaneous realizability in (A4), the exact pairs attain every summand’s lower bound, so every minimizer attains each one. Proposition 1 applied to z0,O\mathbf{z}_{0,\mathcal{O}} gives the result.

Additional attention restrictions are covered only when they preserve the ability to represent vO∗\mathbf{v}_{\mathcal{O}}^* and its average velocity. The independence of the synthetic training mask holds by construction and does not impose a missingness mechanism on the observed data. The marginal density uses only the observed coordinates. For p>0p > 0, the residual and hence ww depend only on the retained coordinates, so the reduction to the marginal targets still holds, but each summand then has the weighted minimizer discussed in Appendix A.1.

Evaluation Metrics

All experiments use 10 independent datasets, and we report the mean and standard deviation of the following metrics over datasets.

Classifier two-sample test (C2ST). The C2ST compares two distributions through a classification task [37]. If the approximate and the reference posterior coincide, no classifier can tell their draws apart better than chance, whereas any difference between them can be exploited by a sufficiently flexible classifier. Hence, the held-out accuracy a^\hat{a} of a trained classifier measures how distinguishable the two distributions are: a^=0.5\hat{a} = 0.5 indicates indistinguishable and a^=1\hat{a} = 1 perfectly separable draws. We label approximate draws with 1 and reference draws with 0, subsample both sets without replacement to the same size, which is fixed within each experiment across all methods and step counts, standardize the pooled draws, and train a classifier c(θ)∈(0,1)c(\boldsymbol{\theta}) \in(0,1) with the binary cross-entropy. The classifier is an MLP with two residual hidden layers of width 2⌊log⁡2(10D)⌋2^{\lfloor\log_2(10D) \rfloor} for DD-dimensional draws, Mish activations, dropout of 0.1, and a sigmoid output unit. We train it with AdamW (learning rate 5×10−45 \times10^{-4} with linear warmup and cosine decay, weight decay 5×10−35 \times10^{-3}, gradient clipping at norm 1.5) and batch size 128 for at most 100 epochs, with early stopping (patience 5) on 20% of the training data. The accuracy of the classifier c(θ)c(\boldsymbol{\theta}) on held-out draws is averaged over 5-fold cross-validation.

Grid density metrics. On two moons, we evaluate the exact posterior pp and each learned density qq on a 512×512512 \times512 midpoint grid over the prior support with cell area ΔA\Delta A. We report the total mass M=∑jqjΔAM = \sum_j q_j \Delta A of the learned density and compare the shapes of both densities after normalizing them to cell probabilities p~j\tilde{p}_j and q~j\tilde{q}_j on the grid,

KL=∑jp~jlog⁡p~jq~j,H=(12∑j(p~j−q~j)2)1/2.\mathrm{KL} = \sum_j \tilde{p}_j \log\frac{\tilde{p}_j}{\tilde{q}_j}, \qquad H = \left(\frac{1}{2}\sum_j\left(\sqrt{\tilde{p}_j}-\sqrt{\tilde{q}_j}\right)^2\right)^{1/2}.

The Hellinger distance H∈[0,1]H \in[0,1] remains finite when the learned density vanishes where the exact posterior has mass, whereas the Kullback-Leibler (KL) divergence becomes infinite.

Normalized RMSE and coverage. For posterior draws θ^(l)\hat{\theta}^{(l)}, l=1,…,Ll=1,\ldots,L, and the generating parameter θ∗\theta^* of dimension DD, we compute

NRMSE=(1LD∑l=1L∑j=1D(θ^j(l)−θj∗rj)2)1/2.\mathrm{NRMSE} = \left(\frac{1}{LD}\sum_{l=1}^{L}\sum_{j=1}^{D}\left(\frac{\hat{\theta}^{(l)}_j-\theta^*_j}{r_j}\right)^2\right)^{1/2}.

where rjr_j is the prior range of parameter jj. Coverage is the fraction of parameters whose generating value lies within the central 95% credible interval.

Posterior contraction. We define posterior contraction as the relative reduction in variance from prior to posterior,

Contraction=1−1D∑j=1DVar⁡post(θj)Var⁡prior(θj).\mathrm{Contraction} = 1-\frac{1}{D}\sum_{j=1}^{D}\frac{\operatorname{Var}_{\mathrm{post}}(\theta_j)}{\operatorname{Var}_{\mathrm{prior}}(\theta_j)}.

which measures how much the data reduce the prior uncertainty, but not whether the posterior is correct.

TARP. TARP estimates the expected coverage of credible regions around random reference points [33] directly from the trained estimator, without MCMC or reference posteriors. We report the area between the TARP curve and the diagonal (ATC; 0 is calibrated) and the pp-value of the Kolmogorov-Smirnov test, using 2,000 validation pairs split into 10 folds of 200 pairs with 200 draws each (Table S1). On two moons, TARP assesses the learned posterior; for the other experiments, it assesses whether the learned likelihood generates calibrated data.

Posterior predictive checks. For the DDM, we simulate a replicate dataset for each of 200 posterior draws and compare the observed choice proportion, the conditional response-time quantiles (10, 30, 50, 70 and 90%) and the timeout rate TT with their replicate distribution. For each summary, we compute the discrepancy z=(T(yobs)−T‾rep)/sd⁡(Trep)z = (T(y_{\mathrm{obs}}) - \overline{T}_{\mathrm{rep}})/\operatorname{sd}(T_{\mathrm{rep}}) and the predictive pp-value P(T(yrep)≥T(yobs))P(T(y_{\mathrm{rep}}) \ge T(y_{\mathrm{obs}})), and report the largest ∣z∣|z| across summaries.

Convergence diagnostics. We compute split-R^\hat{R} and bulk ESS following Vehtari et al. (2021). A run passes our convergence criteria if max⁡R^≤1.05\max\hat{R} \le1.05, the minimum bulk ESS is at least 100 and at least 500 draws are kept. Reported means and standard deviations include runs that fail these criteria.

Architectures, Training and Hyperparameter Search

All networks and diagnostics are implemented in BayesFlow 2.0.14 (Radev et al., 2023; Kühmichel et al., [32]), where we added the conditional mean flow as an additional inference network.

Architectures.

  • Mean flow: An MLP with 5 hidden layers of width 256. The condition xx is embedded by a linear layer and concatenated with the target zz at the input, and, together with a Fourier embedding with scale 0.3 of the time pair (s,s−t)(s, s-t), it modulates every residual block (Perez et al., 2018). The auxiliary velocity head shares all but the last 2 layers.

  • Masked transformer: A transformer (Peebles and Xie, 2023) with 5 blocks of width 128 and four attention heads. It tokenizes each observation and parameter and receives the time pair (s,s−t)(s, s-t) through adaptive layer normalization. During training, each observation of each simulation is dropped independently with probability 0.3, redrawn for every batch. Dropped tokens are excluded from attention and loss. A causal mask additionally restricts each observation token to parameter and observation tokens up to its own time step. The velocity head branches from the last 2 blocks and uses the same masks. Each observation and parameter token receives a learned embedding of its coordinate index, which for observations is the time step, and a Fourier embedding is used only for the time pair.

  • Consistency model: A continuous-time consistency model (Lu and Song, 2025) with an MLP of 6 hidden layers of width 256.

  • Flow matching: An MLP with the same depth and width as the mean flow, without the velocity head.

  • Normalizing flow: A spline coupling flow (Durkan et al., [19]) with 5 coupling layers, each with 2 hidden layers of width 256, and with 2 coupling layers, each with 2 hidden layers of width 128, for the renewal application.

Training. We trained all networks offline on standardized parameters and observations with a batch size of 256, using AdamW with weight decay 5×10−35 \times10^{-3}, gradient clipping at norm 1.5, and a learning rate warmed up linearly over the first 5% of steps from 5×10−55 \times10^{-5} to 5×10−45 \times10^{-4} and then decayed to zero with a cosine schedule. We used 50,176 simulations for two moons and the DDM, 100,000 for g-and-k, and 8,192 for the renewal model to compare architectures under limited data, with 1,024 further simulations for validation. The conditional mean flow, the consistency model, and the flow matching model were trained for 1,000 epochs, and the normalizing flow for 200 epochs with early stopping (patience 10).

Hyperparameter search. We selected the training hyperparameters of the conditional mean flow with a search in Optuna (Akiba et al., [1]) on two benchmarks: two moons and a three-dimensional variant of the Gaussian linear task with uniform prior. Table S2 lists the search space and the selected values, which all experiments use. The training times are s=us1+αs = u_s^{1+\alpha} and t=ut1+αt = u_t^{1+\alpha} with us,ut∼U(0,1)u_s,u_t \sim U(0,1), and for 0 unshared layers the velocity head reads the velocity from the boundary case uψ(z,s,s,x)u_\psi(z,s,s,x). Each trial trained one network per benchmark for 250 epochs of 100 freshly simulated batches of size 256 and evaluated it with S=4S=4 steps on 256 held-out datasets with 500 posterior draws each. The score of a benchmark was the sum of an accuracy term, the calibration error, and the grid Hellinger distance to the exact posterior. The accuracy term is 2(C2ST−0.5)2(\mathrm{C2ST} - 0.5) on two moons and the NRMSE on the Gaussian task, and the calibration error is the median absolute difference between the nominal and empirical coverage of central credible intervals at 20 levels. The C2ST was averaged over 15 and the Hellinger distance over 3 of the held-out datasets. The search minimized the sum of both benchmark scores with the multivariate tree-structured Parzen estimator of Optuna [1] on 200 trials.

Sampling schedule. For two moons, we tuned the sampling schedule of the consistency model and the mean flow separately for each step count, using the C2ST on 2,000 draws for 3 held-out observations. For the consistency model, we selected the discretization exponent from ρ∈{1,2,3,3.5,5,7,10}\rho\in\{1, 2, 3, 3.5, 5, 7, 10\}. For the mean flow, we optimized the EDM schedule (ρ,σmin⁡)(\rho, \sigma_{\min}) with 7 Optuna trials over ρ∈[1,10]\rho\in[1, 10] and σmin⁡∈[10−6,10−1]\sigma_{\min} \in[10^{-6}, 10^{-1}] (log-uniform), the same number of candidates as for the consistency model. Table S3 lists the selected schedules. For S=1S=1, the schedule is fixed. For all other experiments, we set ρ=7\rho=7 and σmin⁡=0.001\sigma_{\min}=0.001.

Code. The code and the configurations of all experiments are available under the MIT license at https://anonymous.4open.science/r/MeanFlow-AISTAST. The code is written in Python 3.14, and all networks are Keras 3.15.1 models [12] on the JAX 0.11.1 backend [7], both under the Apache 2.0 license. Besides BayesFlow (MIT), we build on PyMC 5.28.5 (Apache 2.0) (Salvatier et al., 2016) and nutpie 0.16.11 (MIT) (Seyboldt et al., 2026) for MCMC, ArviZ 0.23.4 (Apache 2.0) (Martin et al., 2026) for the convergence diagnostics, and Optuna 4.9.0 (MIT) [1] for the hyperparameter searches.

Compute environment. We ran all analyses on a computing cluster using eight CPU cores and one NVIDIA A100 GPU with 40 GB of VRAM. The computing cluster uses an AMD EPYC 7F72 CPU with a core clock speed of up to 3.2 GHz and 50 GB of RAM.

MCMC Samplers

NUTS. We sample with the NUTS implementation of nutpie (Seyboldt et al., 2026) through PyMC (Salvatier et al., 2016) on the JAX backend [7], with 4 chains, a diagonal mass matrix, a maximum tree depth of 10 and the default target acceptance rate of nutpie. We use the default of 400 warmup iterations, except for g-and-k, where the warmup is 25% of the requested draws of each method.

Budget on g-and-k. A method whose density costs KK network evaluations requests 8,000/K8{,}000/K draws per chain, so that the product of requested draws and network evaluations per density is constant across methods. The normalizing flow counts as K=1K=1. For delayed acceptance MCMC, the requested iterations are 96,000/(JSc+100)96{,}000/(JS_c+100) per chain, which accounts for the J=5J=5 coarse evaluations and one fine evaluation per iteration. The budget is set on the requested draws and ignores the number of leapfrog steps per draw, which differs between methods, so the realized number of network evaluations varies. We count one network evaluation per forward pass of the network for one pair (z,x)(\mathbf{z},\mathbf{x}): a normalizing flow costs one evaluation per density, a mean flow with SS steps costs SS, a velocity field integrated with SS Euler steps costs SS, and a fixed-step Tsit5 integration costs 7 per step. Jacobians, divergences and gradients are obtained by automatic differentiation on top of these passes and are not counted; their cost is reflected in the wall times.

Delayed acceptance MCMC. We implement two-level delayed acceptance MCMC ([13]) with the subchains of Lykkegaard et al. (2023). For any coarse posterior πc\pi_c, its invariant distribution is the fine posterior πf\pi_f (§ 3.3). Both levels use the same trained network: the coarse level evaluates the mean flow with Sc∈{1,2,4,8}S_c \in\{1,2,4,8\} steps, and the fine level integrates its velocity head with 100 Tsit5 steps of fixed size and the exact divergence in (1). Each iteration runs a subchain of J=5J=5 random-walk Metropolis steps on πc\pi_c, following Lykkegaard et al. (2023), and proposes its end point to the fine level with the acceptance probability (11). The random walk draws Gaussian increments with a step size per parameter, initialized at 10% of the prior width, and a global scale. A proposal outside the prior’s support is rejected without evaluating the network. If the subchain does not move, the proposal equals the current state and is accepted without evaluating the fine likelihood. Adaptation takes 25% of the requested iterations and is discarded. During adaptation, a Robbins-Monro update steers the global scale towards a coarse acceptance rate of 0.3, and in its second half, the step sizes are updated to the marginal standard deviations of the states visited in that half, after which the proposal is fixed. We run 4 chains started from prior draws.

Per-Experiment Details

Two Moons

The prior is θ∼U(−1,1)2\theta\sim\mathcal{U}(-1,1)^2, and the forward model is

a∼U(−π/2,π/2),r∼N(0.1,0.012),a \sim\mathcal{U}(-\pi/2,\pi/2), \qquad r \sim\mathcal{N}(0.1,0.01^2),
y=(rcos⁡a+0.25,rsin⁡a)+(−∣θ1+θ2∣/2,(−θ1+θ2)/2),\mathbf{y} = (r\cos a+0.25,r\sin a)+(-|\theta_1+\theta_2|/\sqrt{2},(-\theta_1+\theta_2)/\sqrt{2}),

whose fold makes the posterior invariant under (θ1,θ2)↦(−θ2,−θ1)(\theta_1,\theta_2)\mapsto(-\theta_2,-\theta_1), which gives two crescent-shaped modes ([26]). Since the density is available in closed form and the forward model can be inverted, we draw 32,000 exact i.i.d. reference samples per observation. The first dataset uses the canonical observation y=(0,0)\mathbf{y}=(0,0), and the other nine use prior predictive draws.

g-and-k

The g-and-k distribution is defined by its quantile function in normal-score space (Rayner and MacGillivray, 2002),

W(z;g,k)=(1+0.8tanh⁡(gz/2))(1+z2)kz,z∼N(0,1),W(z;g,k)=(1+0.8\tanh(gz/2))(1+z^2)^kz, \qquad z\sim\mathcal{N}(0,1),

and has no closed-form density. Since WW is strictly increasing for k≥0k\ge0, we invert it by bisection, which gives the exact log-density by the change of variables. We couple two coordinates with a Gaussian copula of correlation ρ\rho in normal-score space, such that both marginals are g-and-k distributed. The priors are g∼U(−1,1)g\sim\mathcal{U}(-1,1), k∼U(0,0.5)k\sim\mathcal{U}(0,0.5) and ρ∼U(−0.9,0.9)\rho\sim\mathcal{U}(-0.9,0.9), and each dataset consists of N=50N=50 observations simulated from a parameter drawn from the prior. We obtain 32,000 reference draws per dataset from an adaptive random-walk Metropolis ensemble on the exact log-posterior, started around the generating parameter with a jitter of 2% of the prior width (8 chains, 5,000 adaptation iterations, 40,000 draws thinned by 10, R^≤1.05\hat{R}\le1.05 and ESS ≥400\ge400).

Epidemic Renewal

On a grid of T=128T = 128 steps, of which the first n0=5n_0 = 5 are seeded at incidence I1=⋯=In0=10I_1 = \cdots= I_{n_0} = 10 and not observed, the renewal model is, for t>n0t > n_0,

Λt=∑s=115wsIt−s,It=RtΛtexp⁡(σpεt−12σp2),yt=log⁡It+σoηt,\Lambda_t = \sum_{s=1}^{15} w_s I_{t-s}, \qquad I_t = R_t \Lambda_t \exp\left(\sigma_p \varepsilon_t - \frac{1}{2}\sigma_p^2\right), \qquad y_t = \log I_t + \sigma_o \eta_t,

with εt,ηt∼N(0,1)\varepsilon_t,\eta_t \sim\mathcal{N}(0,1), σp=σo=0.05\sigma_p = \sigma_o = 0.05, and ww the Gamma density with mean 5.0 and standard deviation 2.5 [21, 14]. This is the renewal equation of Cori et al. [14] with a discretized generation interval truncated at 15 steps. The observation is (yn0+1,…,yT)(y_{n_0+1},\ldots,y_T), so d=123d = 123. The parameter is the whitened coefficient vector z∈R128\mathbf{z} \in\mathbb{R}^{128} with log⁡R=Lz\log R = L\mathbf{z}, where LL⊤LL^\top is a squared-exponential kernel with lengthscale 2.5, marginal standard deviation 0.4 and a 10−610^{-6} ridge (Rasmussen and Williams, 2005). Hence, the prior is exactly z∼N(0,I)\mathbf{z} \sim\mathcal{N}(0,\mathbf{I}). Since LL is lower triangular, zsz_s enters log⁡Rt\log R_t only for t≥st \ge s, and since the recursion runs forward in time, yty_t does not depend on zsz_s for s>ts > t. The causal attention mask of the masked transformer (Appendix § 8) encodes exactly this structure. Observations are standardized separately at each time step.

We withhold each of the observed steps independently with probability 0.3 and draw a new pattern for every dataset. Since this mechanism is independent of the process and the parameters, the data are missing completely at random, and the posterior only requires the marginal likelihood p(yO∣z)p(y_{\mathcal{O}} \mid\mathbf{z}) of the observed entries O\mathcal{O} [35]. The masked transformer trains on complete simulations with masks drawn independently per simulation and observation at the same rate and thereby learns this marginal for every pattern. The normalizing flow instead models vectors with the sentinel −1-1 in the missing entries according to Wang et al. (2024).

Cognitive Model

A trial is a Wiener process with drift ν\nu that starts at βa\beta a (with fixed relative starting point β=0.5\beta= 0.5) and terminates at the first hit of 0 or aa. The response time adds a non-decision time t0t_0, and trials time out after 10 s. The priors are ν∼U(−3,3)\nu\sim U(-3,3), a∼U(0.8,2)a \sim U(0.8,2) and t0∼U(0.1,0.4)t_0 \sim U(0.1,0.4), and we simulate with Euler-Maruyama at dt=10−4\mathrm{d}t = 10^{-4}. The network observes the signed response time y=(2c−1)ty = (2c - 1)t, with c=1c = 1 for the upper boundary, which is bijective with the pair of response time and choice. Since the non-decision time cannot exceed the fastest observed response time, we sample it below this bound, which tightens as trials are added. Within each dataset, trial counts are nested, and every setting keeps 4×1,0004 \times1{,}000 NUTS draws after the default warmup. For the first trial count N=4N=4, the chains start at the center of the prior support with the default jitter of PyMC. The chains for the next trial count start at the posterior median of the preceding trial count, clipped to the current support of t0t_0, with independent jitter per chain.

Additional Figures and Tables

Table S4: Density metrics on two moons. Total mass, KL divergence and Hellinger distance of each learned posterior density against the exact one, on a 512×512512 \times512 grid over the prior; mean (standard deviation) over 10 independent datasets. The best value per column is in bold, for the mass the one closest to 1.

References

  1. [1]T. Akiba, S. Sano, T. Yanase, T. Ohta, and M. Koyama. Optuna: A next-generation hyperparameter optimization framework. In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery & Data Mining, KDD ’19, pages 2623–2631, New York, NY, USA, 7 2019. Association for Computing Machinery. doi: 10.1145/3292500.3330701.DOI
  2. [2]J. Arruda, Y. Schälte, C. Peiter, O. Teplytska, U. Jaehde, and J. Hasenauer. An amortized approach to non-linear mixed-effects modeling based on neural posterior estimation. In R. Salakhutdinov, Z. Kolter, K. Heller, A. Weller, N. Oliver, J. Scarlett, and F. Berkekamp, editors, Proceedings of the 41st International Conference on Machine Learning, volume 235 of Proceedings of Machine Learning Research, pages 1865–1901. PMLR, 7 2024. URL https://proceedings.mlr.press/v235/arruda24a.html.DOI
  3. [3]J. Arruda, N. Bracher, U. Köthe, J. Hasenauer, and S. T. Radev. Diffusion models in simulation-based inference: A tutorial review. Transactions on Machine Learning Research, 2026. URL https://openreview.net/forum?id=86Q261z005.arxiv.org/abs/2512.20685
  4. [4]G. Batzolis, J. Stanczuk, C.-B. Schönlieb, and C. Etmann. Conditional image generation with score-based diffusion models. arXiv preprint arXiv:2111.13606, 2021. doi: 10.48550/arXiv.2111.13606.DOI
  5. [5]M. Betancourt. A Conceptual Introduction to Hamiltonian Monte Carlo. arXiv preprint arXiv:1701.02434, 2017. doi: 10.48550/arXiv.1701.02434.DOI
  6. [6]J. Boelts, J.-M. Lueckmann, R. Gao, and J. H. Macke. Flexible and efficient simulation-based inference for models of decision-making. Elife, 11:e77220, 2022. doi: 10.7554/eLife.77220.DOI
  7. [7]J. Bradbury, R. Frostig, P. Hawkins, M. J. Johnson, Y. K. Katariya, C. Leary, D. Maclaurin, G. Necula, A. Paszke, J. VanderPlas, S. Wanderman-Milne, and Q. Zhang. JAX: composable transformations of Python+NumPy programs, 2018. URL http://github.com/jax-ml/jax.
  8. [9]B. Carpenter, A. Gelman, M. D. Hoffman, D. Lee, B. Goodrich, M. Betancourt, M. Brubaker, J. Guo, P. Li, and A. Riddell. Stan: A probabilistic programming language. Journal of statistical software, 76(1):1–32, 2017. doi: 10.18637/jss.v076.i01.DOI
  9. [10]R. T. Q. Chen, Y. Rubanova, J. Bettencourt, and D. Duvenaud. Neural ordinary differential equations. In Proceedings of the 32nd International Conference on Neural Information Processing Systems, NIPS’18, pages 6572–6583, Red Hook, NY, USA, 2018. Curran Associates Inc. URL https://dl.acm.org/doi/10.5555/3327757.3327764.arxiv.org/abs/1806.07366
  10. [12]F. Chollet et al. Keras. https://keras.io, 2015.
  11. [13]J. A. Christen and C. Fox. Markov chain Monte Carlo using an approximation. Journal of Computational and Graphical Statistics, 14(4):795–810, 2005. doi: 10.1198/106186005X76983.DOI
  12. [14]A. Cori, N. M. Ferguson, C. Fraser, and S. Cauchemez. A new framework and software to estimate time-varying reproduction numbers during epidemics. American journal of epidemiology, 178 (9):1505–1512, 2013. doi: 10.1093/aje/kwt133.DOI
  13. [15]K. Cramer, J. Brehmer, and G. Louppe. The frontier of simulation-based inference. Proceedings of the National Academy of Sciences, 117(48):30055–30062, 5 2020. doi: 10.1073/pnas.1912789117.
  14. [16]M. Deistler, J. Boelts, P. Steinbach, G. Moss, T. Moreau, M. Gloeckler, P. L. C. Rodrigues, J. Linhart, J. K. Lappalainen, B. K. Miller, P. J. Gonçalves, J.-M. Lueckmann, C. Schröder, and J. H. Macke. Simulation-Based Inference: A Practical Guide. arXiv preprint arXiv:2508.12939, 2025. doi: 10.48550/arXiv.2508.12939.arxiv.org/abs/2508.12939
  15. [17]L. Dinh, J. Sohl-Dickstein, and S. Bengio. Density estimation using real NVP. In International Conference on Learning Representations, 2017. URL https://openreview.net/forum?id=HkpbnH9lx.arxiv.org/abs/1605.08803
  16. [19]C. Durkan, A. Bekasov, I. Murray, and G. Papamakarios. Neural spline flows. In Proceedings of the 33rd International Conference on Neural Information Processing Systems. Curran Associates Inc., 2019. URL https://proceedings.neurips.cc/paper_files/paper/2019/file/7ac71d433f282034e088473244df8c02-Paper.pdf.
  17. [20]A. Fengler, L. N. Govindarajan, T. Chen, and M. J. Frank. Likelihood approximation networks (lans) for fast inference of simulation models in cognitive neuroscience. eLife, 10:e65074, 2021. doi: 10.7554/elife.65074.DOI
  18. [21]C. Fraser. Estimating individual and household reproduction numbers in an emerging epidemic. PLoS one, 2(8):e758, 2007. doi: 10.1371/journal.pone.0000758.DOI
  19. [22]Z. Geng, M. Deng, X. Bai, Z. Kolter, and K. He. Mean flows for one-step generative modeling. In Advances in Neural Information Processing Systems 38, pages 84032–84054, 2025. doi: 10.52202/085713-2534.DOI
  20. [23]Z. Geng, Y. Lu, Z. Wu, E. Shechtman, J. Z. Kolter, and K. He. Improved mean flows: On the challenges of fastforward generative models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), pages 30467–30476, 2026. URL https://openaccess.thecvf.com/content/CVPR2026/html/Geng_Improved_Mean_Flows_On_the_Challenges_of_Fastforward_Generative_Models_CVPR_2026_paper.html.arxiv.org/abs/2512.02012
  21. [24]M. Gloeckler, M. Deistler, C. Weilbach, F. Wood, and J. H. Macke. All-in-one simulation-based inference. In Proceedings of the 41st International Conference on Machine Learning, ICML’24, pages 15735–15766. JMLR.org, 2024. URL https://dl.acm.org/doi/10.5555/3692070.3692700.arxiv.org/abs/2404.09636
  22. [25]K. M. Gostic, L. McGough, E. B. Baskerville, S. Abbott, K. Joshi, C. Tedijanto, R. Kahn, R. Niehus, J. A. Hay, P. M. De Salazar, et al. Practical considerations for measuring the effective reproductive number, Rₜ. PLoS computational biology, 16(12):e1008409, 2020. doi: 10.1371/journal.pcbi.1008409.DOI
  23. [26]D. Greenberg, M. Nonnenmacher, and J. Macke. Automatic posterior transformation for likelihood-free inference. In International conference on machine learning, pages 2404–2414. PMLR, 2019. URL https://proceedings.mlr.press/v97/greenberg19a.html.arxiv.org/abs/1905.07488
  24. [27]J. Gu, T. Chen, D. Berthelot, H. Zheng, Y. Wang, R. ZHANG, L. Dinh, M. Á. Bautista, J. M. Susskind, and S. Zhai. STARFlow: Scaling latent normalizing flows for high-resolution image synthesis. In The Thirty-ninth Annual Conference on Neural Information Processing Systems, pages 134122–134158, 2025. doi: 10.52202/085713-4036.DOI
  25. [28]M. D. Hoffman and A. Gelman. The No-U-turn sampler: Adaptively setting path lengths in Hamiltonian Monte Carlo. Journal of Machine Learning Research, 15(1):1593–1623, 2014. doi: 10.5555/2627435.2638586.
  26. [29]T. Karras, M. Aittala, S. Laine, and T. Aila. Elucidating the design space of diffusion-based generative models. In Proceedings of the 36th International Conference on Neural Information Processing Systems, NIPS ’22, Red Hook, NY, USA, 2022. Curran Associates, Inc. doi: 10.52202/068431-1926.DOI
  27. [31]Š. Kucharský, A. Mishra, D. Habermann, S. T. Radev, and P.-C. Bürkner. Improving the accuracy of amortized model comparison with self-consistency. arXiv preprint arXiv:2508.20614, 2026. doi: 10.48550/arxiv.2508.20614.DOI
  28. [32]L. Kühmichel, J. M. Huang, V. Pratz, J. Arruda, H. Olischläger, D. Habermann, S. Kucharsky, L. Elsemüller, A. Mishra, N. Bracher, et al. BayesFlow 2.0: Multi-backend amortized Bayesian inference in python. arXiv preprint arXiv:2602.07098, 3 2026. doi: 10.48550/arxiv.2602.07098.
  29. [33]P. Lemos, A. Coogan, Y. Hezaveh, and L. Perreault-Levasseur. Sampling-based accuracy testing of posterior estimators for general inference. In A. Krause, E. Brunskill, K. Cho, B. Engelhardt, S. Sabato, and J. Scarlett, editors, Proceedings of the 40th International Conference on Machine Learning, volume 202 of Proceedings of Machine Learning Research, pages 19256–19273. PMLR, 7 2023. URL https://proceedings.mlr.press/v202/lemos23a.html.arxiv.org/abs/2302.03026
  30. [34]Y. Lipman, R. T. Q. Chen, H. Ben-Hamu, M. Nickel, and M. Le. Flow matching for generative modeling. In The Eleventh International Conference on Learning Representations, 2023. URL https://openreview.net/forum?id=PqvMRDCJT9t.arxiv.org/abs/2210.02747
  31. [35]R. J. Little and D. B. Rubin. Statistical analysis with missing data. Wiley Series in Probability and Statistics. John Wiley & Sons, 2019. doi: 10.1002/9781119482260.
  32. [36]X. Liu, C. Gong, and Q. Liu. Flow straight and fast: Learning to generate and transfer data with rectified flow. In The Eleventh International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=XVjTT1nw5z.arxiv.org/abs/2209.03003
  33. [37]D. Lopez-Paz and M. Oquab. Revisiting classifier two-sample tests. In International Conference on Learning Representations, 2017. URL https://openreview.net/forum?id=SJkXfE5xx.

Paper details

vlnc:W_hk52fhrq
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 2

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Mathematics

Not recorded for this paper

View statement
Looking for related papers…
Contents