title: How to decompose efficiently dpoibin into its summands in R?
body: <p>The Poisson-Binomial distribution concerns the probability of the number of successes in a sequence of independent Bernoulli trials with different probabilities of success. This is a generalization of the Binomial distribution. </p>
  
  <p>With the command <code>dpoibin</code>, in the <code>poibin</code> package, one can obtain the mass probability function. For instance, with this command:</p>
  
  <pre><code>library(poibin)
  n &lt;- 100
  Probs_Success &lt;- runif(n)
  dpoibin(kk = 30, pp = Probs_Success)
  </code></pre>
  
  <p>one can obtain the probability of getting 30 successes in a sequence of 100 independent Bernoulli trials with probabilities of success contained in the vector <code>Probs_Success</code>. To compute this probability one has to sum the probabilities of all possible sequences of lenght 100 where there are 30 successes and 70 failures. </p>
  
  <p><strong>Question:</strong> How can I efficiently obtain all of the summands that generate the above probability in R? Thanks a lot for your help.</p>
  
  <p>For those who are interested in the problem that motivated this question, please click on the following link:</p>
  
  <p><a href="https://math.stackexchange.com/questions/2924831/bivariate-poisson-binomial-distribution">https://math.stackexchange.com/questions/2924831/bivariate-poisson-binomial-distribution</a></p>