【问题标题】:Percentile rank calculation百分等级计算
【发布时间】:2012-01-31 06:30:30
【问题描述】:

我正在尝试使用python statlib 模块计算得分的percentile rankpercentileofscore 函数应该返回一个介于 0 和 100 之间的值,但它通常会生成超出此范围的数字。一个例子:

 >> a = [0,1,2,3,4,5]
 >> percentileofscore(a, 0)
 108.33333333333333

我已经尝试了scipy 模块,并且我自己也尝试了类似的结果。

我是不是误会了什么。这个功能?

编辑 - 更多示例:

 percentileofscore([23,23,23,25], 23)
 137.5
 percentileofscore([12,19,65,25], 12)
 112.5
 percentileofscore([112,109,605,25], 25)
 112.5

似乎查询最低分数的百分位数会导致问题。也许是一个错误?

【问题讨论】:

  • 确实很有趣。出于好奇,您能否再添加一些这样的例子?
  • 毫无疑问是一个错误。不错的收获。

标签: python statistics scipy percentile


【解决方案1】:

scipy.stats.percentileofscore 似乎按预期工作:

In [2]: import scipy.stats as stats

In [3]: stats.percentileofscore([0,1,2,3,4,5], 0)
Out[3]: 16.666666666666664

【讨论】:

  • 在测试 scipy 时,我一定没有正确检查我的导入,感谢您清除它。问题似乎仅限于 statlib。
  • 我不认为 statlib 得到维护,虽然最初从 statlib 继承的代码中的 scipy.stats 有几个错误修复和改进,例如对于这种情况 projects.scipy.org/scipy/ticket/560
猜你喜欢
  • 1970-01-01
  • 2018-03-10
  • 1970-01-01
  • 2019-10-10
  • 2020-02-05
  • 1970-01-01
  • 2011-06-01
  • 2021-01-10
相关资源
最近更新 更多