[R] how to generate a random data from a empirical distribition

Nordlund, Dan (DSHS/RDA) NordlDJ at dshs.wa.gov
Tue Jul 27 01:18:06 CEST 2010


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of xin wei
> Sent: Monday, July 26, 2010 11:36 AM
> To: r-help at r-project.org
> Subject: [R] how to generate a random data from a empirical
> distribition
> 
> 
> hi, this is more a statistical question than a R question. but I do
> want to
> know how to implement this in R.
> I have 10,000 data points. Is there any way to generate a empirical
> probablity distribution from it (the problem is that I do not know what
> exactly this distribution follows, normal, beta?). My ultimate goal is
> to
> generate addition 20,000 data point from this empirical distribution
> created
> from the existing 10,000 data points.
> thank you all in advance.
> 

Without knowing more than what you have stated in your email, I can only suggest that you look at

?sample

You may be able to do something as simple as

newdata <- olddata[sample(1:10000,size=20000,replace=TRUE)]

If you need more help, you need to tell us more about your data and what you are trying to do.

Hope this is helpful,

Dan

Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204




More information about the R-help mailing list