1\name{q489} 2\alias{q489} 3\title{Even Quicker Sample Quantiles } 4\description{ 5The function \code{q489} computes a single sample quantile using a 6fortran implementation of the Floyd and Rivest (1975) algorithm. 7In contrast to the more elaborate function \code{kuantile} that uses 8the Kiweil (2005) implementation it does not attempt to replicate the 9nine varieties of quantiles as documented in the base function. 10\code{quantile} 11} 12\usage{ 13q489(x, tau = .5) 14} 15\arguments{ 16 \item{x}{numeric vector} 17 \item{tau}{the quantile of intereste.} 18} 19\details{ This is a direct translation of the Algol 68 implementation of 20Floyd and Rivest (1975), implemented in Ratfor. For the median, average 21case behavior requires \eqn{1.5 n + O((n log n)^{1/2})} comparisons. 22In preliminary experiments it seems to be somewhat faster in large samples 23than the implementation \code{kuantile} of Kiwiel (2005). See Knuth (1998) 24for further details. No provision is made for non-uniqueness of the quantile. 25so, when \eqn{\tau n} is an integer there may be some discrepancy.} 26\value{ 27 A scalar quantile of the same length as the vector p. 28} 29\references{ 30R.W. Floyd and R.L. Rivest: "Algorithm 489: The Algorithm 31 SELECT---for Finding the $i$th Smallest of $n$ Elements", 32 Comm. ACM 18, 3 (1975) 173, 33 34K.C. Kiwiel: On Floyd and Rivest's SELECT Algorithm, Theoretical 35 Computer Sci. 347 (2005) 214-238. 36 37D. Knuth, The Art of Computer Programming, Volume 3, Sorting and 38 Searching, 2nd Ed., (1998), Addison-Wesley. 39} 40\author{ R.W.Floyd and R.L.Rivest, R implementation: Roger Koenker } 41\seealso{\code{\link{quantile}}} 42\examples{ 43 medx <- q489(rnorm(1001)) 44} 45\keyword{univar} 46