*From*: Henry Carstens <carstens@xxxxxxxxxxxxxxxxxxxxx>*To*: tech-spec@xxxxxxxxxxxxx*Date*: Sun, 5 Dec 2004 19:34:48 -0800

`# resample - repeated random samples from a vector
# v is a vector of price changes
# samplesize is the size of each resample
# repeatcount is the number of times to repeat the experiment
# the output is a matrix whose first 11 columns are the deciles for
each sample
# col 12 is the mean of the sample
# col 13 is the std dev
# col 14 is the z score for the sample
resample<-function(v, samplesize, repeatcount){`

m<-matrix(data=0,nrow=repeatcount,ncol=14) decilevec<-seq(0,1,.1) for (index in 1:repeatcount) { s<-sample(v, size=samplesize) d<-quantile(s,decilevec) for (i in 1:11){ m[index,i]<-d[i] } m[index,12]<-mean(s) m[index,13]<-sd(s) m[index,14]<-samplesize^.5 * mean(s)/sd(s) } return(m) }

**References**:**[tech-spec] Random Number Generation***From:*Andrew Moe

**[tech-spec] Re: Random Number Generation***From:*Daniel Flam

- » [tech-spec] resample - repeated random samples from a vector