Poisson binomial distribution

In probability theory and statistics, the Poisson binomial distribution is the discrete probability distribution of a sum of independent Bernoulli trials that are not necessarily identically distributed. The concept is named after Siméon Denis Poisson.

In other words, it is the probability distribution of the number of successes in a collection of n independent yes/no experiments with success probabilities $$p_1, p_2, \dots, p_n$$. The ordinary binomial distribution is a special case of the Poisson binomial distribution, when all success probabilities are the same, that is $$p_1 = p_2 = \cdots = p_n$$.

Probability Mass Function
The probability of having k successful trials out of a total of n can be written as the sum


 * $$\Pr(K=k) = \sum\limits_{A\in F_k} \prod\limits_{i\in A} p_i \prod\limits_{j\in A^c} (1-p_j) $$

where $$F_k$$ is the set of all subsets of k integers that can be selected from $$\{1,2,3,...,n\}$$. For example, if n = 3, then $$F_2=\left\{ \{1,2\},\{1,3\},\{2,3\} \right\}$$. $$A^c$$ is the complement of $$A$$, i.e. $$A^c =\{1,2,3,\dots,n\}\setminus A$$.

$$F_k$$ will contain $$n!/((n-k)!k!)$$ elements, the sum over which is infeasible to compute in practice unless the number of trials n is small (e.g. if n = 30, $$F_{15}$$ contains over 1020 elements). However, there are other, more efficient ways to calculate $$\Pr(K=k)$$.

As long as none of the success probabilities are equal to one, one can calculate the probability of k successes using the recursive formula


 * $$\Pr (K=k)= \begin{cases}

\prod\limits_{i=1}^n (1-p_i) & k=0 \\ \frac{1}{k} \sum\limits_{i=1}^k (-1)^{i-1}\Pr (K=k-i)T(i) & k>0 \\ \end{cases}$$

where


 * $$ T(i)=\sum\limits_{j=1}^n \left( \frac{p_j}{1-p_j} \right)^i.$$

The recursive formula is not numerically stable, and should be avoided if $$n$$ is greater than approximately 20.

An alternative is to use a divide-and-conquer algorithm: if we assume $$n = 2^b$$ is a power of two, denoting by $$f(p_{i:j})$$ the Poisson binomial of $$p_i, \dots, p_j$$ and $$*$$ the convolution operator, we have $$f(p_{1:2^b}) = f(p_{1:2^{b-1}})*f(p_{2^{b-1}+1:2^b})$$.

More generally, the probability mass function of a Poisson binomial can be expressed as the convolution of the vectors $$P_0, \dots, P_n$$ where $$P_i=[1-p_i,p_i]$$. This observation leads to the Direct Convolution (DC) algorithm for computing $$\Pr (K=0) $$ through $$\Pr (K=n) $$: // PMF and nextPMF begin at index 0 function DC($$p_1, \dots, p_n$$) is declare new PMF array of size 1 PMF[0] = [1] for i = 1 to $$n$$ do declare new nextPMF array of size i + 1 nextPMF[0] = (1 - $$p_i$$) * PMF[0] nextPMF[i] = $$p_i$$ * PMF[i - 1] for k = 1 to i - 1 do nextPMF[k] = $$p_i$$ * PMF[k - 1] + (1 - $$p_i$$) * PMF[k] repeat PMF = nextPMF repeat return PMF end function $$\Pr (K=k) $$will be found in PMF[k]. DC is numerically stable, exact, and, when implemented as a software routine, exceptionally fast for $$n \leq 2000 $$. It can also be quite fast for larger $$n $$, depending on the distribution of the $$p_i $$.

Another possibility is using the discrete Fourier transform.


 * $$\Pr (K=k)=\frac{1}{n+1} \sum\limits_{l=0}^n C^{-lk} \prod\limits_{m=1}^n \left( 1+(C^l-1) p_m \right) $$

where $$C=\exp \left( \frac{2i\pi }{n+1} \right)$$ and $$i=\sqrt{-1}$$.

Still other methods are described in "Statistical Applications of the Poisson-Binomial and conditional Bernoulli distributions" by Chen and Liu and in "A simple and fast method for computing the Poisson binomial distribution function" by Biscarri et al.

Cumulative distribution function
The cumulative distribution function (CDF) can be expressed as:

$$\Pr(K \leq k) = \sum^{k}_{l=0} \sum\limits_{A\in F_l} \prod\limits_{i\in A} p_i \prod\limits_{j\in A^c} (1-p_j)$$ ,

where $$F_l$$ is the set of all subsets of size $$l$$ that can be selected from $$\{1,2,3,...,n\}$$.

It can be computed by invoking the DC function above, and then adding elements $$0$$ through $$k$$ of the returned PMF array.

Mean and Variance
Since a Poisson binomial distributed variable is a sum of n independent Bernoulli distributed variables, its mean and variance will simply be sums of the mean and variance of the n Bernoulli distributions:


 * $$\mu = \sum\limits_{i=1}^n p_i$$


 * $$\sigma^2 =\sum\limits_{i=1}^n (1-p_i) p_i$$

