On Jun 14, 2010, at 10:42 AM, SHANE MILLER, BLOOMBERG/ 731 LEXIN wrote:

Hi,

Suppose I analyze a log to create a histogram:

event E1 occurred N1 times
event E2 occurred N2 times
 ...
 ... for m total events
 ...
event Em occurred Nm times

The total number of occurrences is: T = Sum    Nj
                                       j=1..m

I want to give this histogram to R and ask it to produce T random events such that approximately N1 instances of E1 are drawn, N2 instances of E2 drawn, and so forth.

?table # or perhaps use the fact that hist() will return a table of a particular type.
?sample  # from the events with prob = frequencies/T

(If you insist on constraining the total count to be the observed sum it will no longer be random with m degrees of freedom. And there are many postings on how to do this in the archives.)

--

David Winsemius, MD
West Hartford, CT

______________________________________________
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