Suppose that X is a continuous random variable and $x_{0.25}$, $x_{0.5}$, $x_{0.75}$ are the 25th, 50th and 75th quantiles respectively. How can I write in terms of probabilities the fact that "quantiles are the three cut points that will divide a dataset into four equal-sized groups"?

  • $\begingroup$ This cannot be correct in general, because the only datasets that can be divided into four equal-sized groups are those whose count is a multiple of four! $\endgroup$
    – whuber
    Commented Feb 28, 2020 at 15:05

2 Answers 2


For a continuous random variable with probability density $f(x)$, quantiles are well defined. You can, e.g., use the following definition for the $p$-Quantile $x_p$: $$p=F(x_p)=\int_{-\infty}^{x_p} f(x)\, dx \quad\Rightarrow\quad x_p=F^{-1}(p)$$ For discrete random variables and empirical samples, there is however no consensus how to define the quantiles in ambiguous (and sometimes even in non-ambiguous) cases. The R-function quantile alone offers nine (sic!) different options for the defintion of quantiles. For an overview of common definitions, see

Hyndman, Rob J., and Yanan Fan. "Sample quantiles in statistical packages." The American Statistician 50.4 (1996): 361-365.


The short version of the answer is that $P(X \le x_{0.25}) = 0.25$ for the lower quartile, Also, in a large sample from the distribution of $X,$ very nearly 25% of observations will be smaller than $x_{0.25}.$ Similar statements hold for the median and upper quartile. The following illustration shows some specific population and sample quantiles.

Suppose you are interested in a population distributed according to a gamma distribution, $\mathsf{Gamma}(\text{shape}=50, \text{rate}=0.5),$ so that the density function of the population is as shown in the figure below. Also, the R function qgamma finds quantiles of a gamma distribution; the quantiles are shown by vertical red lines.

curve(dgamma(x, 50, 0.5), 0, 200, lwd=2, ylab="PDF",
 abline(v=0, col="green2");  abline(h=0, col="green2")
  q = qgamma(c(.25,.5,.75), 50, 0.5)
  abline(v=q, col="red", lwd=2)
[1]  90.13322  99.33413 109.14124

enter image description here

The four areas under the density curve separated by the vertical red lines are equal. (There is sort of an optical illusion here, but the areas are equal.)

If we simulate a very large sample from this distribution, then its sample quantiles will nearly match the theoretical quantiles shown above.

[Unless you ask for something different, the quantile function also gives the minimum 0% and maximum 100%. The theoretical values are $0$ and $\infty,$ but those extreme values are not well estimated even by a huge sample. For very large samples, the differences @cdalitz (+1) notes among software programs are mostly unimportant. ]

x = rgamma(10^6, 50, .5)
       0%       25%       50%       75%      100% 
 42.17696  90.13293  99.31625 109.13695 187.73144 
hist(x, prob=T, col="skyblue2", 
     main="Sample of a Million from GAMMA(50,.5)")
 curve(dgamma(x,50,.5), add=T, lwd=2)
 abline(v=samp.q, col="red", lwd=2, lty="dotted")

enter image description here


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.