[R] Sum of binominal distributed random numbers

Rainer M Krug Rainer+R-help at krugs.de
Tue Oct 23 11:02:46 CEST 2007


Hi

I have two vectors, prob and size, and I want to add the random deviates 
  of these two, i.e.

sum(
   sapply(
          1:length(prob),
          function(n){ rbinom(1, size(n), prob(n) }
         )
)

My problem is that I have to do this for a large number of value 
combinations. Is there a faster way of doing this?

Rainer



More information about the R-help mailing list