Giter Club home page Giter Club logo

bernmix's Introduction

BernMix

Computation of PMF and CDF for a weighted sum of dependent and independent ni.d. Bernoulli random variables

Abbreviations

BRV - Bernoulli Random variable
PMF - Probability mass function
CDF - Cumulative distribution function
ni.d. - independent non-identically distributed

Description

The BernMix package includes two efficient algorithms to calculate the exact distribution of a weighted sum of ni.d. BRV โ€“ the first is for integer weights and the second is for non-integer weights. The discussed distribution includes, as particular cases, Binomial and Poisson Binomial distributions together with their linear combinations.

For integer weights, we present two algorithms to calculate a probability mass function (PMF) and a cumulative distribution function (CDF) of a weighted sum of BRVs: utilising the Discrete Fourier transform and convolution method. For non-integer weights we suggest the heuristic approach to compute a pointwise CDF using rounding and integer linear programming. We also propose the transformation algorithm to estimate the joint distribution of weighted sums of BRVs and suggest the heuristics to estimate PMF and CDF, when BRVs are non-independent. Together with numerical studies we discuss possible application in bioinformatics analysis.

The BernMix package provides Python implementations of all developed algorithms; C++ library for using Fast Fourier transform is wrapped with Cython. Code is available on GitHub and via PyPi.

Implemented methods

  • pmf_int - computation of the PMF for a integer-weighted sum of BRVs by the FFT-based} method
  • pmf_int_conv - computation of the PMF for a integer-weighted sum of BRVs by the convolution method
  • pmf_int_bf - computation of the PMF for a integer-weighted sum of BRVs by the brute-force search
  • pmf_int_dep - computation of the PMF for a integer-weighted sum of dependent BRVs by the convolution method
  • pmf_int_joint - computation of the joint PMF for integer-weighted sums of BRVs
  • pmf_int_prod - computation of the PMF for the product of two integer-weighted sums of BRVs
  • cdf_int - computation of the CDF for a integer-weighted sum of BRVs by the FFT-based method
  • cdf_double - computation of the pointwise corrected CDF for a weighted sum of BRVs with real weights by the FFT-based method
  • cdf_permut - computation of the CDF for a weighted sum of BRVs by the permutation

There are two required parameters in each function: a list of success probabilities for BRVs and a vector of weights. Other parameters have default values but can be set by the user.

Requirements

To run BernMix methods you need Python 3.4 or later. A list of required Python packages that the BernMix depends on, are in requirements.txt.
The BernMix also required the FFTW3 library (a C library for computing the discrete Fourier transform) and Cython.

Installation

BernMix can be installed via PyPi:

pip install bernmix

or by the following commands:

git clone https://github.com/iganna/bernmix.git
cd bernmix
python setup.py sdist bdist_wheel
cd dist
pip install *.whl

Running the tests

To demonstrate the use of methods we created a Python notebook tests/bernmix_demo.ipynb.
All tests that were used in the below article, are presented in a Python notebook tests/bernmix_test.ipynb and in a R notebook tests/gpb_test.ipynb

References

The mathematical inference of the algorithm implemented in the BernMix package is described in A.A.Igolkina, On distributions of weighted sums of binary random variables

Authors

Anna Igolkina developed the BernMix package, e-mail.

Max Kovalev contributed in bernmix_int/bernmix_fourier.c.

License information

The BernMix package is open-sourced software licensed under the MIT license.

bernmix's People

Contributors

iganna avatar

Watchers

James Cloos avatar  avatar

bernmix's Issues

Generalized Poisson-Binomial Distribution?

Thanks for your brilliant library, great to see!

I just wanted to confirm: Does this implement the generalized/weighted/modified Poisson-Binomial distribution i.e. the PDF using a vector of (p_i,w_i), or can it be easily used to do so?

Thanks again and for any and all assistance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.