User Tools

Site Tools


To generate the samples, one can proceed like in Exercise 1.7 (pg. 44 in ISwR). A solution there is apply(sapply(rep(100,10),rnorm),2,mean). To understand how it works, start with help(sapply) and sapply(rep(100,10).

In the assignment, we need to pass parameters to the sample function. This is done by named parameters: sapply(1:1000,sample,x=101:111,size=5) . One could also use replicate in a similar manner or use a for loop instead of the implicit loop.

The means and medians are obtained like in Ex. 1.7.

/var/www/ · Last modified: 2007/09/11 21:54 by helgi

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki