Neural posterior estimation (NPE) enables Bayesian inference of the posterior parameter in agent-based models (ABMs) with intractable likelihoods, but simulating training data can be computationally expensive. We propose Double-Flow Neural Posterior Estimation (DF-NPE), which combines learned time-series summaries with two conditional normalizing flows for synthetic-data generation and posterior estimation. The framework supplements direct simulations with synthetic training pairs and supports both pooled and ordered training strategies. Experiments in two settings of the Brock-Hommes asset-pricing model show that DF-NPE can reduce direct simulations by 90 percent while achieving lower mean posterior discrepancies and runtime than standard NPE. Performance varies with the allocation of directly simulated and synthetic data and the training strategy. These results establish learned summary augmentation as a practical approach to reducing simulation costs for Bayesian posterior inference of parameters in ABMs.
Figures & tables
Figure 1: DF-NPE with three posterior-training strategies. (A) Direct simulations train the encoder and latent-surrogate flow; stored trajectories are re-encoded, and the current surrogate generates synthetic summaries from retained parameter proposals. (B) The posterior flow is trained using Mixed, Synthetic-to-Simulation or Simulation-to-Synthetic, with the encoder and surrogate held fixed. Blue and teal denote directly-simulated and synthetic data, respectively. The dashed arrow indicates that the fitted posterior, conditioned on the observed summary, supplies the proposal for the next round.
Figure 2: Posterior samples from the approximate ground truth, SNPE and DF-NPE for the smooth Brock–Hommes setting. DF-NPE uses Mixed training at a directly-simulated:synthetic ratio of 3:7. Diagonal panels show marginal posterior distributions as count histograms; upper-triangular panels show bivariate joint distributions as two-dimensional count histograms. Red lines and points denote the mean of the likelihood-based reference posterior. Darker and lighter colours indicate lower and higher sample counts, respectively, in the off-diagonal plots.
Figure 3: Posterior discrepancies of SNPE and DF-NPE with Mixed training for the smooth Brock–Hommes setting. Results show WASS and MMD 2 over ten fits per configuration using one fixed observation. Ratios denote directly-simulated:synthetic allocations; SNPE uses only direct simulations. White lines denote medians, boxes show the interquartile range, and whiskers extend to the most extreme values within 1.5 interquartile ranges.
Figure 4: Posterior samples from the approximate ground truth, SNPE and DF-NPE for the noisy Brock–Hommes setting. DF-NPE uses Mixed training at a directly-simulated:synthetic ratio of 3:7. Diagonal panels show marginal posterior distributions as count histograms; upper-triangular panels show bivariate joint distributions as two-dimensional count histograms. Red lines and points denote the mean of the likelihood-based reference posterior. Darker and lighter colours indicate lower and higher sample counts, respectively, in the off-diagonal plots.
Figure 5: Posterior discrepancies of SNPE and DF-NPE with Mixed training for the noisy Brock–Hommes setting. Results show WASS and MMD 2 over ten fits per configuration using one fixed observation. Ratios denote directly-simulated:synthetic allocations; SNPE uses only direct simulations. White lines denote medians, boxes show the interquartile range, and whiskers extend to the most extreme values within 1.5 interquartile ranges.
Figure 6: Posterior discrepancies of the three DF-NPE training strategies and SNPE for the smooth Brock–Hommes setting. Results show WASS and MMD 2 over ten fits at directly-simulated:synthetic ratios of 1:9, 3:7 and 5:5. Syn. → Sim. and Sim. → Syn. denote Synthetic-to-Simulation and Simulation-to-Synthetic, respectively. White lines denote medians, boxes show the interquartile range, and whiskers extend to the most extreme values within 1.5 interquartile ranges.
Figure 7: Posterior discrepancies of the three DF-NPE training strategies and SNPE for the noisy Brock–Hommes setting. Results show WASS and MMD 2 over ten fits at directly-simulated:synthetic ratios of 1:9, 3:7 and 5:5. Syn. → Sim. and Sim. → Syn. denote Synthetic-to-Simulation and Simulation-to-Synthetic, respectively. White lines denote medians, boxes show the interquartile range, and whiskers extend to the most extreme values within 1.5 interquartile ranges.
Figure 8: End-to-end runtime of SNPE and the three DF-NPE training strategies for the smooth and noisy Brock–Hommes settings. Results show ten runs per configuration at directly-simulated:synthetic ratios of 1:9, 3:7 and 5:5, with runtime measured in minutes. White lines denote medians, boxes show the interquartile range, and whiskers extend to the most extreme values within 1.5 interquartile ranges.
Appendix figures & tables9 assets
Supplementary material from the paper’s appendix.
Appendix
Component
Setting
Supervised encoder
Two-layer GRU, hidden width 32 and latent dimension 8; parameter-regression head with one 32-unit hidden layer
Encoder fit
Adam, learning rate 10−3 , batch size 100, at most 100 epochs; latent extraction batch size 256
Conditional latent surrogate
Five-transform MAF with 50 hidden features; learning rate 5×10−4 , batch size 100, 10% validation and early stopping after 10 validation epochs
Latent posterior estimator
Five-transform SNPE-C MAF with 50 hidden features; learning rate 5×10−4 , batch size 200, 10% validation and early stopping after 20 validation epochs
SNPE comparator
Jointly trained two-layer GRU embedding and MAF posterior through the project defaults
Execution
Timing runs capped neural fits at 500 epochs
Appendix
Table A.1 : Architecture and optimisation settings for Mixed and SNPE. Sequential budgets and allocations are specified in Section 3.2.1 .
Workflow
90% coverage
Median RMSE
Summary MAE
1:9
0.979±0.020
0.577±0.294
0.380±0.318
3:7
0.931±0.093
0.459±0.074
0.267±0.105
5:5
0.957±0.050
0.513±0.060
0.190±0.027
7:3
0.951±0.097
0.482±0.089
0.227±0.063
9:1
0.973±0.022
0.484±0.083
0.203±0.049
SNPE
0.932±0.011
0.372±0.015
0.222±0.014
Appendix
Table B.1: Smooth Brock–Hommes: posterior-predictive checks over ten fits, using 200 posterior draws per fit returned to the simulator. Entries report mean ± sample standard deviation.
Figure C.1 : Posterior samples from the two ordered DF-NPE training strategies for the smooth and noisy Brock–Hommes settings at a directly-simulated:synthetic ratio of 3:7. Syn. → Sim. and Sim. → Syn. denote Synthetic-to-Simulation and Simulation-to-Synthetic, respectively. Diagonal panels show marginal posterior distributions as count histograms; upper-triangular panels show bivariate joint distributions as two-dimensional count histograms. Red lines and points denote the mean of the likelihood-based reference posterior. Darker and lighter colours indicate lower and higher sample counts, respectively, in the off-diagonal plots.
Ratio
Direct/round
WASS gain
MMD 2 gain
MAE gain
1:9
100
0.202±0.140 (5/5)
0.295±0.308 (3/5)
0.083±0.049 (5/5)
3:7
300
0.216±0.096 (5/5)
0.403±0.195 (5/5)
0.067±0.027 (5/5)
5:5
500
0.229±0.172 (5/5)
0.465±0.347 (5/5)
0.070±0.054 (5/5)
7:3
700
0.260±0.063 (5/5)
0.484±0.150 (5/5)
0.076±0.027 (5/5)
9:1
900
0.310±0.057 (5/5)
0.573±0.169 (5/5)
0.087±0.015 (5/5)
Appendix
Table C.1: Smooth Brock–Hommes: same-direct-budget comparisons over five paired seeds. Entries report mean ± sample standard deviation of SNPE-minus-Mixed discrepancies; positive values favour Mixed. Parentheses give improving seeds out of five.
Workflow
WASS
MMD 2
MAE to θ∗
Time (min)
Speed-up
Smooth Brock–Hommes
1:9
0.3051±0.0841
0.5637±0.1997
0.0780±0.0256
10.15±2.21
6.45×
3:7
0.2681±0.1042
0.4595±0.2168
0.0685±0.0326
16.03±5.59
4.08×
5:5
0.2458±0.1228
0.4007±0.2635
0.0590±0.0382
19.13±2.91
3.42×
7:3
0.2489±0.1239
0.4478±0.2968
0.0656±0.0414
21.47±2.14
3.05×
9:1
0.2403±0.1027
0.4430±0.2559
0.0622±0.0332
25.63±1.11
2.55×
Appendix
Table C.2: Mixed workflows and SNPE across the two Brock–Hommes settings. Entries are mean ± sample standard deviation over ten seeds. Scores and timing conventions follow Section 3.1 . Ratios are directly-simulated:synthetic allocations; time is in minutes.
Figure C.2 : Computational cost of SNPE and DF-NPE with Mixed training for the Brock–Hommes model, broken down by workflow phase. Stacked segments show median phase times in minutes over ten seeds; ratios denote directly-simulated:synthetic allocations. Colours identify the computational phases. The setup / I/O / plotting segment contains costs not assigned to the other phases. Segment medians need not sum to the median end-to-end runtime.
Ratio
Schedule
WASS
MMD 2
MAE to θ∗
Time (min)
Smooth Brock–Hommes
1:9
Syn. → Sim.
0.4182±0.1407
0.76124±0.24726
0.1223±0.0406
27.71±26.66
1:9
Sim. → Syn.
0.3696±0.1209
0.67745±0.27146
0.1017±0.0376
17.70±9.69
3:7
Syn. → Sim.
0.2993±0.0888
0.55649±0.23965
0.0804±0.0258
15.39±7.99
3:7
Sim. → Syn.
0.3822±0.1739
0.76860±0.47356
0.1011±0.0463
17.22±5.87
5:5
Syn. → Sim.
0.2612±0.1182
0.44882±0.31734
0.0676±0.0336
25.23±20.61
Appendix
Table C.3 : Complete ordered-workflow results across ten seeds (mean ± sample standard deviation). Syn. → Sim. denotes Synthetic-to-Simulation and Sim. → Syn. denotes Simulation-to-Synthetic. Scores follow Section 3.1 ; time is recorded end-to-end minutes. Mixed and SNPE results are in Table C.2 .
Task
Source
Ratio
Prior excess MMD 2
Ref. excess MMD 2
Smooth BH
G→S
1:9
0.36259±0.03831
0.29850±0.07948
Smooth BH
G→S
3:7
0.22473±0.04098
0.15527±0.06224
Smooth BH
G→S
5:5
0.20284±0.03971
0.09657±0.02512
Smooth BH
S→G
1:9
0.27270±0.05115
0.20251±0.09400
Smooth BH
S→G
3:7
0.25792±0.04028
0.13531±0.04036
Smooth BH
S→G
5:5
0.21534±0.04260
0.08688±0.03532
Appendix
Table D.1: Conditional surrogate diagnostics over ten source fits (mean ± source-seed standard deviation). Prior and reference excess MMD 2 average ten parameter sites per region, with source-specific standardisation.
Task
Source
Ratio
ΔMMDdiag2
ΔWmarg
Δeref
Smooth BH
G→S
1:9
−0.01428±0.01305 (9)
−0.00933±0.01407 (7)
−0.00989±0.01472 (7)
Smooth BH
G→S
3:7
−0.00624±0.02317 (5)
−0.00832±0.00733 (9)
−0.01047±0.00958 (8)
Smooth BH
G→S
5:5
−0.01409±0.01681 (7)
−0.01087±0.00864 (9)
−0.01311±0.00914 (10)
Smooth BH
S→G
1:9
−0.00143±0.02758 (7)
−0.00077±0.01900 (5)
−0.00365±0.01970 (5)
Smooth BH
S→G
3:7
−0.00139±0.02299 (6)
0.00082±0.02088 (4)
0.00044±0.02295 (5)
Smooth BH
S→G
5:5
−0.02537±0.01602 (9)
−0.01076±0.01356 (8)
−0.01327±0.01485 (8)
Appendix
Table D.2 : Frozen-component prior-only controls: augmented-minus-direct differences over ten source fits (mean ± sample standard deviation). Parentheses give improvements out of ten; negative values favour augmentation. ΔMMDdiag2 uses the standardised diagnostic kernel, ΔWmarg is prior-width-scaled marginal Wasserstein distance, and Δeref is reference-mean error. Source labels identify the encoder–surrogate origin ( G→S : Synthetic-to-Simulation; S→G : Simulation-to-Synthetic). Both augmented arms use pooled training. Both arms share the directly-simulated bank, initialisation and 1,000-update budget, but direct exposure differs. Diagnostic scores use different definitions from the main scores.
Neural posterior estimation learns probability distributions over unknown model parameters from observed data, often using simulations when likelihoods are unavailable.
Agent-based models (ABMs) are widely used in economics and social sciences. They represent heterogeneous personal behaviors and their interactions by using simulations, whereas their likelihoods are often intractable for parameter estimations. Therefore, most traditional statistical inference techniques are hindered. Driven by recent advances in probabilistic machine learning, recent works have applied neural networks to achieve likelihood-free inference in large-scale ABMs. Specifically, Neural Posterior Estimation using normalizing flows provide amortized Bayesian inference from simulations, yet a pre-trained estimator may become inaccurate when the target task changes. In this work, we investigate the practicality of adapting a pre-trained conditional normalizing flow through a unified sequential neural posterior estimation test-time training (SNPE-TTT) framework. The framework includes four adaptation strategies: full-parameter adaptation, low-rank adaptation, and two update spaces identified from target-task gradients. We evaluate all four methods across economic simulation models with both tractable and intractable likelihoods. These benchmarks demonstrate that the sequential neural posterior estimation test-time training framework can adapt pre-trained posterior estimators to related inference tasks using a limited budget of target simulations. Posterior recovery and computational benefits depend on the task and adaptation strategy, with lower target-stage cost in some settings but no consistently superior posterior accuracy.
Neural Posterior Estimation (NPE) enables rapid parameter inference for complex simulators with intractable likelihoods. NPE trains an inference network to estimate a probability density over parameters given data, typically assumed to be continuous. However, many scientific models involve parameter spaces that are mixed, that is, they contain both discrete and continuous dimensions. We address this limitation by extending NPE to mixed parameter spaces through an inference network that jointly handles discrete and continuous parameters. The inference network factorizes the joint posterior into discrete and continuous components, combining an autoregressive classifier for the discrete parameters with a generative model for the continuous parameters, trained jointly under a single simulation-based objective. In addition, we propose a diagnostic tool to assess the calibration of the mixed posterior approximation. Across tractable toy examples and real-world scientific simulators, our joint inference approach yields accurate and calibrated posteriors. The inference framework is available in the sbi Python package.
Jan Boelts, Cornelius Schröder, Jonas Beck +3
appliedAI Institute for Europe · Machine Learning in Science, University of Tübingen · Tübingen AI Center +3
Deep learning models are being used for the analysis of parametric statistical models based on simulation-only frameworks. Bayesian models using normalizing flows simulate data from a prior distribution and are composed of two deep neural networks: a summary network that learns a sufficient statistic for the parameter and a normalizing flow that conditional on the summary network can approximate the posterior distribution. Here, we explore frequentist models that are based on a single summary network. During training, input of the network is a simulated data set based on a parameter and the loss function minimizes the mean-square error between learned summary and parameter. The network thereby solves the inverse problem of parameter estimation. We propose a branched network structure that contains collapsing layers that reduce a data set to summary statistics that are further mapped through fully connected layers to approximate the parameter estimate. We motivate our choice of network structure by theoretical considerations. In simulations we demonstrate three desirable properties of parameter estimates: finite sample exactness, robustness to data contamination, and algorithm approximation. These properties are achieved offering the the network varying sample size, contaminated data, and data needing algorithmic reconstruction during the training phase. In our simulations an EM-algorithm for genetic data is automatically approximated by the network. Simulation only approaches seem to offer practical advantages in complex modeling tasks where the simpler data simulation part is left to the researcher and the more complex problem of solving the inverse problem is left to the neural network. Challenging future work includes offering pre-trained models that can be used in a wide variety of applications.
Stefan Böhringer
Department of Biomedical Data Sciences Leiden University Medical Center Einthovenweg 20, 2333 ZC Leiden, The Netherlands