Richard Pearson wrote:
Shubha
Does table(ceiling(runif(100,0,50))) give you something like you want?
That's a neat(-ish) solution of Moshe's multinomial formulation.
More generally, if p is a vector of probabilities you can simulate
independent indicators with cut(runif(N), c(0,cumsum(p)) and then
multinomials by tabulation.
However, it is inefficient for large N, and awkward if you want
replicates, which is why we have rmultinom(). In the present case use
rmultinom(1, 100, rep(1/50,50))
--
O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907
______________________________________________
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.