title: Probability of selecting exactly n elements
body: <p>I have a list of about 100 000 probabilities on an event stored in a vector.</p>
  
  <p>I want to know if it is possible to calculate the probability of n occuring events (e.g. what is the probability that exactly 1000 events occur).</p>
  
  <p>I managed to calculate several probabilities in R :</p>
  
  <ul>
  <li><code>p</code> is the vector containing all the probabilities</li>
  <li>probability of none : <code>prod(1-p)</code></li>
  <li>probability of at least one : <code>1 - prod(1-p)</code></li>
  </ul>
  
  <p>I found how to calculate the probability of exactly one event : </p>
  
  <pre><code>sum(p * (prod(1-p) / (1-p)))
  </code></pre>
  
  <p>But I don't know how to generate a formula for n events.</p>