bayesint: A Python Package for Calculating Bayesian Credible Intervals of Ratios of Beta Distributions

M. Bekker Nielsen Dunbar*, Thomas J.R. Finnie

*Corresponding author for this work

Research output: Contribution to journalArticlepeer-review


We present bayesint, a Python package for calculating Bayesian credible intervals for ratios of two independent beta distributions such as are used when considering binomial data. Such data could be found in counts of events in medical diagnostic tests, case-control studies, and field epidemiological investigations, among other applications. The package contains general functions providing the expression of the density and distribution of the ratio and two functions for calculating the equaltailed and highest posterior density credible intervals. The package is intended for use with 2*2 contingency tables. We introduce bayesint by comparing two groups in a contingency table through calculating the relative risk of cholera, showcasing its use in a novel context.

Original languageEnglish
Article number35
JournalJournal of Open Research Software
Publication statusPublished - 2021

Bibliographical note

Funding Information:
The research leading to these results has received UK government grant-in-aid funding. MBND and TJRF were funded by the National Institute for Health Research—Health Protection Research Unit for Modelling Methodology (HPRU MM). The funding bodies (UK government and HPRU MM) did not play any role in the formulation of this manuscript. The views expressed in this publication are those of the authors and not necessarily those of Public Health England.

Publisher Copyright:
© 2021 The Author(s). All Rights Reserved.


  • Python
  • beta distributions
  • cholera
  • contingency tables
  • credible interval
  • relative risk


Dive into the research topics of 'bayesint: A Python Package for Calculating Bayesian Credible Intervals of Ratios of Beta Distributions'. Together they form a unique fingerprint.

Cite this