简体   繁体   中英

sample from given distribution

I have a text file with a distribution of values, one on each row eg:

2313213.32
321233.23
97938.23
21323
211555

How do I randomly sample from this distribution 1000 times with replacement and get the mean from this random sampling? Preferably using R.

Thank you in advance,

Rubal

#test<-readLines('your.file')
#test<-as.numeric(test)

test<-c(2313213.32,321233.23,97938.23,21323,211555)

out<-sample(test,1000,replace=TRUE)

out.mean<-mean(out)
> out.mean
[1] 618679.5

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM