Skip to main content

Methods to compute PMF and CDF values of a weighted sum of i.ni.d. BRVs

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bernmix-1.11.45.tar.gz (36.6 kB view details)

Uploaded Source

File details

Details for the file bernmix-1.11.45.tar.gz.

File metadata

  • Download URL: bernmix-1.11.45.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for bernmix-1.11.45.tar.gz
Algorithm Hash digest
SHA256 d0c4c4bbe879f9eaae1666ff170e30b88e36738b3430139b33e9c8027a152c8b
MD5 9483503a064488ac45095511a3da5be8
BLAKE2b-256 7375a66ac3c2e56894273d65bd15851fe099a134d54754792fb10dbf4a5602d6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page