{"id":23515127,"url":"https://github.com/htjb/beta-flows","last_synced_at":"2025-04-19T14:53:39.088Z","repository":{"id":248837199,"uuid":"738557957","full_name":"htjb/beta-flows","owner":"htjb","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-07T16:39:36.000Z","size":120010,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T09:01:34.544Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/htjb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2024-01-03T14:00:38.000Z","updated_at":"2025-03-19T22:49:24.000Z","dependencies_parsed_at":"2025-03-07T17:36:07.832Z","dependency_job_id":null,"html_url":"https://github.com/htjb/beta-flows","commit_stats":null,"previous_names":["htjb/beta-flows"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htjb%2Fbeta-flows","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htjb%2Fbeta-flows/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htjb%2Fbeta-flows/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/htjb%2Fbeta-flows/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/htjb","download_url":"https://codeload.github.com/htjb/beta-flows/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249718497,"owners_count":21315083,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-12-25T14:12:59.021Z","updated_at":"2025-04-19T14:53:39.069Z","avatar_url":"https://github.com/htjb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# $\\beta$-flows: Learning with the whole Nested Sampling run\n\n|bflows | Temperature dependent Normalising Flows |\n|---------|-----------|\n|Author | Harry Bevins|\n|Homepage | |\n\nUNDER CONSTRUCTION\n\n$\\beta$-flows are a density estimation tool that were intially designed\nto improve the accuracy of more traditional normalising flows.\n\nThey are built using conditional masked autoregressive flows and utilise the\nthermodynamic description of nested sampling during training. The structure\nof the $\\beta$-flows class and the interface are largely based on\nthe code [margarine](https://github.com/htjb/margarine).\n\nThe nested sampling algorithm is used to perform Bayesian inference and estimate\nthe normalising factor on Bayes theorem known as the evidence\n\n$$\\mathcal{Z} = \\int \\mathcal{L}(\\theta)\\pi(\\theta) d\\theta$$\n\nwhere $\\mathcal{L}(\\theta)$ is the postulated probability, known as the\nlikelihood, of the data given a set of parameters $\\theta$ and $\\pi(\\theta)$\nis the prior on the parameters. In the process of estimating the evidence the\nnested sampling algorithm also returns samples on the posterior \nprobability $P(\\theta) = P(\\theta|D, M)$.\n\nAn analogy can be made between the Bayesian evidence and the partition function\nin statistical mechanics. If one writes the energy of a given state as\n$E(\\theta) = - \\log \\mathcal{L}(\\theta)$ then the partition function can be \nwritten as\n\n$$\\mathcal{Z}(\\beta) = \\int e^{-\\beta E} g(E) dE = \\int \\mathcal{L}(\\theta)^\\beta \\pi(\\theta)\nd\\theta$$\n\nwhere $g(E)$ is the density of states with a given energy and $\\beta$ is an inverse\ntemperature. It can be seen that when $\\beta=1$ we recover the integral over the posterior\nand when $\\beta=0$ the integral is over the prior.\n\nWe can therefore track over the nested sampling algorihtm transforms the prior\ninto the posterior by varying $\\beta$ between 0 and 1. Further we can\ngenerate a set of samples from any distribution between the prior and posterior\nby reweighting the returned posterior points according to\n\n$$p_i^\\beta = \\frac{w_i \\mathcal{L}_i^\\beta} {\\mathcal{Z}(\\beta)}$$\n\nwhere $w_i$ corresponds to the prior volume contraction at each iteration in the\nrun.\n\nIt has been shown that normalising flows can be used to emulate posteriors, priors\nand likelihood functions and that researchers can take advantage of these emulators\nin a number of different ways.\n\nTypically normalising are trained on the $\\beta=1$ posterior distribution or\nthe $\\beta=0$ prior distribution. When learning the posterior researchers often\nfind that the flows perform poorly in the tails of the distribution.\n\nThe inovation behind $\\beta$-flows is to train the flow conditioned on $\\beta$ using \nappropriately weighted samples from a nested sampling run.\n\nThis has been seen to improve the accuracy of emulation of the $\\beta=1$\ndistribution and has many other applications.\n\n## Example\n\n\n\n## Citation\n\nPlease cite this code base if you use Beta-flows in your work and the corresponding\npaper [Accelerated nested sampling with  β -flows for gravitational waves](https://ui.adsabs.harvard.edu/abs/2024arXiv241117663P/abstract).\n\n```bibtex\n@ARTICLE{2024arXiv241117663P,\n       author = {{Prathaban}, Metha and {Bevins}, Harry and {Handley}, Will},\n        title = \"{Accelerated nested sampling with $\\beta$-flows for gravitational waves}\",\n      journal = {arXiv e-prints},\n     keywords = {Astrophysics - Instrumentation and Methods for Astrophysics, Astrophysics - High Energy Astrophysical Phenomena, General Relativity and Quantum Cosmology},\n         year = 2024,\n        month = nov,\n          eid = {arXiv:2411.17663},\n        pages = {arXiv:2411.17663},\narchivePrefix = {arXiv},\n       eprint = {2411.17663},\n primaryClass = {astro-ph.IM},\n       adsurl = {https://ui.adsabs.harvard.edu/abs/2024arXiv241117663P},\n      adsnote = {Provided by the SAO/NASA Astrophysics Data System}\n}\n```\n\n```bibtex\n@article{beta-flows,\n    year  = {2024},\n    author = {Harry Bevins et al},\n    title = {beta-flows: Temperature dependent Normalising Flows},\n    journal = {In preparation}\n}\n```\n\n## Contribution\n\nContributions are welcome. Please open up an issue to discuss.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtjb%2Fbeta-flows","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhtjb%2Fbeta-flows","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhtjb%2Fbeta-flows/lists"}