Savage-Dickey density ratio estimation with normalizing flows for Bayesian model comparison

Kiyam Lin, 1⋆ Alicja Polanska, 1 Davide Piras, 2,3 Alessio Spurio Mancini, 4 and Jason D. McEwen 1 · 2025

Read Savage-Dickey density ratio estimation with normalizing flows for Bayesian model comparison by Kiyam Lin, 1⋆ Alicja Polanska, 1 Davide Piras, 2,3 Alessio Spurio Mancini, 4 and Jason D. McEwen 1 (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2506-04339.txt.

Introduction

Kiyam Lin, Alicja Polanska, Davide Piras, Alessio Spurio Mancini, and Jason McEwen speed up model comparison in a 2025 paper. Bayesian methods can weigh which science model best fits data, but computing the proof is costly. A shortcut, the Savage-Dickey density ratio, works for nested models using samples from the larger one alone.

The shortcut still needs a density estimate, and classic tools scale poorly to many dimensions. The team uses normalizing flows, a neural method, for that step. Tests on toy and real cosmology cases work well. For one field-level case, two unlike inference paths give matching Bayes factors, a good cross-check.

Catalog record

CREATORKiyam Lin, 1⋆ Alicja Polanska, 1 Davide Piras, 2,3 Alessio Spurio Mancini, 4 and Jason D. McEwen 1
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE38 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2506-04339

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Savage-Dickey density ratio estimation with normalizing flows for Bayesian model comparison ⋆ E-mail: [email protected] Kiyam Lin, 1⋆ Alicja Polanska, 1 Davide Piras, 2,3 Alessio Spurio Mancini, 4 and Jason D. McEwen 1 Abstract A core motivation of science is to evaluate which scientific model best explains observed data. Bayesian model comparison provides a principled statistical approach to comparing scientific models and has found widespread application within cosmology and astrophysics. Calculating the Bayesian evidence is computationally challenging, especially as we continue to explore increasingly more complex models. The Savage-Dickey density ratio (SDDR) provides a method to calculate the Bayes factor (evidence ratio) between two nested models using only posterior samples from the super model. The SDDR requires the calculation of a normalised marginal distribution over the extra parameters of the super model, which has typically been performed using classical density estimators, such as histograms. Classical density estimators, however, can struggle to scale to high-dimensional settings. We introduce a neural SDDR approach using normalizing flows that can scale to settings where the super model contains a large number of extra parameters. We demonstrate the effectiveness of this neural SDDR methodology applied to both toy and realistic cosmological examples. For a field-level inference setting, we show that Bayes factors computed for a Bayesian hierarchical model (BHM) and simulation-based inference (SBI) approach are consistent, providing further validation that SBI extracts as much cosmological information from the field as the BHM approach. The SDDR estimator with normalizing flows is implemented in the open-source harmonic Python package. \journalinfo The Open Journal of Astrophysics \submitted submitted XXX; accepted YYY SDDR with normalizing flowsSDDR with normalizing flows 1 Introduction A core aspect of science is to determine which scientific model of reality is the most accurate. Bayesian model comparison provides a principled statistical approach to comparing scientific models that has found widespread application, particularly in astrophysics and cosmology ( Trotta 2007 ) . With advances in computational power, it is possible to analyse increasingly complex cosmological and astrophysical models. To describe these more complex and intricate models, additional parameters are often required, including those that are physically interesting as well as those that might be considered nuisance parameters yet must be modelled ( von Wietersheim-Kramsta et al. 2025 , e.g.) . These more complex models that often exist in higher-dimensional parameter spaces, however, can be costly to analyse, with some models being infeasible to explore due to insurmountable computational costs. We can make use of modern machine learning techniques and their underlying technologies to massively accelerate the computational speed of performing Bayesian inference. This can be achieved by combining (i) emulation of physical models by machine learning techniques ; (ii) differentiable and probabilistic programming ; (iii) scalable Markov chain Monte Carlo sampling (MCMC) that makes use of gradient information, and (iv) decoupled and scalable Bayesian model selection , as advocated in Piras et al. 2024 . Gradient-based Markov chain Monte Carlo (MCMC) sampling algorithms that can leverage gradients computed efficiently by automatic differentiation make sampling in higher-dimensional parameter spaces tractable, e.g. the No-U-Turn Sampler (NUTS; Hoffman & Gelman 2014 ), a highly efficient and adaptive variant of Hamiltonian Monte Carlo (HMC; Duane et al. 1987 ; Neal 1996 ). Bayesian model selection requires the computation of the Bayesian evidence, which is typically performed by nested sampling ( Skilling 2006 ; see Ashton et al. 2022 ; Buchner 2023 for reviews), where sampling must be performed in a prescribed nested manner for which a variety of algorithms have been developed ( Feroz & Hobson 2008 ; Feroz et al. 2009 ; Higson et al. 2019 ; Feroz et al. 2019 ; Handley et al. 2015a ; Handley et al. 2015b ; Speagle 2020 ; Buchner 2021 ; Cai et al. 2021 ; McEwen et al. 2023 ; Lange 2023 ) . Nested sampling is thus not applicable for arbitrary MCMC sampling algorithms. To compute the Bayesian evidence for arbitrary sampling algorithms, such as NUTS, we require methods to compute the Bayesian evidence that are decoupled from the sampling algorithm while being scalable. Methods that require only posterior samples to compute the evidence have become increasingly popular ( Dickey 1971 ; DiCiccio et al. 1997 ; Trotta 2007 ; Heavens et al. 2017 ; Jia & Seljak 2020 ; McEwen et al. 2021 ; Srinivasan et al. 2024 ; Rinaldi et al. 2024 ) . Amongst these methods, the learned harmonic mean estimator ( McEwen et al. 2021 ; Polanska et al. 2023 ; Polanska et al. 2024a ) , available in the harmonic software package, has been shown to provide robust and scalable evidence calculations and has been growing in popularity within astrophysics and cosmology ( Spurio Mancini et al. 2023 ; Piras et al. 2024 ; Polanska et al. 2024b ; Spurio Mancini et al. 2024 ; Stiskalek & Desmond 2024 ; Du et al. 2025 ; Carrion et al. 2025 ; Stiskalek et al. 2025 ) . Even with such acceleration, the process of performing Bayesian model comparison can still be highly computationally costly as it requires acquiring posterior samples along with their respective likelihood values for every model being evaluated. However, if the models being compared have a relationship where one model is a nested model of the larger super model, then we can make use of the Savage-Dickey density ratio (SDDR; Dickey 1971 ; Verdinelli & Wasserman 1995 ; O’Hagan & Forster 2004 ) to perform Bayesian model comparison without needing to explicitly acquire samples from the nested model. The term ‘nested’ here refers to a relationship between two models where a super model reduces to a smaller, nested model when some of the super model’s parameters are fixed at particular values, as is often the case in cosmological settings. We refer to the parameters common to both the super and nested model as common parameters and the additional parameters of the super model as extra parameters . This approximately halves the computational cost of performing Bayesian model comparison as we only need to perform sampling once for the super model. The SDDR has already been applied to cosmology, for instance by Trotta 2007 ; Marin & Robert 2009 ; Verde et al. 2013 ; Leistedt et al. 2014 ; Salvatelli et al. 2014 ; Di Valentino et al. 2017 ; Di Valentino et al. 2020 ; Kreisch et al. 2020 . Besides requiring nested models, the SDDR also requires there to be sufficient posterior support with high enough sample density around the parameter values where the super model reduces to the nested model to be able to evaluate the marginal posterior accurately. If this requirement is not met, calculating the evidence directly with the learned harmonic mean provides a good alternative. Traditionally the SDDR has been calculated through the use of classical density estimators, such as histograms or kernel density estimation. For situations where there are only a small number of extra parameters, classical density estimators provide good estimates of the evidence ratio. However, this approach can fail even in settings with just a few extra parameters as, e.g., it becomes computationally difficult to normalise the histogram of the probability distribution of the extra parameters by numerical integration due to the curse of dimensionality.

Read the complete text