How to find the statistical mode?

前端 未结 30 2139
时光取名叫无心
时光取名叫无心 2020-11-21 07:00

In R, mean() and median() are standard functions which do what you\'d expect. mode() tells you the internal storage mode of the objec

30条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-11-21 07:56

    I would use the density() function to identify a smoothed maximum of a (possibly continuous) distribution :

    function(x) density(x, 2)$x[density(x, 2)$y == max(density(x, 2)$y)]
    

    where x is the data collection. Pay attention to the adjust paremeter of the density function which regulate the smoothing.

提交回复
热议问题