11% File  src / library / stats / man / quantile.Rd 
22% Part  of  the  R  package , https : // www.R - project.org 
3- % Copyright  1995 - 2020  R  Core  Team 
3+ % Copyright  1995 - 2025  R  Core  Team 
44% Distributed  under  GPL  2  or  later 
55
66\name {quantile }
1717quantile(x , \dots )
1818
1919\method {quantile }{default }(x , probs  =  seq(0 , 1 , 0.25 ), na.rm  =  FALSE ,
20-          names  =  TRUE , type  =  7 , digits  =  7 , \dots )
20+          names  =  TRUE , type  =  7 , digits  =  7 ,
21+          fuzz  =  if (type  ==  7L ) 0  else  4  *  .Machine $ double.eps ,
22+          \dots )
2123}
2224\arguments {
2325  \item {x }{numeric  vector  whose  sample  quantiles  are  wanted , or  an 
@@ -36,6 +38,9 @@ quantile(x, \dots)
3638  \i tem{digits}{used only when \c ode{names} is true: the precision to use 
3739    when formatting the percentages.  In \R  versions up to 4.0.x, this had 
3840    been set to \c ode{max(2, getOption("digits"))}, internally.} 
41+   \i tem{fuzz}{small non-negative number to protect against rounding errors 
42+     when \c ode{j <- \l ink{floor}(np + m)}, (\e qn{np} \d Quote{a version of} 
43+     \c ode{n * probs}, see the formula below), is computed.} 
3944  \i tem{\d ots}{further arguments passed to or from other methods.} 
4045} 
4146\d etails{
@@ -57,6 +62,11 @@ quantile(x, \dots)
5762  There is a method for the date-time classes (see 
5863  \c ode{"\l ink{POSIXt}"}).  Types 1 and 3 can be used for class 
5964  \c ode{"\l ink{Date}"} and for ordered factors. 
65+ 
66+   \c ode{fuzz := 4 * .Machine$double.eps} has been hard coded and used for 
67+   \c ode{type = 4,5,6, 8,9} since \c ode{type}s were introduced, % r30628, 2004-08-12 
68+   and is used, since \R  4.5.0, also for the other types (but with default 
69+   \c ode{0} for the default \c ode{type = 7} for back compatibility reasons). 
6070} 
6171\s ection{Types}{
6272  \c ode{quantile} returns estimates of underlying distribution quantiles 
@@ -139,14 +149,16 @@ quantile(x, \dots)
139149    } 
140150  } 
141151  Further details are provided in \b ibcite{Hyndman and Fan (1996)} who 
142-   recommended type 8.   
152+   recommended type 8. 
143153  The default method is type 7, as used by S and by \R  < 2.0.0. 
144-   \I {Makkonen} argues for type 6, also as already proposed by Weibull in 1939. 
154+   \b ibcite{Makkonen and Pajari (2014)} argue for type 6, also as already 
155+   proposed by Weibull in 1939. 
145156  The Wikipedia page contains further information about availability of 
146157  these 9 types in software. 
147158} 
148159\a uthor{
149-   of the version used in \R  >= 2.0.0, Ivan Frohne and Rob J Hyndman. 
160+   of the version used in \R  >= 2.0.0, Ivan Frohne and Rob J Hyndman; 
161+   tweaks, notably use of \c ode{fuzz}, by the R Core Team. 
150162} 
151163\r eferences{
152164  Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) 
@@ -157,13 +169,16 @@ quantile(x, \dots)
157169  packages, \e mph{American Statistician} \b old{50}, 361--365. 
158170  \d oi{10.2307/2684934}. 
159171
172+   Eric Langford (2006)  Quartiles in Elementary Statistics, \e mph{Journal 
173+   of Statistics Education} \b old{14} 3; \d oi{10.1080/10691898.2006.11910589} 
174+ 
175+   Makkonen, L. and Pajari, M. (2014)  Defining Sample Quantiles by the True 
176+   Rank Probability, \e mph{Journal of Probability and Statistics; Hindawi Publ.Corp.} 
177+   \d oi{10.1155/2014/326579} 
178+ 
160179  Wicklin, R. (2017) Sample quantiles: A comparison of 9 definitions; SAS Blog. 
161180  \u rl{https://blogs.sas.com/content/iml/2017/05/24/definitions-sample-quantiles.html} 
162181
163-   %% Makkonen, L. and Pajari, M. (2014)  Defining Sample Quantiles by the True 
164-   %% Rank Probability. \e mph{Journal of Probability and Statistics; Hindawi Publ.Corp.} 
165-   %% \d oi{10.1155/2014/326579} 
166-   %% 
167182  Wikipedia: \u rl{https://en.wikipedia.org/wiki/Quantile#Estimating_quantiles_from_a_sample} 
168183} 
169184\s eealso{
0 commit comments