Quantcast

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

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

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

drflxms
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?

Thank you for your support in advance, Felix

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: percentile of a given value: is there a "reverse" quantile function?

Stephan Kolassa
?ecdf

Best,
Stephan


On 03.03.2012 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?
>
> Thank you for your support in advance, Felix
>
> ______________________________________________
> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: percentile of a given value: is there a "reverse" quantile function?

Peter Dalgaard-2
In reply to this post by drflxms

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
>
> ______________________________________________
> [hidden email] 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.

--
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: [hidden email]  Priv: [hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re : percentile of a given value: is there a "reverse" quantile function?

Pascal Oettli-2
In reply to this post by drflxms
Hi Felix,

Have a look at ?pnorm and ?qnorm.

And at ?Distributions

Regards,
Pascal



----- Mail original -----
De : drflxms <[hidden email]>
À : [hidden email]
Cc :
Envoyé le : Samedi 3 mars 2012 21h37
Objet : [R] percentile of a given value: is there a "reverse" quantile function?

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?

Thank you for your support in advance, Felix

______________________________________________
[hidden email] 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.


______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: percentile of a given value: is there a "reverse" quantile function?

drflxms
In reply to this post by Peter Dalgaard-2
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
>>
>> ______________________________________________
>> [hidden email] 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.
>

______________________________________________
[hidden email] 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.
Loading...