I have read other posts (such as here) on getting the "reverse" of quantile -- that is, to get the percentile that corresponds to a certain value in a series of values.
However, the answers don't give me the same value as quantile for the same data series.
I have also researched that quantile provides 9 different algorithms to calculate percentile.
So my question: is there a reliable way to get the reverse of the quantile function? ecdf does not take a "type" argument so it doesn't seem that one can make sure they are using the same method.
Reproducible example:
# 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