[R] Drawing from an empirical distribution
Albyn Jones
jones at reed.edu
Tue Jan 6 23:55:54 CET 2009
the empirical distribution gives probability 1/n to each of n observations.
rather than sampling the unit interval, just resample the dataset.
If x is your dataset, and you want an independent sample of size k,
sample(x,size=k,replace=TRUE)
albyn
On Tue, Jan 06, 2009 at 02:39:17PM -0800, culpritNr1 wrote:
>
> Hi All,
>
> Does anybody know if there is a simple way to draw numbers from an empirical
> distribution?
>
> I know that I can plot the empirical cumulative distribution function this
> easy:
> plot(ecdf(x))
>
> Now I want to pick a number between 0 and 1 and go back to domain of x.
> Sounds simple to me.
>
> Any suggestion?
>
> Thank you,
>
> Your culprit
> (everybody needs a culprit)
>
>
> --
> View this message in context: http://www.nabble.com/Drawing-from-an-empirical-distribution-tp21320810p21320810.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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.
>
More information about the R-help
mailing list