In intro statistics textbooks, the mode is typically described as least susceptible to skewness, followed by the median, which is in turn followed by the mean. The difference between the median and the mean is pretty straightforward to me, but I am a bit unclear about the mode. It seems that in discrete distributions, it is possible for the median and the mode to be the same.
For example, if I have a dataset as shown below:
#R code
median(rep(1:8, c(rep(1,3), rep(2, 2), 7, 1, 1)))
[1] 1 2 3 4 4 5 5 6 6 6 6 6 6 6 7 8
hist(rep(1:8, c(rep(1,3), rep(2, 2), 7, 1, 1)),
breaks=seq(0.5, 8, length=8), freq=FALSE, main="", xlab="values")
Here, the mean and the median are
mean(rep(1:8, c(rep(1,3), rep(2, 2), 7, 1, 1))); median(rep(1:8, c(rep(1,3), rep(2, 2), 7, 1, 1)))
[1] 5.0625
[1] 6
The mode is 6. So in this case, the median and the mode are identical. Can someone please elaborate on this? Thanks.