[R] Sum(Random Numbers)=100

Carl Witthoft carl at witthoft.com
Tue Jul 8 23:40:23 CEST 2008


quote: In the present case use rmultinom(1, 100, rep(1/50,50))

At least in my version,  rmultinom normalizes the last argument,
so rep(1,50) works just as well.

Back to the original problem:  either assign 49 randoms and give the 
remainder to the 50th slot, or do the right thing :-) :

You have 50 outcomes, so simply draw  numbers from the uniform 
distribution over the range 1:50.  Keep drawing until you've assigned a 
number to each of your "dollars" (i.e. each item in your sample set).

Carl



More information about the R-help mailing list