set1 <- c(10, 2, 3, 2, 4, 2, 5)
set2 <- c(20, 12, 13, 12, 14, 12, 15)
mode <- function(x) {
ux <- unique(x)
ux[which.max(tabulate(match(x, ux)))]
}
Q1:
##set1
mean(set1)
[1] 4
median(set1)
[1] 3
mode(set1)
[1] 2##set2
mean(set2)
[1] 14
median(set2)
[1] 13
mode(set2)
[1] 12Q2:
##set1
range(set1)
[1] 2 10
quantile(set1)
0% 25% 50% 75% 100%
2.0 2.0 3.0 4.5 10.0
var(set1)
[1] 8.333333
sd(set1)
[1] 2.886751##set2
range(set2)
[1] 12 20
quantile(set2)
0% 25% 50% 75% 100%
12.0 12.0 13.0 14.5 20.0
var(set2)
[1] 8.333333
sd(set2)
[1] 2.886751Q3:
Based on these results we can see how the mean median and mode is higher in set2 than in set1 because the numbers within set2 are of higher value. In contrast, the range of set1 and set2 is the same length. The biggest thing to note is that even though the numbers in set2 are larger than set1, its variance and standard deviation are the same. This shows us that on a graph, the shape of set1’s bell curve would be the same as set2’s bell curve because even though the numbers are different, the variation of the numbers are the exact same.
Leave a comment