Package: bernmix
BernMixComputation of PMF and CDF for a weighted sum of dependent and independent ni.d. Bernoulli random variablesAbbreviationsBRV - Bernoulli Random variablePMF -  Probability mass functionCDF - Cumulative distribution functionni.d. - independent non-identically distributedDescriptionThe 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 methodspmf_int- computation of the PMF for ainteger-weightedsum of BRVs by the FFT-based} methodpmf_int_conv- computation of the PMF for ainteger-weightedsum of BRVs by theconvolutionmethodpmf_int_bf- computation of the PMF for a integer-weighted sum of BRVs by the brute-force searchpmf_int_dep- computation of the PMF for a integer-weighted sum ofdependent BRVsby the convolution methodpmf_int_joint- computation of thejointPMF for integer-weighted sums of BRVspmf_int_prod- computation of the PMF for theproductof two integer-weighted sums of BRVscdf_int- computation of the CDF for a integer-weighted sum of BRVs by the FFT-based methodcdf_double- computation of the pointwise corrected CDF for a weighted sum of BRVs withreal weightsby the FFT-based methodcdf_permut- computation of the CDF for a weighted sum of BRVs by the permutationThere 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.RequirementsTo run BernMix methods you need Python 3.4 or later. A list of required Python packages that the BernMix depends on, are inrequirements.txt.The BernMix also required theFFTW3library (a C library for computing the discrete Fourier transform) and Cython.InstallationBernMix can be installed via PyPi:pip install bernmixor by the following commands:git clone https://github.com/iganna/bernmix.git
cd bernmix
python setup.py sdist bdist_wheel
cd dist
pip install *.whlRunning the testsTo demonstrate the use of methods we created a Python notebooktests/bernmix_demo.ipynb.All tests that were used in the below article, are presented in a Python notebooktests/bernmix_test.ipynband in a R notebooktests/gpb_test.ipynbReferencesThe mathematical inference of the algorithm implemented in the BernMix package is described in A.A.Igolkina,On distributions of weighted sums of binary random variablesAuthorsAnna Igolkinadeveloped the BernMix package,e-mail.Max Kovalevcontributed inbernmix_int/bernmix_fourier.c.License informationThe BernMix package is open-sourced software licensed under theMIT license.