# Help me understand the quantile (inverse CDF) function

I am reading about the quantile function, but it is not clear to me. Could you provide a more intuitive explanation than the one provided below?

Since the cdf $F$ is a monotonically increasing function, it has an inverse; let us denote this by $F^{−1}$. If $F$ is the cdf of $X$, then $F^{−1}(\alpha)$ is the value of $x_\alpha$ such that $P(X \le x_\alpha) = \alpha$; this is called the $\alpha$ quantile of $F$. The value $F^{−1}(0.5)$ is the median of the distribution, with half of the probability mass on the left, and half on the right. The values $F^{−1}(0.25)$ and $F^{−1}(0.75)$ are the lower and upper quartiles.

• You should learn to use math markup, see my edits! – kjetil b halvorsen May 16 '16 at 12:07
• This is a model of concise explanation at a certain level and contains an example already. It's unclear what level of explanation you seek. An answer could be 10 times longer than this depending on what you don't know. E.g. do you know a cdf is? do you know what 'monotonically increasing' means? do you know what an inverse function is? We're only part way through the first sentence. Your question is equivalent to a statement that you don't understand (all) this and although we have no reason to doubt you, that is not at all a precise question. – Nick Cox May 16 '16 at 12:57

All this may sound complicated at first, but it is essentially about something very simple.

By cumulative distribution function we denote the function that returns probabilities of $$X$$ being smaller than or equal to some value $$x$$,

$$\Pr(X \le x) = F(x).$$

This function takes as input $$x$$ and returns values from the $$[0, 1]$$ interval (probabilities)—let's denote them as $$p$$. The inverse of the cumulative distribution function (or quantile function) tells you what $$x$$ would make $$F(x)$$ return some value $$p$$,

$$F^{-1}(p) = x.$$

This is illustrated in the diagram below which uses the normal cumulative distribution function (and its inverse) as an example.

## Example

As an simple example, you can take a standard Gumbel distribution. Its cumulative distribution function is

$$F(x) = e^{-e^{-x}}$$

and it can be easily inverted: recall natural logarithm function is an inverse of exponential function, so it is instantly obvious that quantile function for Gumbel distribution is

$$F^{-1}(p) = -\ln(-\ln(p))$$

As you can see, the quantile function, according to its alternative name, "inverts" the behaviour of cumulative distribution function.

## Generalized inverse distribution function

Not every function has an inverse. That is why the quotation you refer to says "monotonically increasing function". Recall that from the definition of the function, it has to assign for each input value exactly one output. Cumulative distribution functions for continuous random variables satisfy this property since they are monotonically increasing. For discrete random variables cumulative distribution functions are not continuous and increasing, so we use generalized inverse distribution functions which need to be non-decreasing. More formally, the generalized inverse distribution function is defined as

$$F^{-1}(p) = \inf \big\{x \in \mathbb{R}: F(x) \ge p \big\}.$$

The definition, translated to plain English, says that for given probability value $$p$$, we are looking for some $$x$$, that results in $$F(x)$$ returning value greater or equal then $$p$$, but since there could be multiple values of $$x$$ that meet this condition (e.g. $$F(x) \ge 0$$ is true for any $$x$$), so we take the smallest $$x$$ of those.

## Functions with no inverses

In general, there are no inverses for functions that can return same value for different inputs, for example density functions (e.g., the standard normal density function is symmetric, so it returns the same values for $$-2$$ and $$2$$ etc.). The normal distribution is an interesting example for one more reason—it is one of the examples of cumulative distribution functions that do not have a closed-form inverse. Not every cumulative distribution function has to have a closed-form inverse! Hopefully in such cases the inverses can be found using numerical methods.

## Use-case

The quantile function can be used for random generation as described in How does the inverse transform method work?

• This answer works well up until the penultimate paragraph. By the time you get there, you have asserted that every continuous CDF has an inverse but then you appear to have offered the Normal distribution as a counterexample to that very statement. That is potentially very confusing. – whuber May 5 '17 at 13:23
• @whuber you are right, added one sentence to make it more clear. – Tim May 5 '17 at 13:26
• Tim, and I added one more word to make it even clearer :) – amoeba May 5 '17 at 13:27
• @Tim great answer but could you shed some light on the definition of the inverse cdf $F^{-1}(u)=\inf\{x:F(x) \ge u\}$? As you mentioned we ask what $x$ would make $F(x)=p$. I understand the $\inf$ part as follows. Since the cdf is monotone increasing there are many values all satisfying $F(x) \ge u$ but the $\inf$ would give the greatest lower bound, i.e. fix a unique point and by doing so define generalized inverse. Does this make sense ? – Alexander Cska Oct 16 '18 at 19:29
• @AlexanderCska Yes, basically, multiple F(x) values are greater then u, so we take the lower bound, "the smallest value that meets this condition". – Tim Oct 17 '18 at 6:41

Both inverse functions (for those strictly increasing cdf) and quantile functions (for those monotonically increasing but not strictly monotonically increasing cdfs) can be denoted as $$F^{-1}$$, which can be confusing sometimes.