Page 362 #5

Solution

# create a vector class
num_s25 = vector()
sum_s25 = vector()
mean_a25 = vector()
ind_num = 25

# run the for loop 1000 times
for (x in 1:1000){
  a = runif(ind_num, min = 0, max = 20)
  num_s25[[x]] = sum(a)
  sum_s25[[x]] = (sum(a) - (ind_num * mean(a)))/(sqrt(ind_num) - sd(a))
  mean_a25[[x]] = mean(a)
}

summary(num_s25)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   178.0   228.1   249.4   249.0   269.1   341.3
summary(sum_s25)
##       Min.    1st Qu.     Median       Mean    3rd Qu.       Max. 
## -3.264e-12  0.000e+00  0.000e+00 -8.016e-15  0.000e+00  7.067e-13
summary(mean_a25)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   7.119   9.125   9.975   9.959  10.762  13.651
barplot(num_s25)

barplot(sum_s25)

barplot(mean_a25)

The fit for S25 is better than the standard sum of S25 and the mean of A25.