# Re: R-beta: Quantile function

Peter Dalgaard BSA (p.dalgaard@biostat.ku.dk)
12 Feb 1998 13:42:03 +0100

```To: Philippe Lambert <phlamber@luc.ac.be>
Subject: Re: R-beta: Quantile function
From: Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk>
Date: 12 Feb 1998 13:42:03 +0100
In-Reply-To: Philippe Lambert's message of Thu, 12 Feb 1998 13:08:37 +0100 (MET)

Philippe Lambert <phlamber@luc.ac.be> writes:

>
> Is the following behaviour of the quantile function what one would expect?
> > a <- 1:100
> > quantile(a,.6)
>  60%
> 60.4

Yes...

And so is
> quantile(1:10)
0%   25%   50%   75%  100%
1.00  3.25  5.50  7.75 10.00

(Note that *three* values, 8,9,10 fall above the 75% quantile!)

There are many possible definition of quantiles. R's (and Splus's) is
to put 0% at the minimum and 100% at the maximum, and in general, the
k-th smallest is at (k-1)/(n-1), with linear interpolation between the
points. (Try plot(quantile(rnorm(5),seq(0,1,.01))) to see it).

This can surely be criticized, e.g. you'll always have 1 observation
below the 0.00..001 quantile! Alternatives might for example use
(k-.5)/n which puts the smallest observation at 1/2n, but then it's
tricky to define quantiles outside (1/2n,1-1/2n).

--
O__  ---- Peter Dalgaard             Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics     2200 Cph. N
(*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
```