#4. Sample Variance and degrees of freedom #Histogram of s^2 for normal population of size n #Histogram of \hat \sigma^2 (with n in denominator) for normal populaion of size n. # par(mfrow=c(1,1)) n=3 nsamp=1000 ssquared=NULL for(iter in 1:nsamp) ssquared=c(ssquared,var(rnorm(n))) hist(ssquared, main = paste("1000 Replications of Sample Variance, n=3 Vertical lines at 1, Mean of Sample Variance =",(round(mean(ssquared),3))), xlab="Sample Variance") abline(v=mean(ssquared)) abline(v=1) title(sub="Population is Standard Normal") #