Re: [R] using R to draw over a distribution.

From: David Winsemius <dwinsemius_at_comcast.net>
Date: Mon, 14 Jun 2010 11:00:05 -0400

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_at_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.
Received on Mon 14 Jun 2010 - 15:02:48 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 14 Jun 2010 - 15:30:29 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive