This is a fork from the original project by @tsakim This version adds these Features:
- Adds
mean
,var
,std
,skew
,amax
andargmax
methods - Solves FFT instability issues, as proposed here by @zeeshansayyed
The module contains a Python implementation of functions related to the Poisson Binomial probability distribution [1], which describes the probability distribution of the sum of independent Bernoulli random variables with non-uniform success probabilities. For further information, see reference [1].
The implemented methods are:
pmf
: probability mass functioncdf
: cumulative distribution functionpval
: p-value for right tailed testsmean
: mean of the distributionvar
: variance of the distributionstd
: standard deviation of the distributionskew
: skewness of the distributionamax
: max value of the probability mass functionargmax
: index of the max value of the probability mass function
Mika Straka, Maxi Marufo, Zeeshan Sayyed
Consider n
independent and non-identically distributed random variables and
be p
a list/NumPy array of the corresponding Bernoulli success probabilities.
In order to create the Poisson Binomial distributions, use
from poibin import PoiBin
pb = PoiBin(p)
- Mean
pb.mean()
- Variance
pb.var()
- Standard Deviation
pb.std()
- Skewness
pb.skew()
- Max value
pb.amax()
- Index of the max value
pb.argmax()
Be x
a list/NumPy array of different numbers of success. Use the following
methods to obtain the corresponding quantities:
- Probability mass function
pb.pmf(x)
- Cumulative distribution function
pb.cdf(x)
- P-values for right tailed tests
pb.pval(x)
All three methods accept single integers as well as lists/NumPy arrays of
integers. Note that x[i]
must be smaller than len(p)
.
The methods have been implemented using the pytest
module. To run the tests, execute
$ pytest test_poibin.py
in the command line. For verbose mode, use
$ pytest -v test_poibin.py
Copyright (c) 2016-2020 Mika J. Straka, Maxi Marufo, Zeeshan Sayyed