我最近阅读了建议您通常应该使用中位数而不是意味着消除异常值。示例:以下文章 http://www.amazon.com/Forensic-Science-Introduction-Scientific-Investigative/product-reviews/1420064932/
目前有 16 条评论:
review = c(5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 3, 2, 1, 1)
summary(review) ## "ordinary" summary
Min. 1st Qu. Median Mean 3rd Qu. Max.
1.000 3.750 5.000 4.062 5.000 5.000
因为他们使用均值,所以文章获得 4 星,但如果他们使用中位数,则获得 5 星。
中位数不是一个“更公平”的法官吗?
实验表明,中位数的误差总是大于均值。中位数更差吗?
library(foreach)
# the overall population of bookjudgments
n <- 5
p <- 0.5
expected.value <- n*p
peoplesbelieve <- rbinom(10^6,n, p)
# 16 ratings made for 100 books
ratings <- foreach(i=1:100, .combine=rbind) %do% sample(peoplesbelieve,16)
stat <- foreach(i=1:100, .combine=rbind) %do% c(mean=mean(ratings[i,]),
median=median(ratings[i,]))
# which mean square error is bigger? Mean's or Median's?
meansqrterror.mean <- mean((stat[,"mean"]-expected.value)^2)
meansqrterror.median <- mean((stat[,"median"]-expected.value)^2)
res <- paste("mean MSE",meansqrterror.mean)
res <- paste(res, "| median MSE", meansqrterror.median)
print(res)