Open-source · Python · MIT licensed
Bayesian inference made simple.
bilby is a user-friendly Bayesian inference library for Python. Define a likelihood and priors, pick any of a dozen samplers, and get posteriors and evidences back, from fitting a straight line to measuring the masses of merging black holes.
pip install bilby
import bilby
likelihood = bilby.likelihood.GaussianLikelihood(
x, y, model, sigma
)
priors = dict(
m=bilby.prior.Uniform(0, 5, "m"),
c=bilby.prior.Uniform(-5, 5, "c"),
)
result = bilby.run_sampler(
likelihood, priors, sampler="dynesty"
)
result.plot_corner()
Why bilby?
Any sampler, one interface
Switch between dynesty, emcee, bilby-mcmc, nessai, ultranest, PyMC and more by changing one keyword. Sampler plugins let anyone add their own.
Gravitational-wave ready
bilby.gw provides waveforms, detector networks, calibration and marginalised likelihoods. It underpins inference for LIGO-Virgo-KAGRA catalogues.
Priors that make sense
A rich library of priors, including conditional, joint and constrained distributions, that you combine with plain Python.
Results you can share
Corner plots, evidences, and portable result files in HDF5 or JSON, ready for hierarchical and population analyses with bilby.hyper.
Try bilby in your browser
Edit the code and press Run. Python and bilby run locally in your browser with Pyodide, with nothing to install.
Press Run (or Ctrl/⌘+Enter) to sample in your browser with Pyodide. Nothing is installed on your computer.
Runs on one CPU core in your browser. For more examples, including gravitational-wave analyses, open the full examples site.
Bring your favourite sampler
Every sampler sees the same likelihood and priors, so comparing samplers means changing one argument. New samplers plug in through Python entry points.
See the samplers- dynestynested
- bilby-mcmcMCMC
- emceeMCMC
- nessainested + flows
- ultranestnested
- PyMCHMC
- zeusensemble slice
- ptemceeparallel tempering
- PolyChordnested
- MultiNestnested
- nestlenested
- DNest4diffusive nested
The bilby ecosystem
bilby is the core of a family of packages for pipelines, population studies and astrophysical transients.
-
Gravitational waves
bilby_pipe
Configure and run bilby gravitational-wave analyses on a computing cluster from a single ini file.
Source -
Gravitational waves
parallel_bilby
Run bilby gravitational-wave analyses across many CPUs with MPI.
Source -
Gravitational waves
bilby_tgr
Tests of general relativity with bilby.
Source -
Populations
gwpopulation
Hierarchical population inference for gravitational-wave catalogues, built on bilby.
Source -
Transients
redback
Bayesian inference and modelling of electromagnetic transients, built on bilby.
Source -
Results
PESummary
Summary pages and plots for parameter-estimation results, including bilby's.
Source
Using bilby in your package? Let us know and we'll add it here. Tell us about it
News
Feed-
Welcome to the new bilby homepage
bilby now has a home of its own at bilby-dev.github.io, with links to the documentation, the in-browser examples and project news.
-
Run the bilby examples in your browser
The bilby examples now run entirely in your browser with Pyodide, with no installation needed. Pick an example, edit it, and sample.
-
bilby 2.8.2 released
bilby 2.8.2 is out. Upgrade with
pip install -U bilbyor from conda-forge. Read the release notes. -
bilby 2.8.1 released
bilby 2.8.1 is out. Upgrade with
pip install -U bilbyor from conda-forge. Read the release notes.
Citing bilby
If bilby contributes to your research, please cite the papers below.
-
BILBY: A user-friendly Bayesian inference library for gravitational-wave astronomy
BibTeX
@article{Ashton_2019, title = {Bilby: A User-friendly Bayesian Inference Library for Gravitational-wave Astronomy}, volume = {241}, ISSN = {1538-4365}, url = {http://dx.doi.org/10.3847/1538-4365/ab06fc}, DOI = {10.3847/1538-4365/ab06fc}, number = {2}, journal = {The Astrophysical Journal Supplement Series}, publisher = {American Astronomical Society}, author = {Ashton, Gregory and Hübner, Moritz and Lasky, Paul D. and Talbot, Colm and Ackley, Kendall and Biscoveanu, Sylvia and Chu, Qi and Divakarla, Atul and Easter, Paul J. and Goncharov, Boris and Vivanco, Francisco Hernandez and Harms, Jan and Lower, Marcus E. and Meadors, Grant D. and Melchor, Denyz and Payne, Ethan and Pitkin, Matthew D. and Powell, Jade and Sarin, Nikhil and Smith, Rory J. E. and Thrane, Eric}, year = {2019}, month = Apr, pages = {27} } -
BibTeX
@article{Romero_Shaw_2020, title = {Bayesian inference for compact binary coalescences with <scp>bilby</scp> : validation and application to the first LIGO–Virgo gravitational-wave transient catalogue}, volume = {499}, ISSN = {1365-2966}, url = {http://dx.doi.org/10.1093/mnras/staa2850}, DOI = {10.1093/mnras/staa2850}, number = {3}, journal = {Monthly Notices of the Royal Astronomical Society}, publisher = {Oxford University Press (OUP)}, author = {Romero-Shaw, I M and Talbot, C and Biscoveanu, S and D’Emilio, V and Ashton, G and Berry, C P L and Coughlin, S and Galaudage, S and Hoy, C and Hübner, M and Phukon, K S and Pitkin, M and Rizzo, M and Sarin, N and Smith, R and Stevenson, S and Vajpeyi, A and Arène, M and Athar, K and Banagiri, S and Bose, N and Carney, M and Chatziioannou, K and Clark, J A and Colleoni, M and Cotesta, R and Edelman, B and Estellés, H and García-Quirós, C and Ghosh, Abhirup and Green, R and Haster, C-J and Husa, S and Keitel, D and Kim, A X and Hernandez-Vivanco, F and Magaña Hernandez, I and Karathanasis, C and Lasky, P D and De Lillo, N and Lower, M E and Macleod, D and Mateu-Lucena, M and Miller, A and Millhouse, M and Morisaki, S and Oh, S H and Ossokine, S and Payne, E and Powell, J and Pratten, G and Pürrer, M and Ramos-Buades, A and Raymond, V and Thrane, E and Veitch, J and Williams, D and Williams, M J and Xiao, L}, year = {2020}, month = Sept, pages = {3295–3319} }