For some reason, the while-loop I sent did not work. It was running forever
although I don't know why. Anyway, using repeat works fast:

repeat{x=rpois(50,2)
      if(sum(x)==100) break
      } 


-------------------------
cuncta stricte discussurus
-------------------------

-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Im
Auftrag von Shubha Vishwanath Karanth
Gesendet: Tuesday, July 08, 2008 1:59 AM
An: [EMAIL PROTECTED]
Betreff: [R] Sum(Random Numbers)=100

Hi R,

 

I need to generate 50 random numbers (preferably poisson), such that their
sum is equal to 100. How do I do this?

 

 

Thank you,

Shubha

 

This e-mail may contain confidential and/or privileged i...{{dropped:13}}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to