Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1789946
  • 博文数量: 297
  • 博客积分: 285
  • 博客等级: 二等列兵
  • 技术积分: 3006
  • 用 户 组: 普通用户
  • 注册时间: 2010-03-06 22:04
个人简介

Linuxer, ex IBMer. GNU https://hmchzb19.github.io/

文章分类

全部博文(297)

文章存档

2020年(11)

2019年(15)

2018年(43)

2017年(79)

2016年(79)

2015年(58)

2014年(1)

2013年(8)

2012年(3)

分类: Python/Ruby

2018-05-15 14:27:42

今天是percentiles 和moments.

1. percentiles: in a data set, what's the point at which x% of the values are less than that value.
例如90% percentile就是大于90%,50% percentile就是median.
IQR: interquartile range
when we talk about a distribution,IQR is the area in the middle of the distribution that contains 50% of the values.

点击(此处)折叠或打开

  1. #find percentiles
  2. vals = np.random.normal(0, 0.5, 10000)
  3. plt.hist(vals, 50)
  4. plt.show()
  5. np.percentile(vals, 50)        #median
  6. np.percentile(vals, 90)
  7. np.percentile(vals, 20)

2.  moments: Quantitative measures of the shape of a probability density function.
the 1st moment is mean.
the 2nd moment is variance.
the 3rd moment is skew.    long tail on the left means negative skew, long tail on the right means positive skew.
the 4th moment kurtosis.   how thick is the tail and how sharp is the peak , higher peak have higher kurtosis. For a normal distribution the kurtosis value should be close to 0.
峰度系数(kurtosis)用来度量数据在中心聚集程度
skew: [数学] 不对称的; [统计学] 歪斜,扭曲

点击(此处)折叠或打开

  1. In [4]: vals = np.random.normal(0, 0.5, 10000)

  2. In [5]: np.mean(vals)
  3. Out[5]: 0.0011295365153999981

  4. In [6]: np.var(vals)
  5. Out[6]: 0.25548593546863058

  6. In [7]: np.skew(vals)
  7. ---------------------------------------------------------------------------
  8. AttributeError Traceback (most recent call last)
  9. <ipython-input-7-b80cde84233b> in <module>()
  10. ----> 1 np.skew(vals)

  11. AttributeError: module 'numpy' has no attribute 'skew'

  12. In [8]: sp.skew(vals)
  13. Out[8]: 0.040095376387442

  14. In [9]: sp.kurtosis(vals)
  15. Out[9]: -0.038755363660934794


阅读(948) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~