= Quartile
{title2=$Q_1,Q_2,Q_3$}
{wiki}
<Quartiles> are the <quantiles> at <probability> levels $1/4,1/2,3/4$; $Q_2$ is a <median>. For a population we can use its <quantile function>, $Q_r=Q(r/4)$ for $r=1,2,3$. Finite-sample conventions differ. Our <box plot> uses linear interpolation between <order statistics>: for $n\geq2$ and $0<p<1$, set
$$
h=1+(n-1)p,\qquad j=\lfloor h\rfloor,\qquad g=h-j,\qquad \widetilde Q(p)=(1-g)x_{(j)}+g x_{(j+1)}.
$$
Then $Q_r=\widetilde Q(r/4)$. This is R's type-7 convention, described in the documentation authored by Ivan Frohne and Rob J Hyndman. It differs from the generalized-inverse <sample quantile> defined elsewhere in this wiki: for the twelve toy values, that rule selects ranks $3,6,9$ and gives $2,4,6$, rather than $2.75,4.5,6.25$. These are different stated conventions, not arithmetic disagreements. https://stat.ethz.ch/R-manual/R-devel/library/stats/html/quantile.html[Frohne and Hyndman, R stats documentation, sample quantile types]{ref}
Back to article page