【发布时间】:2019-11-05 13:05:54
【问题描述】:
我已阅读其他有关获取分位数“反向”的帖子(例如here) - 即获取与一系列值中的某个值相对应的百分位数。
但是,对于相同的数据系列,答案并没有给出与分位数相同的值。
我还研究了分位数提供了 9 种不同的算法来计算百分位数。
所以我的问题是:有没有可靠的方法来获得分位数函数的反转? ecdf 不接受“类型”参数,因此似乎无法确保它们使用相同的方法。
可重现的例子:
# Simple data
x = 0:10
pcntile = 0.5
# Get value corresponding to a percentile using quantile
(pcntile_value <- quantile(x, pcntile))
# 50%
# 5 # returns 5 as expected for 50% percentile
# Get percentile corresponding to a value using ecdf function
(pcntile_rev <- ecdf(x)(5))
# [1] 0.5454545 #returns 54.54% as the percentile for the value 5
# Not the same answer as quantile produces
【问题讨论】:
标签: r quantile percentile ecdf