R> x=c(92, 3, 1, 4, 15, 4)
R> rank(x)
[1] 6.0 2.0 1.0 3.5 5.0 3.5

Given the rank results of an input vector of sampled data, I can estimate the quantiles like the following.

R> (rank(x)-1)/(6-1)
[1] 1.0 0.2 0.0 0.5 0.8 0.5

In this case, since 92 is the greatest number, the estimate of the quantile of this number is 1. But the sample may be limited so that there may just be greater numbers from the underlying distribution, it is just not seen in this sample.

Therefore, I may adjust the result a little. In the following example, I adjusted the numerator and the denominator by 1 and 2, respectively.

R> rank(x)/(6+1)
[1] 0.8571429 0.2857143 0.1428571 0.5000000 0.7142857 0.5000000

But these two numbers are rather arbitrary. Alternatively, I may adjust the numerator and the denominator by .5 and 1, respectively. I am not sure what is considered as most statistically sound. This seems to be a rudimental problem, I don't remember seeing it in statistical textbooks that I read.

The ecdf() function does not seem to treat the two extreme values (92 and 1) symmetrically (I'd expect the sum of their results be 1), so it is not appropriate for my purpose.

R> ecdf(x)(x)
[1] 1.0000000 0.3333333 0.1666667 0.6666667 0.8333333 0.6666667

Could anybody let me know what is the currently recommended way to estimate the quantiles from samples?


1 Answer 1


The quantile function and its help page provides and describes 9 ways to estimate quantiles, with references, including to a paper that compares all 9 (Hyndman, R. J. and Fan, Y. (1996) Sample quantiles in statistical packages, American Statistician 50, 361–365. doi: 10.2307/2684934.)

The Hyndman and Fan paper is 26 years old, but I think it's still fairly current.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.