# CLT - #samDistn #INPUTS: 1) NUMsamp - the number of samples...

This preview shows pages 1–2. Sign up to view the full content.

#INPUTS: 1) NUMsamp - the number of samples you wish to take # 2) Study - the Study Data # 3) sampSIZE - the sample size you wish to take # 4) REPLACE - sampling with or without replacement #OUTPUTS:1) a vector of means samDistn <- function(NUMsamp,Study,sampSIZE,REPLACE) { meanVECT <- NULL for (i in 1:NUMsamp) { x <- mean(sample(Study,sampSIZE,REPLACE)) meanVECT[i] <- x } return(meanVECT) } #DISPLAY #INPUTS: see above. last is a flag (true or false) to plot zoom in on the last plot #OUTPUTS: displays a histogram of the means and calculates basic statistics DISPLAY <- function(NUMsamp,Study,sampSIZE,REPLACE,last) { #Draw a Sample data <- samDistn(NUMsamp,Study,sampSIZE,REPLACE) #determine the number of histogram breaks minS <- (min(Study) )#+min(data))/2 maxS <- (max(Study) )#+max(data))/2 brks <- (c(0:50)/50)*(maxS-minS)+minS #set up title textpart <- "Sample Averages: n = " mathpart <- sampSIZE title <- append(textpart,mathpart) #Draw a historgram h<-hist(data,main=title,xlab="X-BAR",ylab="",breaks=brks) h lines(h\$mids,h\$counts) #set up title for the zoomed histogram

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 11/16/2010 for the course STAT 340 taught by Professor Xu(sunny)wang during the Spring '09 term at Waterloo.

### Page1 / 3

CLT - #samDistn #INPUTS: 1) NUMsamp - the number of samples...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online