pbhstat: A Python Package for Calculating the Primordial Black Hole Abundance
Abstract
1. Introduction
2. Output of the Code
3. Choice of Statistics
3.1. Press–Schechter
3.2. Peaks Theory
3.3. Non-Linear Compaction Function Statistics
4. Power Spectra and Smoothing
5. Structure of the Code and Installation
- power_spectrum.pyContains the PowerSpectrum class, which defines and evaluates the primordial curvature power spectrum. There are some pre-defined forms for the power spectrum which can be loaded, such as flat and piecewise. It also supports both analytical and tabulated user-defined spectra, which can be implemented directly into the class or loaded as an array. The class then provides interpolation over a user-specified range of wavenumbers k.
- mass_variance.pyImplements the MassVariance class, which computes the smoothed mass variance over a range of scales, using the power spectrum and a choice of window function. Currently, the Gaussian window function and the real-space top-hat window functions are implemented, with a large-k cut-off optional for the latter.
- collapse_stats.pyProvides statistical models for PBH formation. It includes classes for the Press–Schechter formalism (PressSchechterModel), peaks theory (PeaksTheoryModel), and for non-linear compaction statistics (NonLinearModel). These classes set up the computation of the mass function of primordial black holes as a function of mass.
- mass_function.pyContains the MassFunction class, which wraps around the collapse statistics to compute the differential PBH mass function and total abundance .
- stats_utils.pyHosts auxiliary functions used predominantly for the NonLinearkModel class, such as critical threshold calculations, filtering functions, and intermediate formulae that can be pre-computed.
- plot_utils.pyProvides helper routines for plotting key quantities such as the power spectrum, mass variance, and PBH mass function.
- constants.pyStores fiducial values of cosmological quantities that can be edited and will be imported for abundance calculations.
6. Usage Instructions
6.1. Installation
- pip install pbhstat
- git clone https://github.com/pipcole/pbhstat.git
- and run
- cd pbhstat
- pip install -e .
- {for an editable install. The required dependencies are numpy, matplotlib, scipy, and tqdm.
6.2. Example Usage
- or loaded from file:
- which should then be instantiated with
- Alternatively, the power spectrum can be generated from one of the pre-set options, for example, a piecewise power spectrum which can be instantiated directly:
- Key quantities can be plotted using the routines in plot_utils.py.
- Then, a modified version of the default script PlotPBHbounds.py is available at https://github.com/pipcole/pbhstat (accessed on 3 July 2025) to be run in the directory of PBHbounds. This will overplot the mass function produced with pbhstat with the bounds (that can be specified via the command line, if not all bounds are desired) from PBHbounds. We emphasise that the constraints themselves depend on the form of the mass function, and therefore overlaying broad mass functions with monochromatic PBH constraints is inconsistent. We recommend that this utility should only be used for narrow mass functions, and in any case as an approximate guide. See [66] for a method for converting constraints from monochromatic to extended mass functions.
7. Summary and Outlook
Author Contributions
Funding
Acknowledgments
Conflicts of Interest
1 | In some works, this variable is also denoted by , , or . |
2 | Here, we defined the width parameters to be dimensionless. |
3 | This choice, strictly speaking, refers to a non-canonical definition of the compaction function; see [32]. |
4 | We remind the reader that all expressions are considered at the maximum of the compaction function where . |
References
- Zel’dovich, Y.B.; Novikov, I.D. The Hypothesis of Cores Retarded during Expansion and the Hot Cosmological Model. Soviet Astron. AJ (Engl. Transl.) 1967, 10, 602. [Google Scholar]
- Hawking, S. Gravitationally collapsed objects of very low mass. Mon. Not. Roy. Astron. Soc. 1971, 152, 75. [Google Scholar] [CrossRef]
- Carr, B.J.; Hawking, S.W. Black holes in the early Universe. Mon. Not. Roy. Astron. Soc. 1974, 168, 399–415. [Google Scholar] [CrossRef]
- Page, D.N.; Hawking, S.W. Gamma rays from primordial black holes. Astrophys. J. 1976, 206, 1–7. [Google Scholar] [CrossRef]
- MacGibbon, J.H.; Carr, B.J. Cosmic rays from primordial black holes. Astrophys. J. 1991, 371, 447–469. [Google Scholar] [CrossRef]
- Barrau, A.; Boudoul, G.; Donnard, J.; Grain, J.; Servant, G. Gamma-ray constraints on the density of primordial black holes. Astron. Astrophys. 2003, 398, 403–410. [Google Scholar] [CrossRef]
- Sasaki, M.; Suyama, T.; Tanaka, T.; Yokoyama, S. Primordial black hole scenario for the gravitational wave event GW150914. Phys. Rev. Lett. 2016, 117, 061101. [Google Scholar] [CrossRef]
- Carr, B.; Kohri, K.; Sendouda, Y.; Yokoyama, J. Constraints on primordial black holes. Rept. Prog. Phys. 2021, 84, 116902. [Google Scholar] [CrossRef] [PubMed]
- Green, A.M.; Kavanagh, B.J. Primordial black holes as a dark matter candidate. J. Phys. G 2021, 48, 043001. [Google Scholar] [CrossRef]
- Khlopov, M.Y. Primordial black holes. Res. Astron. Astrophys. 2010, 10, 495–528. [Google Scholar] [CrossRef]
- Ivanov, P.; Naselsky, P.; Novikov, I. Inflation and primordial black holes as dark matter. Phys. Rev. D 1994, 50, 7173–7178. [Google Scholar] [CrossRef]
- Carr, B.J.; Gilbert, J.H.; Lidsey, J.E. Black hole relics and inflation: Limits on blue perturbation spectra. Phys. Rev. D 1994, 50, 4853–4867. [Google Scholar] [CrossRef]
- Garcia-Bellido, J.; Linde, A.D.; Wands, D. Density perturbations and black hole formation in hybrid inflation. Phys. Rev. D 1996, 54, 6040–6058. [Google Scholar] [CrossRef]
- Yoo, C.M. The basics of primordial black hole formation and abundance estimation. arXiv 2024, arXiv:2211.13512. [Google Scholar] [CrossRef]
- Carr, B.; Kuhnel, F. Primordial black holes as dark matter candidates. SciPost Phys. Lect. Notes 2022, 48, 1. [Google Scholar] [CrossRef]
- Escrivà, A.; Kuhnel, F.; Tada, Y. Primordial Black Holes. In Black Holes in the Era of Gravitational-Wave Astronomy; Elsevier: Amsterdam, The Netherlands, 2022. [Google Scholar] [CrossRef]
- Musco, I.; Miller, J.C.; Rezzolla, L. Computations of primordial black hole formation. Class. Quant. Grav. 2005, 22, 1405–1424. [Google Scholar] [CrossRef]
- Escrivà, A. Simulation of primordial black hole formation using pseudo-spectral methods. Phys. Dark Univ. 2020, 27, 100466. [Google Scholar] [CrossRef]
- Musco, I. Numerical Simulations of Primordial Black Holes. In Primordial Black Holes; Springer: Singapore, 2025. [Google Scholar] [CrossRef]
- Germani, C.; Musco, I. Abundance of Primordial Black Holes Depends on the Shape of the Inflationary Power Spectrum. Phys. Rev. Lett. 2019, 122, 141302. [Google Scholar] [CrossRef] [PubMed]
- Musco, I. Threshold for primordial black holes: Dependence on the shape of the cosmological perturbations. Phys. Rev. D 2019, 100, 123524. [Google Scholar] [CrossRef]
- Ando, K.; Inomata, K.; Kawasaki, M. Primordial black holes and uncertainties in the choice of the window function. Physical Review D 2018, 97, 103528. [Google Scholar] [CrossRef]
- Yoo, C.M.; Harada, T.; Garriga, J.; Kohri, K. Primordial black hole abundance from random Gaussian curvature perturbations and a local density threshold. Prog. Theor. Exp. Phys. 2018, 2018, 123E01. [Google Scholar] [CrossRef]
- Young, S. Computation of the Abundance of Primordial Black Holes. In Primordial Black Holes; Springer: Singapore, 2025. [Google Scholar] [CrossRef]
- Fumagalli, J.; Garriga, J.; Germani, C.; Sheth, R.K. Unexpected shape of the primordial black hole mass function. Phys. Rev. D 2025, 111, 123518. [Google Scholar] [CrossRef]
- Pi, S.; Sasaki, M.; Takhistov, V.; Wang, J. Primordial Black Hole Formation from Power Spectrum with Finite-width. arXiv 2024, arXiv:2501.00295. [Google Scholar] [CrossRef]
- Press, W.H.; Schechter, P. Formation of Galaxies and Clusters of Galaxies by Self-Similar Gravitational Condensation. Astrophys. J. 1974, 187, 425–438. [Google Scholar] [CrossRef]
- Carr, B.J. The Primordial black hole mass spectrum. Astrophys. J. 1975, 201, 1–19. [Google Scholar] [CrossRef]
- Bardeen, J.M.; Bond, J.R.; Kaiser, N.; Szalay, A.S. The Statistics of Peaks of Gaussian Random Fields. Astrophys. J. 1986, 304, 15. [Google Scholar] [CrossRef]
- Green, A.M.; Liddle, A.R.; Malik, K.A.; Sasaki, M. A New calculation of the mass fraction of primordial black holes. Phys. Rev. D 2004, 70, 041502. [Google Scholar] [CrossRef]
- Young, S.; Byrnes, C.T.; Sasaki, M. Calculating the mass fraction of primordial black holes. J. Cosmol. Astropart. Phys. 2014, 2014, 45. [Google Scholar] [CrossRef]
- Young, S.; Musso, M. Application of peaks theory to the abundance of primordial black holes. J. Cosmol. Astropart. Phys. 2020, 11, 22. [Google Scholar] [CrossRef]
- Germani, C.; Sheth, R.K. Nonlinear statistics of primordial black holes from Gaussian curvature perturbations. Phys. Rev. D 2020, 101, 063520. [Google Scholar] [CrossRef]
- Germani, C.; Sheth, R.K. The Statistics of Primordial Black Holes in a Radiation-Dominated Universe: Recent and New Results. Universe 2023, 9, 421. [Google Scholar] [CrossRef]
- Özsoy, O.; Tasinato, G. Inflation and Primordial Black Holes. Universe 2023, 9, 203. [Google Scholar] [CrossRef]
- Pattison, C.; Vennin, V.; Assadullahi, H.; Wands, D. Quantum diffusion during inflation and primordial black holes. J. Cosmol. Astropart. Phys. 2017, 2017, 46. [Google Scholar] [CrossRef]
- Ezquiaga, J.M.; García-Bellido, J. Quantum diffusion beyond slow-roll: Implications for primordial black-hole production. J. Cosmol. Astropart. Phys. 2018, 2018, 18. [Google Scholar] [CrossRef]
- Biagetti, M.; De Luca, V.; Franciolini, G.; Kehagias, A.; Riotto, A. The formation probability of primordial black holes. Phys. Lett. B 2021, 820, 136602. [Google Scholar] [CrossRef]
- Vennin, V.; Wands, D. Quantum Diffusion and Large Primordial Perturbations from Inflation. In Primordial Black Holes; Springer Nature: Singapore, 2025; pp. 201–227. [Google Scholar] [CrossRef]
- Bullock, J.S.; Primack, J.R. NonGaussian fluctuations and primordial black holes from inflation. Phys. Rev. D 1997, 55, 7423–7439. [Google Scholar] [CrossRef]
- Ivanov, P. Nonlinear metric perturbations and production of primordial black holes. Phys. Rev. D 1998, 57, 7145–7154. [Google Scholar] [CrossRef]
- Young, S.; Byrnes, C.T. Primordial black holes in non-Gaussian regimes. J. Cosmol. Astropart. Phys. 2013, 08, 52. [Google Scholar] [CrossRef]
- Byrnes, C.T.; Copeland, E.J.; Green, A.M. Primordial black holes as a tool for constraining non-Gaussianity. Phys. Rev. D 2012, 86, 043512. [Google Scholar] [CrossRef]
- Tada, Y.; Yokoyama, S. Primordial black holes as biased tracers. Phys. Rev. D 2015, 91, 123534. [Google Scholar] [CrossRef]
- Atal, V.; Germani, C. The role of non-Gaussianities in Primordial Black Hole formation. Phys. Dark Univ. 2019, 24, 100275. [Google Scholar] [CrossRef]
- Franciolini, G.; Kehagias, A.; Matarrese, S.; Riotto, A. Primordial Black Holes from Inflation and non-Gaussianity. J. Cosmol. Astropart. Phys. 2018, 3, 16. [Google Scholar] [CrossRef]
- Kehagias, A.; Musco, I.; Riotto, A. Non-Gaussian Formation of Primordial Black Holes: Effects on the Threshold. J. Cosmol. Astropart. Phys. 2019, 12, 29. [Google Scholar] [CrossRef]
- Riccardi, F.; Taoso, M.; Urbano, A. Solving peak theory in the presence of local non-gaussianities. J. Cosmol. Astropart. Phys. 2021, 8, 60. [Google Scholar] [CrossRef]
- Gow, A.D.; Assadullahi, H.; Jackson, J.H.P.; Koyama, K.; Vennin, V.; Wands, D. Non-perturbative non-Gaussianity and primordial black holes. EPL 2023, 142, 49001. [Google Scholar] [CrossRef]
- Matsubara, T.; Sasaki, M. Non-Gaussianity effects on the primordial black hole abundance for sharply-peaked primordial spectrum. J. Cosmol. Astropart. Phys. 2022, 2022, 94. [Google Scholar] [CrossRef]
- Nakama, T.; Silk, J.; Kamionkowski, M. Stochastic gravitational waves associated with the formation of primordial black holes. Phys. Rev. D 2017, 95, 043511. [Google Scholar] [CrossRef]
- Shibata, M.; Sasaki, M. Black hole formation in the Friedmann universe: Formulation and computation in numerical relativity. Phys. Rev. D 1999, 60, 084002. [Google Scholar] [CrossRef]
- Harada, T.; Yoo, C.M.; Nakama, T.; Koga, Y. Cosmological long-wavelength solutions and primordial black hole formation. Phys. Rev. D 2015, 91, 084057. [Google Scholar] [CrossRef]
- Uehara, K.; Escrivà, A.; Harada, T.; Saito, D.; Yoo, C.M. Numerical simulation of type II primordial black hole formation. J. Cosmol. Astropart. Phys. 2025, 1, 3. [Google Scholar] [CrossRef]
- Shimada, M.; Escrivá, A.; Saito, D.; Uehara, K.; Yoo, C.M. Primordial black hole formation from type II fluctuations with primordial non-Gaussianity. J. Cosmol. Astropart. Phys. 2025, 2, 18. [Google Scholar] [CrossRef]
- Inui, R.; Joana, C.; Motohashi, H.; Pi, S.; Tada, Y.; Yokoyama, S. Primordial black holes and induced gravitational waves from logarithmic non-Gaussianity. J. Cosmol. Astropart. Phys. 2025, 3, 21. [Google Scholar] [CrossRef]
- Escrivà, A. The threshold for PBH formation in the type-II region and its analytical estimation. arXiv 2025, arXiv:2504.05814. [Google Scholar] [CrossRef]
- Gow, A.D.; Byrnes, C.T.; Cole, P.S.; Young, S. The power spectrum on small scales: Robust constraints and comparing PBH methodologies. J. Cosmol. Astropart. Phys. 2021, 2, 2. [Google Scholar] [CrossRef]
- Young, S. The primordial black hole formation criterion re-examined: Parametrisation, timing and the choice of window function. Int. J. Mod. Phys. D 2019, 29, 2030002. [Google Scholar] [CrossRef]
- Niemeyer, J.C.; Jedamzik, K. Near-Critical Gravitational Collapse and the Initial Mass Function of Primordial Black Holes. Phys. Rev. Lett. 1998, 80, 5481–5484. [Google Scholar] [CrossRef]
- Young, S.; Musco, I.; Byrnes, C.T. Primordial black hole formation and abundance: Contribution from the non-linear relation between the density and curvature perturbation. J. Cosmol. Astropart. Phys. 2019, 11, 12. [Google Scholar] [CrossRef]
- Escrivà, A.; Germani, C.; Sheth, R.K. Universal threshold for primordial black hole formation. Phys. Rev. D 2020, 101, 044022. [Google Scholar] [CrossRef]
- Kehagias, A.; Perrone, D.; Riotto, A. Why the universal threshold for primordial black hole formation is universal. Class. Quant. Grav. 2025, 42, 055010. [Google Scholar] [CrossRef]
- Wang, Q.; Liu, Y.C.; Su, B.Y.; Li, N. Primordial black holes from the perturbations in the inflaton potential in peak theory. Phys. Rev. D 2021, 104, 083546. [Google Scholar] [CrossRef]
- Kavanagh, B.J. Bradkav/PBHbounds: Release Version, version = 1.0; Zenodo: Geneve, Switzerland, 2019. [Google Scholar] [CrossRef]
- Bellomo, N.; Bernal, J.L.; Raccanelli, A.; Verde, L. Primordial Black Holes as Dark Matter: Converting Constraints from Monochromatic to Extended Mass Distributions. J. Cosmol. Astropart. Phys. 2018, 1, 4. [Google Scholar] [CrossRef]
- Afzal, A.; Agazie, G.; Anumarlapudi, A.; Archibald, A.M.; Arzoumanian, Z.; Baker, P.T.; Bécsy, B.; Blanco-Pillado, J.J.; Blecha, L.; Boddy, K.K. The NANOGrav 15 yr Data Set: Search for Signals from New Physics. Astrophys. J. Lett. 2023, 951, L11. [Google Scholar] [CrossRef]
- Antoniadis, J.; Arumugam, P.; Arumugam, S.; Babak, S.; Bagchi, M.; Nielsen, A.S.B.; Bassa, C.G.; Bathula, A.; Berthereau, A.; Bonetti, M.; et al. The second data release from the European Pulsar Timing Array-IV. Implications for massive black holes, dark matter, and the early Universe. A&A 2024, 685, A94. [Google Scholar] [CrossRef]
- Niikura, H.; Takada, M.; Yasuda, N.; Lupton, R.H.; Sumi, T.; More, S.; Kurita, T.; Sugiyama, S.; More, A.; Oguri, M.; et al. Microlensing constraints on primordial black holes with Subaru/HSC Andromeda observations. Nat. Astron. 2019, 3, 524–534. [Google Scholar] [CrossRef]
- Mróz, P.; Udalski, A.; Szymański, M.K.; Soszyński, I.; Pietrukowicz, P.; Kozłowski, S.; Poleski, R.; Skowron, J.; Ulaczyk, K.; Gromadzki, M.; et al. Limits on Planetary-mass Primordial Black Holes from the OGLE High-cadence Survey of the Magellanic Clouds. Astrophys. J. Lett. 2024, 976, L19. [Google Scholar] [CrossRef]
- Byrnes, C.T.; Hindmarsh, M.; Young, S.; Hawkins, M.R. Primordial black holes with an accurate QCD equation of state. J. Cosmol. Astropart. Phys. 2018, 2018, 41. [Google Scholar] [CrossRef]
- Escrivà, A.; Bagui, E.; Clesse, S. Simulations of PBH formation at the QCD epoch and comparison with the GWTC-3 catalog. J. Cosmol. Astropart. Phys. 2023, 2023, 4. [Google Scholar] [CrossRef]
- Musco, I.; Jedamzik, K.; Young, S. Primordial black hole formation during the QCD phase transition: Threshold, mass distribution, and abundance. Phys. Rev. D 2024, 109, 083506. [Google Scholar] [CrossRef]
- Young, S.; Musco, I.; Byrnes, C.T. Influence of large local and nonlocal bispectra on primordial black hole abundance. J. Cosmol. Astropart. Phys. 2022, 2, 32. [Google Scholar] [CrossRef]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Cole, P.S.; Fumagalli, J. pbhstat: A Python Package for Calculating the Primordial Black Hole Abundance. Universe 2025, 11, 322. https://doi.org/10.3390/universe11090322
Cole PS, Fumagalli J. pbhstat: A Python Package for Calculating the Primordial Black Hole Abundance. Universe. 2025; 11(9):322. https://doi.org/10.3390/universe11090322
Chicago/Turabian StyleCole, Philippa S., and Jacopo Fumagalli. 2025. "pbhstat: A Python Package for Calculating the Primordial Black Hole Abundance" Universe 11, no. 9: 322. https://doi.org/10.3390/universe11090322
APA StyleCole, P. S., & Fumagalli, J. (2025). pbhstat: A Python Package for Calculating the Primordial Black Hole Abundance. Universe, 11(9), 322. https://doi.org/10.3390/universe11090322