[R] Sum of Bernoullis with varying probabilities
(Ted Harding)
Ted.Harding at nessie.mcc.ac.uk
Sun Oct 8 15:36:47 CEST 2006
On 08-Oct-06 Gabor Grothendieck wrote:
> And here is one minor improvement (rbind() rather than t(cbind()):
>
> p <- 1:4/8
> Re(fft(apply(mvfft(rbind(1-p, p, 0 * p[-1] %o% p)), 1, prod), inverse
> = TRUE) / (length(p) + 1))
Really nice! Much better than any solution I might have found
for myself. It really is worth posting to the list!
This all still leaves me with one nagging question in the back
of my mind -- Surely this is not the first time someone has
tackled the problem (in R) of the distribution of the sum of
Bernoulli RVs with unequal probabilities? R Site Search on
"Bernoulli" did not seem to throw anything up.
(Or maybe they just did it, and didn't think it worth saying
anything about--but it's not really trivial).
Best wishes,
Ted.
--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 08-Oct-06 Time: 14:36:43
------------------------------ XFMail ------------------------------
More information about the R-help
mailing list