2
$\begingroup$

Let $x_1,x_1,\dots,x_n \in \mathbb{R} (n \in \mathbb{N})$ be some observations and let $x_{(1)}, x_{(2)},\dots,x_{(n)}$ be increasingly sorted observations. The $\alpha$-quantile for $\alpha \in (0,1)$ is defined by

$$ q_\alpha = \begin{cases} x_{(\text{ceiling}(n\alpha))} & \text{if } n\alpha \notin \mathbb{Z} \\ [x_{(n\alpha)}, x_{(n\alpha+1)}] & \text{if } n\alpha \in \mathbb{Z} \end{cases} $$

I understand that this definition is for the quantile, where $\alpha =0.2$ would mean $20$th percentile. However, I don't really understand $n\alpha$. Is that $n$ multiplied by $\alpha$, what would that even mean?

Update: Ok, I think I sort of get it. Suppose there were $50$ observations, then the $\alpha$ quantile can either be defined by an observation or an interval of observations, this depends on whether $n\alpha$ is an integer or not. Suppose we say $\alpha = 0.2$, then $0.2\cdot50= 10$, an integer, so the $\alpha$ quantile is $[x_{10}, x_{11}]$. Is this correct?

$\endgroup$
  • 1
    $\begingroup$ Can you add a reference (citation) for the definition you are quoting - what is the source? Also, it is better to write the definition rather than just copy an image: much of the image is irrelevant to your question, it is not accessible to people using screen readers, and words in the picture can't be found by a search engine. $\endgroup$ – Silverfish Jul 3 '16 at 2:57
  • $\begingroup$ Good points, It was from page 36 of this online text: bookboon.com/en/… $\endgroup$ – jim Heyner Jul 3 '16 at 3:01
  • $\begingroup$ to get $x_{10}$ type $x_{10}$ $\endgroup$ – Glen_b -Reinstate Monica Jul 3 '16 at 3:41
  • $\begingroup$ Ahh ok, I tried it with round brackets and it wasn't working, thank you very much. $\endgroup$ – jim Heyner Jul 3 '16 at 4:32
  • $\begingroup$ @jimHeyner I edited your question, check if it is ok. Notice: you can click the edit button to view the source and check how does $\TeX$ formatting work. $\endgroup$ – Tim Jul 3 '16 at 8:18
5
$\begingroup$

I wanted to type a brief answer but in the process, I felt the need to elaborate... this text is about the quantiles of a sample, or, maybe about the empirical quantiles of a distribution. I don’t know about the whole text but this snippet is not so good — we need to forget it and start from scratch. I’ll start by the quantiles of a distribution.

Remember the cdf, the cumulative distribution function? It is defined by $$F(x) = Pr(X \le x).$$ In many cases, e.g. if $X$ is normal, $F$ is a bijection from $\mathbb R$ to $(0,1)$. In this case, you can define the quantiles of the distribution by $$q_\alpha = F^{-1}(\alpha),$$ that is, $q_\alpha$ is the unique number such that $$ F(q_\alpha) = Pr( X \le q_\alpha ) = \alpha, $$ for all $\alpha \in(0,1)$.

However, in many situations $F$ is not a bijection and we have to find something else. Let $$q_\alpha = \text{inf}\left\{ q : F(q) \ge \alpha \right\}. $$ To better understand this definition, I’ll split it in three subcases.

  • if there is a unique number $q$ such that $Pr(X \le q) = \alpha$, then this is $q_\alpha$, as in our first case;
  • there may also be a whole interval of such $q$'s: in this case, $q_\alpha$ is the lower bound of this interval, $F(q_\alpha) = \alpha$ and no smaller number has this property;
  • there may be no such number $q$; in this case, consider the interval of numbers $q$ such that $\Pr(X \le q) \ge \alpha$; $q_\alpha$ is the lower bound of this interval, $F(q_\alpha)$ is $> \alpha$ and no smaller number has this property.

So now turn to the quantiles of a sample. Assume you have 4 observations $x_{(1)} \le x_{(2)} \le x_{(3)} \le x_{(4)}$.

You can consider a distribution in which these $4$ numbers have equal probability $0.25$. In this case, for $\alpha \le 0.25$, $q_\alpha = x_{(1)}$, for $0.25 < \alpha \le 0.50$, $q_\alpha = x_{(2)}$, and so on. This is the behavior of the $R$ function quantile when type = 1 (not the default!).

You can also prefer to consider that these numbers are sampled from an unknown distribution, and that your aim is to find a good estimations of its quantiles. In this case, many rules are possible, based on various kind of linear interpolations.

Now, back to your text. To me, it doesn’t make much sense to consider that the quantile $q_{0.25}$ of this sample of four numbers is the whole interval $[x_{(1)}, x_{(2)}]$. This might be a good manual to learn R, but I recommend that you use a statistics textbook too for proper definition of the concepts.

$\endgroup$
  • 1
    $\begingroup$ I've seen quantiles defined as entire intervals in statistics textbooks too! It may not be very practical but I suspect this is done for theoretical reasons. $\endgroup$ – Silverfish Jul 3 '16 at 12:09
  • 1
    $\begingroup$ @Silverfish This makes the quantile function take its values in $\mathcal P(\mathbb R)$. Why would you do something like that? It seems really uselessly complex. In this case, I think the natural thing to do would be to define $q_\alpha$ as $F^{-1}\bigl( \{ \alpha \} \bigr)$, with the inconvenient that its value can be the empty set. $\endgroup$ – Elvis Jul 3 '16 at 13:51
4
$\begingroup$

The definition that you quote uses order statistics notation, so $x_{(1)}$ is the first value of the ordered sample (i.e. the minimum), $x_{(n)}$ is the $n$-th value (i.e. the maximum), $x_{((n+1)/2)}$ is the median for odd $n$ etc. Using such notation you can define the $\alpha$-th quantile as $x_{(n\alpha)}$ when $n\alpha$ is an integer, e.g. if $n=100$, and $\alpha = 0.5$, then $n\alpha = 50$. Notice however that this differs from how would we understand the median, because for the median we would take the average of $x_{(n/2)}$ and $x_{((n+1)/2)}$. This is because the definition that you quote is not the formal one, but is rather one of the ways that we may translate the definition of distribution quantile to that of sample quantiles (see Hyndman and Fan, 1996). The definition of distribution quantile is

$$ Q(p) = F^{-1}(p) = \inf\{x : F(x) \ge p \} $$

so it is the smallest value of $x$ such that its probability is at least $p$ (in case of your definition, $\alpha$).


Hyndman, R.J., & Fan, Y. (1996). Sample Quantiles in Statistical Packages. American Statistician, 50 (4): 361–365.

$\endgroup$
  • $\begingroup$ Yep, shorter than mine :) I started typing before you answered, if your answer had been there I wouldn’t have consider answering too... $\endgroup$ – Elvis Jul 3 '16 at 8:35
  • 1
    $\begingroup$ @Elvis your answer is clear and detailed, so it also can be helpful +1 $\endgroup$ – Tim Jul 3 '16 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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