Quantile function (source code)

= Quantile function
{title2=$Q(p)=\inf\{x:F(x)\geq p\}$}
{wiki}

= Quantile
{synonym}

The <quantile function> converts a cumulative probability level into a value. For a <cumulative distribution function> $F$ and $0<p<1$, use the generalized inverse
$$
Q(p)=\inf\{x:F(x)\geq p\}.
$$
It selects the first threshold reaching the requested level. The <infimum> handles jumps and flat portions, so this construction does not require an ordinary <inverse function>. Other endpoint conventions are possible at $p=0$ or $p=1$; the open probability <interval> avoids those issues. NIST introduces the inverse-direction question as the percent point function. https://itl.nist.gov/div898/handbook/eda/section3/eda362.htm[NIST: cumulative distribution and percent point functions]{ref}.

For the finite example under <probability distribution>,
$$
Q_X(p)=\begin{cases}
0,&0<p\leq0.2,\\
1,&0.2<p\leq0.7,\\
3,&0.7<p<1.
\end{cases}
$$
Thus $Q_X(0.1)=0$, $Q_X(0.5)=1$, $Q_X(0.9)=3$. The value at $p=0.2$ is still zero, because $F_X(0)=0.2$ already reaches that level. For $F_Y(y)=y^2$ on $[0,1]$, the <quantile function> is $Q_Y(p)=\sqrt p$, giving $Q_Y(0.5)=1/\sqrt2\approx0.70710678$.

\Image[/quantile-generalized-inverse.png]
{title=Quantile functions map probability levels to outcomes, including repeated outcomes}
{description=Left: the three probability bands of widths $0.2$, $0.5$ and $0.3$ map to outcomes $0$, $1$ and $3$. Right: the <quantile function> $\sqrt p$ maps the same probability levels to the continuous density example. The marked levels are $0.1$, $0.5$ and $0.9$. Endpoints at $p=0$ and $p=1$ are shown open because the stated <quantile function> convention uses $0<p<1$.}

A <median> is a central threshold; $Q(1/2)$ supplies one, though a <median> need not be unique. The same <quantile function> becomes a sampling algorithm through <inverse transform sampling>. Jumps in $F$ become flat bands in $Q$, precisely the mechanism needed to assign positive probability to one outcome.