### Tutorial3 Question # data provided # first group of students x <- c(66, 75, 72, 71, 55, 56, 72, 93, 73, 72, 72, 73, 91, 66, 71, 56, 59) # second group of students y <- c(54, 52, 51, 50, 36, 55, 44, 46, 57, 44, 43, 52, 38, 46, 55, 34, 44, 39, 43, 36, 55, 57, 36, 46, 49, 46, 49, 47) ##### ### Part a # boxplot for the first group boxplot(x) # boxplot for the second group boxplot(y) # If you want to compare them next to each other boxplot(x,y,names=c("first group","second group")) ##### ### Part b # Yes in the first group, and no in the second # If you want to determine outliers, compute the following two calues # above Qu+1.5*IQR and below Ql-1.5*IQR are considered outliers q.l <- quantile(x,0.25) q.u <- quantile(x,0.75) iqr <- q.u-q.l q.u+1.5*iqr q.l-1.5*iqr # This means data points below 55.5 and above 83.5 are considered outliers ##### ### Part c # For the first set of data range(x) range(x)[2]-range(x)[1] # the range is 38 sort(x) # 72 is the mode since it appeared 4 times median(x) # 72 is the median mean(x) # 70.17647 is the mean sum(x)/length(x) # For the second set range(y) range(y)[2]-range(y)[1] # the range is 23 sort(y) # 46 is the mode since it appeared 4 times median(y) # 46 is the median mean(y) # 46.57143 is the mean sum(y)/length(y) ##### ### Part d # For the first set, the median is greater than the mean, # therefore the data is skewed to the left. # For the second set, the median is less than the mean, # therefore the data is slightly skewed to the right, but not by a lot since the values are close ##### ### Part e # First set var(x) sum((x-mean(x))^2)/(length(x)-1) # the variance is 112.5294 sqrt(var(x)) sd(x) sqrt(sum((x-mean(x))^2)/(length(x)-1)) # the standard deviation is 10.60799 # Second set var(y) sum((y-mean(y))^2)/(length(y)-1) # the variance is 46.62434 sd(y) sqrt(sum((y-mean(y))^2)/(length(y)-1)) # the standard deviation is 6.828202