[R] using R to draw over a distribution.
David Winsemius
dwinsemius at comcast.net
Mon Jun 14 17:00:05 CEST 2010
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
More information about the R-help
mailing list