Entropy
There is no simple formula for the entropy of a Poisson binomial distribution, but the entropy is bounded above by the entropy of a binomial distribution with the same number parameter and the same mean. Therefore, the entropy is also bounded above by the entropy of a Poisson distribution with the same mean.

The Shepp–Olkin concavity conjecture, due to Lawrence Shepp and Ingram Olkin in 1981, states that the entropy of a Poisson binomial distribution is a concave function of the success probabilities $$p_1, p_2, \dots, p_n$$. This conjecture was proved by Erwan Hillion and Oliver Johnson in 2015. The Shepp–Olkin monotonicity conjecture, also from the same 1981 paper, is that the entropy is monotone increasing in $$p_i$$, if all $$p_i \leq 1/2$$. This conjecture was also proved by Hillion and Johnson, in 2019.

Chernoff bound
The probability that a Poisson binomial distribution gets large, can be bounded using its moment generating function as follows (valid when $$s \geq \mu$$ and for any $$t>0$$):



\begin{align} \Pr[S\ge s] &\le \exp(-st)\operatorname E\left[\exp\left[t \sum_i X_i\right]\right] \\&= \exp(-st)\prod_i (1-p_i+e^t p_i) \\&= \exp\left(-st + \sum_i \log\left( p_i (e^t - 1) + 1\right)\right) \\&\le \exp\left(-st + \sum_i \log\left( \exp(p_i(e^t-1))\right)\right) \\&= \exp\left(-st + \sum_i p_i(e^t-1)\right) \\&= \exp\left(s-\mu-s\log\frac{s}{\mu}\right), \end{align} $$

where we took $t=\log\left(s/\mu\right)$. This is similar to the tail bounds of a binomial distribution.

Approximation by Binomial Distribution
A Poisson binomial distribution $$PB$$ can be approximated by a binomial distribution $$B$$ where $$\mu$$, the mean of the $$p_i$$, is the success probability of $$B$$. The variances of $$PB$$ and $$B$$ are related by the formula

$$Var(PB)=Var(B)-\textstyle \sum_{i=1}^n \displaystyle(p_i-\mu)^2$$

As can be seen, the closer the $$p_i$$ are to $$\mu$$, that is, the more the $$p_i$$ tend to homogeneity, the larger $$PB$$'s variance. When all the $$p_i$$are equal to $$\mu$$, $$PB$$ becomes $$B$$, $$Var(PB)=Var(B)$$, and the variance is at its maximum.

Ehm has determined bounds for the total variation distance of $$PB$$ and $$B$$, in effect providing bounds on the error introduced when approximating $$PB$$ with $$B$$. Let $$\nu = 1 - \mu$$ and $$d(PB,B)$$ be the total variation distance of $$PB$$ and $$B$$. Then

$$d(PB,B)\le(1-\mu^{n+1}-\nu^{n+1}) \frac{\sum_{i=1}^n \displaystyle(p_i-\mu)^2}{((n+1)\mu\nu)}$$

$$d(PB,B)\ge C\min(1,\frac{1}{n\mu\nu})\textstyle \sum_{i=1}^n \displaystyle(p_i-\mu)^2$$

where $$C\ge\frac{1}{124}$$.

$$d(PB,B)$$ tends to 0 if and only if $$Var(PB)/Var(B)$$ tends to 1.

Approximation by Poisson Distribution
A Poisson binomial distribution $$PB$$ can also be approximated by a Poisson distribution $$Po$$ with mean $$\lambda=\sum_{i=1}^n \displaystyle p_i $$. Barbour and Hall have shown that

$$\frac{1}{32}\min(\frac{1}{\lambda},1)\textstyle \sum_{i=1}^n \displaystyle p_i^2\le d(PB, Po)\le\frac{1-\epsilon^{-\lambda}}{\lambda}\sum_{i=1}^n \displaystyle p_i^2$$

where $$d(PB,B)$$ is the total variation distance of $$PB$$ and $$Po$$. It can be seen that the smaller the $$p_i$$, the better $$Po$$ approximates $$PB$$.

As $$Var(Po)=\lambda=\sum_{i=1}^n \displaystyle p_i $$ and $$Var(PB) =\sum\limits_{i=1}^n p_i-\sum\limits_{i=1}^n p_i^2$$, $$Var(Po)>Var(PB) $$; so a Poisson binomial distribution's variance is bounded above by a Poisson distribution with $$\lambda=\sum_{i=1}^n \displaystyle p_i $$, and the smaller the $$p_i$$, the closer $$Var(Po) $$ will be to $$Var(PB) $$.

Computational methods
The reference discusses techniques of evaluating the probability mass function of the Poisson binomial distribution. The following software implementations are based on it:
 * An R package poibin was provided along with the paper, which is available for the computing of the cdf, pmf, quantile function, and random number generation of the Poisson binomial distribution. For computing the PMF, a DFT algorithm or a recursive algorithm can be specified to compute the exact PMF, and approximation methods using the normal and Poisson distribution can also be specified.
 * poibin - Python implementation - can compute the PMF and CDF, uses the DFT method described in the paper for doing so.