# Solution to BPS Exercise 15.7, 15.15 scores = c(86,63,81,55,72,72,65,66,75,59) #15.7a hist(scores) #15.7b mu = mean(scores) print("mean score") print(mu) #15.7c samplescores = sample(scores,4) print("sample of four, and their mean:") print(samplescores) print(mean(samplescores)) #15.7d n = 10000 trials = replicate(n,mean(sample(scores,4))) hist(trials) #15.15b #You can do this by eye, but here we estimate with the trials: bigones = length(trials[trials >= 76]) print("proportion of xbar larger than 76:") print(bigones/n) #15.15c print("xbar for students 1,3,5,7:") print(mean(scores[c(1,3,5,7)]))