{"id":23515243,"url":"https://github.com/thomasgesseyjones/fullybayesianforecastsexample","last_synced_at":"2026-04-06T01:01:48.964Z","repository":{"id":194522733,"uuid":"672572583","full_name":"ThomasGesseyJones/FullyBayesianForecastsExample","owner":"ThomasGesseyJones","description":"Example of a fully Bayesian forecast using evidence networks applied to 21-cm cosmology","archived":false,"fork":false,"pushed_at":"2024-08-14T20:04:55.000Z","size":6021,"stargazers_count":9,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-10-19T00:02:23.513Z","etag":null,"topics":["21cm-signal","astronomy","astrophysics","bayesian-methods","cosmology","python","simulation-based-inference","statistics"],"latest_commit_sha":null,"homepage":"https://ui.adsabs.harvard.edu/abs/2024PhRvD.109l3541G/","language":"TeX","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThomasGesseyJones.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-07-30T14:42:30.000Z","updated_at":"2025-02-28T19:29:03.000Z","dependencies_parsed_at":"2024-03-26T21:26:19.470Z","dependency_job_id":"51806eae-58ca-4064-9bee-133a90ec9474","html_url":"https://github.com/ThomasGesseyJones/FullyBayesianForecastsExample","commit_stats":null,"previous_names":["thomasgesseyjones/fullybayesianforecastsexample"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/ThomasGesseyJones/FullyBayesianForecastsExample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasGesseyJones%2FFullyBayesianForecastsExample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasGesseyJones%2FFullyBayesianForecastsExample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasGesseyJones%2FFullyBayesianForecastsExample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasGesseyJones%2FFullyBayesianForecastsExample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThomasGesseyJones","download_url":"https://codeload.github.com/ThomasGesseyJones/FullyBayesianForecastsExample/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThomasGesseyJones%2FFullyBayesianForecastsExample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31455474,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"ssl_error","status_checked_at":"2026-04-05T21:22:51.943Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["21cm-signal","astronomy","astrophysics","bayesian-methods","cosmology","python","simulation-based-inference","statistics"],"created_at":"2024-12-25T14:13:13.192Z","updated_at":"2026-04-06T01:01:48.946Z","avatar_url":"https://github.com/ThomasGesseyJones.png","language":"TeX","funding_links":[],"categories":[],"sub_categories":[],"readme":"===============================\nFully Bayesian Forecast Example\n===============================\n\nOverview\n--------\n\n:Name: Fully Bayesian Forecast Example\n:Author: Thomas Gessey-Jones\n:Version: 1.0.1\n:Homepage: https://github.com/ThomasGesseyJones/FullyBayesianForecastsExample\n:Letter: https://ui.adsabs.harvard.edu/abs/2024PhRvD.109l3541G/abstract\n\n.. image:: https://img.shields.io/badge/python-3.8-blue.svg\n   :target: https://www.python.org/downloads/\n   :alt: Python version\n.. image:: https://img.shields.io/badge/license-MIT-blue.svg\n   :target: https://github.com/ThomasGesseyJones/ErrorAffirmations/blob/main/LICENSE\n   :alt: License information\n.. image:: https://img.shields.io/badge/arXiv-2309.06942-b31b1b.svg?style=flat\n    :target: https://ui.adsabs.harvard.edu/abs/2023arXiv230906942G\n    :alt: arXiv link\n\n\nExample of a fully Bayesian forecast performed using an `Evidence Network \u003chttps://ui.adsabs.harvard.edu/abs/2023arXiv230511241J/abstract\u003e`__.\nThis code also replicates the analysis of\n`Gessey-Jones et al. (2024) \u003chttps://ui.adsabs.harvard.edu/abs/2024PhRvD.109l3541G/abstract\u003e`__.\nThis repository thus serves the dual purposes of providing an example code base others\ncan modify to perform their own fully Bayesian forecasts and also providing a\nreproducible analysis pipeline for the letter.\n\nThe overall goal of the code is to produce a fully Bayesian forecast of\nthe chance of a `REACH \u003chttps://ui.adsabs.harvard.edu/abs/2022NatAs...6..984D/abstract\u003e`__-like experiment\nmaking a significant detection of the 21-cm global signal from within foregrounds and noise. It also produces\nfigures showing how this conclusion changes with different astrophysical parameter values\nand validates the forecast through blind coverage\ntests and comparison to `PolyChord \u003chttps://ui.adsabs.harvard.edu/abs/2015MNRAS.453.4384H/abstract\u003e`__.\n\n\n\nInstallation\n------------\n\nThe repository is intended to be installed locally\nby directly cloning it from GitHub. To do this run the following command in the terminal\n\n.. code:: bash\n\n    git clone git@github.com:ThomasGesseyJones/FullyBayesianForecastsExample.git\n\nThis will create a local copy of the repository. The pipeline can\nthen be run from the terminal (see below).\n\n\nStructure and Usage\n-------------------\n\nThe code is split into two main parts. The first part is the\nmodules which provide the general functionality of evidence networks,\ndata simulators, and prior samplers. The second part\nis the scripts which run the fully Bayesian forecast.\n\nThere are three modules included in the repository:\n\n- evidence_networks: This module contains the code for the evidence network\n  class. This class is used to build the evidence network used in the forecasts.\n  The module also provides an implementation of the l-POP exponential loss\n  function.\n  See the class docstring for more details of its capabilities and usage.\n- priors: This module contains the code to generate functions that\n  sample standard prior distributions. These include\n  uniform, log-uniform, and Gaussian priors.\n- simulators: This module defines simulators. In our code, these are functions\n  that take a number of data simulations to run and return that number of mock data\n  simulations alongside the values of any parameters that were used in the\n  simulations. Submodules of this module define functions to generate specific\n  simulators for noise, foregrounds, and the 21-cm signal.\n\nThese three modules are used in the three analysis scripts:\n\n- verification_with_polychord.py: This script generates a range of mock data\n  sets from both the no-signal model and the with-signal model, and then\n  performs a Bayesian analysis on each of them.\n  Evaluating the Bayes ratio between the two models of the data\n  using Polychord. These results are then stored in the verification_data directory\n  for later comparison with the results from the evidence network to\n  verify its accuracy. It should be run first, ideally with a large number of\n  versions in parallel as it is very computationally expensive but\n  splits simply into one task per data set.\n- train_evidence_network.py: This script builds the evidence network object and\n  the data simulator functions, then trains the evidence network. Once trained\n  it stores the evidence network in the models directory, then runs a blind\n  coverage test on the network and validates its performance against the\n  Polychord Bayes ratio evaluations from the previous script. It should\n  be run second.\n- visualize_forecasts.py: This script loads the evidence network from the\n  models directory and uses it to forecast the chance of a REACH-like\n  experiment detecting the 21-cm global signal by applying it to many\n  data sets generated from the noisy-signal model. It then plots this result\n  for fixed astrophysical parameters as in Figure 1 of the letter. This is\n  done for detection significance thresholds of 2, 3 and 5 sigma. Selected\n  numerical values are also output to a .txt file. It should be run last.\n\n\nAll three scripts have docstrings describing their role in more detail, as\nwell as giving advice on how to run them most efficiently. The\nscripts can be run from the terminal using the following commands:\n\n.. code:: bash\n\n    python verification_with_polychord.py 0\n    python train_evidence_network.py\n    python visualize_forecasts.py\n\nto run with the default noise level of 15 mK and replicate the\nanalysis from `Gessey-Jones et al. (2024) \u003chttps://ui.adsabs.harvard.edu/abs/2024PhRvD.109l3541G/abstract\u003e`__.\nAlternatively you can pass\nthe scripts a command line argument to specify the experiments noise level in K. For example\nto run with a noise level of 100 mK you would run the following commands:\n\n.. code:: bash\n\n    python verification_with_polychord.py 0 0.1\n    python train_evidence_network.py 0.1\n    python visualize_forecasts.py 0.1\n\nTwo other files of interest are:\n\n- fbf_utilities.py: which defines IO functions\n  needed by the three scripts, utility functions to assemble the data\n  simulators for the noise-only and noisy-signal model, and standard\n  whitening transforms.\n- configuration.yaml: which defines several parameters used in the code\n  including the experimental frequency resolution, the priors on the\n  astrophysical and foreground parameters, and the astrophysical parameters\n  which are plotted in the forecast figures. If you change the priors or\n  resolution the entire pipeline needs to be rerun to get accurate results.\n\nThe various figures produced in the analysis are stored in the\nfigures_and_results directory alongside the timing_data to assess the\nperformance of the methodology and some summary statistics of the evidence\nnetworks performance. The figures and data generated in the\nanalysis for `Gessey-Jones et al. (2024) \u003chttps://ui.adsabs.harvard.edu/abs/2024PhRvD.109l3541G/abstract\u003e`__ are provided in this\nrepository for reference, alongside the figures generated for an earlier\nversion of the letter which did not model foregrounds.\n\nLicence and Citation\n--------------------\n\nThe software is free to use on the MIT open source license.\nIf you use the software for academic purposes then we request that you cite\nthe `letter \u003chttps://ui.adsabs.harvard.edu/abs/2024PhRvD.109l3541G/abstract\u003e`__ ::\n\n  Gessey-Jones, T. and W. J. Handley. “Fully Bayesian forecasts with evidence \n  networks.” (June 2024). Physical Review D, Volume 109, Issue 12, 123541\n\nIf you are using Bibtex you can use the following to cite the letter\n\n.. code:: bibtex\n\n  @ARTICLE{2024PhRvD.109l3541G,\n       author = {{Gessey-Jones}, T. and {Handley}, W.~J.},\n        title = \"{Fully Bayesian forecasts with evidence networks}\",\n      journal = {\\prd},\n         year = 2024,\n        month = jun,\n       volume = {109},\n       number = {12},\n          eid = {123541},\n        pages = {123541},\n          doi = {10.1103/PhysRevD.109.123541},\n       adsurl = {https://ui.adsabs.harvard.edu/abs/2024PhRvD.109l3541G},\n      adsnote = {Provided by the SAO/NASA Astrophysics Data System}}\n\n\nNote some of the packages used (see below) in this code have their own licenses that\nrequire citation when used for academic purposes (e.g. `globalemu \u003chttps://github.com/htjb/globalemu\u003e`__ and\n`pypolychord \u003chttps://github.com/PolyChord/PolyChordLite\u003e`__). Please check the licenses of these packages for more details.\n\n\nRequirements\n------------\n\nTo run the code you will need to following additional packages:\n\n- `globalemu \u003chttps://pypi.org/project/globalemu/\u003e`__\n- `tensorflow \u003chttps://pypi.org/project/tensorflow/\u003e`__\n- `numpy \u003chttps://pypi.org/project/numpy/\u003e`__\n- `keras \u003chttps://pypi.org/project/keras/\u003e`__\n- `matplotlib \u003chttps://pypi.org/project/matplotlib/\u003e`__\n- `nvidia-cudnn-cu11 \u003chttps://pypi.org/project/nvidia-cudnn-cu11/\u003e`__\n- `pandas \u003chttps://pypi.org/project/pandas/\u003e`__\n- `PyYAML \u003chttps://pypi.org/project/PyYAML/\u003e`__\n- `pypolychord \u003chttps://github.com/PolyChord/PolyChordLite\u003e`__\n- `scipy \u003chttps://pypi.org/project/scipy/\u003e`__\n- `mpi4py \u003chttps://pypi.org/project/mpi4py/\u003e`__\n- `scikit-learn \u003chttps://pypi.org/project/scikit-learn/\u003e`__\n- `anesthetic \u003chttps://pypi.org/project/anesthetic/\u003e`__\n\nThe code was developed using python 3.8. It has not been tested on other versions\nof python. Exact versions of the packages used in our analysis\ncan be found in the\n`requirements.txt \u003chttps://github.com/ThomasGesseyJones/FullyBayesianForecastsExample/blob/main/requirements.txt\u003e`__ file\nfor reproducibility.\n\nAdditional packages that were used for linting, versioning, and pre-commit hooks\nare also listed in the requirements.txt file.\n\nIssues and Questions\n--------------------\n\nIf you have any issues or questions about the code please raise an\n`issue \u003chttps://github.com/ThomasGesseyJones/FullyBayesianForecastsExample/issues\u003e`__\non the github page.\n\nAlternatively you can contact the author directly at\n`tg400@cam.ac.uk \u003cmailto:tg400@cam.ac.uk\u003e`__.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasgesseyjones%2Ffullybayesianforecastsexample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasgesseyjones%2Ffullybayesianforecastsexample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasgesseyjones%2Ffullybayesianforecastsexample/lists"}