集中趋势指标特点

image.png

什么是集中趋势指标

image.png

集中趋势之平均值

image.png

集中趋势之中位数

image.png

集中趋势之众数

image.png

案例

问题

比较两组人员的薪资水平。
计算这两组薪酬数据的平均值、中位数、众数,并根据平均值、中位数和众数来判断哪一组的薪酬水平更高,原因是什么?
image.png

编码

  1. import numpy as np
  2. from decimal import Decimal
  3. salary_1 = [8600, 8700, 9500, 10400, 11000, 11500, 12500]
  4. salary_2 = [3900, 4500, 7300, 9500, 11500, 14500, 21000]
  5. mean_salary_1 = np.mean(salary_1)
  6. mean_salary_2 = np.mean(salary_2)
  7. median_salary_1 = np.median(salary_1)
  8. median_salary_2 = np.median(salary_2)
  9. mode_salary_1 = np.argmax(np.bincount(salary_1))
  10. mode_salary_2 = np.argmax(np.bincount(salary_2))
  11. print('mean_salary_1 %.2f' % mean_salary_1)
  12. print('mean_salary_2 %.2f \n' % mean_salary_2)
  13. print('median_salary_1 %.2f' % median_salary_1)
  14. print('median_salary_2 %.2f \n' % median_salary_2)
  15. print('mode_salary_1 %.2f' % mode_salary_1)
  16. print('mode_salary_2 %.2f' % mode_salary_2)

输出

  1. mean_salary_1 10314.29
  2. mean_salary_2 10314.29
  3. median_salary_1 10400.00
  4. median_salary_2 9500.00
  5. mode_salary_1 8600.00
  6. mode_salary_2 3900.00

结论

image.png
结论:组1的薪资水平高于组2