Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

3
  • $\begingroup$ Very good answer. What I wanted to propose are probability generating functions. In this case for $X_i$: $g_i(s) = E[s^{X_i}] = (1-p_i) + p_is$ and the generating function of the sum is $g(s) = \prod_{i=1}^n g_i(s)$. Taking the nth derivative wrt $s$ evaluated at $0$ gives all the point probabilites. Finally sum them up for the cdf. I just can not offer code for this, so your answer can be readily applied. $\endgroup$ Commented Feb 7, 2013 at 8:50
  • $\begingroup$ @Richard The pgf approach works just fine--in fact, I used that method (in Mathematica, where it's a one-liner) to verify my example here. But under the hood, the product is carried out as a convolution, so it amounts to the same solution. BTW, there's no need to take a derivative: you only need to expand the product as a polynomial in $s$ and pick out the probabilities from the coefficients. $\endgroup$ Commented Feb 7, 2013 at 16:38
  • $\begingroup$ yes, of course the derivatives are just there to extract the coefficients. And yes - in R, it has to be the way you presented it. I just thought I write down the pgf approach for its mathematical beauty ;) $\endgroup$ Commented Feb 7, 2013 at 17:05