[R] percentile of a given value: is there a "reverse" quantile function?

drflxms drflxms at googlemail.com
Sat Mar 3 14:48:11 CET 2012


Thank you a lot Peter, Stefan and Pascal,

for your quick an inspiring answers.

ecdf(distribution)(value)->percentile was exactly, what I was looking
for, as it is in my eyes somehow the equivalent to
quantile(distribution, percentile)->value, isn't it.

Greetings from sunny Munich, Felix


Am 03.03.12 14:33, schrieb peter dalgaard:
> 
> On Mar 3, 2012, at 13:37 , drflxms wrote:
> 
>> Dear all,
>>
>> I am familiar with obtaining the value corresponding to a chosen
>> probability via the quantile function.
>> Now I am facing the opposite problem I have a value an want to know it's
>> corresponding percentile in the distribution. So is there a function for
>> this as well?
> 
> For a single value, mean(x <= a) will do. Otherwise check ecdf().
> 
>> x <- rnorm(100)
>> mean(x <= 2)
> [1] 0.97
>> ecdf(x)(2)
> [1] 0.97
>> ecdf(x)(-3:3)
> [1] 0.00 0.01 0.14 0.48 0.80 0.97 1.00
> 
> if you need values for your original data points, rank(x)/length(x) should do (bar missing value issues).
> 
>>
>> Thank you for your support in advance, Felix
>>
>> ______________________________________________
>> R-help at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list