Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

ABCpy Documentation Status Build Status codecov DOI GitHub license PyPI version PyPI pyversions Binder

ABCpy is a scientific library written in Python for Bayesian uncertainty quantification in absence of likelihood function, which parallelizes existing approximate Bayesian computation (ABC) algorithms and other likelihood-free inference schemes.


ABCpy presently includes the following ABC algorithms:

The above can be used with the following distances:

Moreover, we provide the following methods for directly approximating the likelihood functions:

The above likelihood approximation methods can be used with the following samplers:

Additional features are:

ABCpy addresses the needs of domain scientists and data scientists by providing

  • a fully modularized framework that is easy to use and easy to extend,
  • a quick way to integrate your generative model into the framework (from C++, R etc.) and
  • a non-intrusive, user-friendly way to parallelize inference computations (for your laptop to clusters, supercomputers and AWS)
  • an intuitive way to perform inference on hierarchical models or more generally on Bayesian networks


For more information, check out the

Further, we provide a collection of models for which ABCpy has been applied successfully. This is a good place to look at more complicated inference setups.

Quick installation and requirements

ABCpy can be installed from pip:

pip install abcpy

Check here for more details.

Basic requirements are listed in requirements.txt. That also includes packages required for MPI parallelization there, which is very often used. However, we also provide support for parallelization with Apache Spark (see below).

Additional packages are required for additional features:

  • torch is needed in order to use neural networks to learn summary statistics. It can be installed by running pip install -r requirements/neural_networks_requirements.txt
  • In order to use Apache Spark for parallelization, findspark and pyspark are required; install them by pip install -r requirements/backend-spark.txt

Troubleshooting mpi4py installation

mpi4py requires a working MPI implementation to be installed; check the official docs for more info. On Ubuntu, that can be installed with:

sudo apt-get install libopenmpi-dev

Even when that is present, running pip install mpi4py can sometimes lead to errors. In fact, as specified in the official docs, the mpicc compiler needs to be in the search path. If that is not the case, a workaround is:

env MPICC=/path/to/mpicc pip install mpi4py

In some cases, even the above may not be enough. A possibility is using conda (conda install mpi4py) which usually handles package dependencies better than pip. Alternatively, you can try by installing directly mpi4py from the package manager; in Ubuntu, you can do:

sudo apt install python3-mpi4py 

which however does not work with virtual environments.


ABCpy was written by Ritabrata Dutta, Warwick University and Marcel Schoengens, CSCS, ETH Zurich, and presently actively maintained by Lorenzo Pacchiardi, Oxford University and Ritabrata Dutta, Warwick University. Please feel free to submit any bugs or feature requests. We'd also love to hear about your experiences with ABCpy in general. Drop us an email!

We want to thank Prof. Antonietta Mira, Università della svizzera italiana, and Prof. Jukka-Pekka Onnela, Harvard University for helpful contributions and advice; Avinash Ummadisinghu and Nicole Widmern respectively for developing dynamic-MPI backend and making ABCpy suitable for hierarchical models; and finally CSCS (Swiss National Super Computing Center) for their generous support.


There is a paper in the Journal of Statistical Software. In case you use ABCpy for your publication, we would appreciate a citation. You can use this BibTex reference.

Other References

Publications in which ABCpy was applied:

  • L. Pacchiardi, R. Dutta. "Generalized Bayesian Likelihood-Free Inference Using Scoring Rules Estimators", 2021, arXiv:2104.03889.

  • L. Pacchiardi, R. Dutta. "Score Matched Conditional Exponential Families for Likelihood-Free Inference", 2022, Journal of Machine Learning Research 23(38):1−71.

  • R. Dutta, K. Zouaoui-Boudjeltia, C. Kotsalos, A. Rousseau, D. Ribeiro de Sousa, J. M. Desmet, A. Van Meerhaeghe, A. Mira, and B. Chopard. "Interpretable pathological test for Cardio-vascular disease: Approximate Bayesian computation with distance learning.", 2020, arXiv:2010.06465.

  • R. Dutta, S. Gomes, D. Kalise, L. Pacchiardi. "Using mobility data in the design of optimal lockdown strategies for the COVID-19 pandemic in England.", 2021, PLOS Computational Biology, 17(8), e1009236.

  • L. Pacchiardi, P. Künzli, M. Schöngens, B. Chopard, R. Dutta, "Distance-Learning for Approximate Bayesian Computation to Model a Volcanic Eruption", 2021, Sankhya B, 83(1), 288-317.

  • R. Dutta, J. P. Onnela, A. Mira, "Bayesian Inference of Spreading Processes on Networks", 2018, Proceedings of Royal Society A, 474(2215), 20180129.

  • R. Dutta, Z. Faidon Brotzakis and A. Mira, "Bayesian Calibration of Force-fields from Experimental Data: TIP4P Water", 2018, Journal of Chemical Physics 149, 154110.

  • R. Dutta, B. Chopard, J. Lätt, F. Dubois, K. Zouaoui Boudjeltia and A. Mira, "Parameter Estimation of Platelets Deposition: Approximate Bayesian Computation with High Performance Computing", 2018, Frontiers in physiology, 9.

  • A. Ebert, R. Dutta, K. Mengersen, A. Mira, F. Ruggeri and P. Wu, "Likelihood-free parameter estimation for dynamic queueing networks: case study of passenger flow in an international airport terminal", 2021, Journal of Royal Statistical Society: Series C (Applied Statistics) 70.3: 770-792.


ABCpy is published under the BSD 3-clause license, see here.


You are very welcome to contribute to ABCpy.

If you want to contribute code, there are a few things to consider: