如何使用python/numpy计算百分位数? [英] How do I calculate percentiles with python/numpy?

查看:639
本文介绍了如何使用python/numpy计算百分位数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方便的方法来计算序列或一维numpy数组的百分位数?

Is there a convenient way to calculate percentiles for a sequence or single-dimensional numpy array?

我正在寻找类似于Excel的百分位功能的东西.

I am looking for something similar to Excel's percentile function.

我查看了NumPy的统计资料参考,但找不到.我只能找到中位数(第50个百分位数),但没有更具体的内容.

I looked in NumPy's statistics reference, and couldn't find this. All I could find is the median (50th percentile), but not something more specific.

推荐答案

您可能对科学统计软件包.它具有百分位数功能您在追求和其他许多统计优势.

You might be interested in the SciPy Stats package. It has the percentile function you're after and many other statistical goodies.

percentile() 可用 >也是如此.

import numpy as np
a = np.array([1,2,3,4,5])
p = np.percentile(a, 50) # return 50th percentile, e.g median.
print p
3.0

此故障单使我相信他们不会集成percentile()很快就会变成numpy.

This ticket leads me to believe they won't be integrating percentile() into numpy anytime soon.

这篇关于如何使用python/numpy计算百分位数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