Tutorials › Statistical Theory I - Probability and Distribution Theory › Quantiles from Density Integrals

Support, Quantiles, and Tails · Tutorial 83 of 994

Quantiles from Density Integrals

Turn a density into a CDF, then use its accumulated probability to find quantiles, including when the density changes across intervals.

Beginner 9 min read

What You'll Learn

  • Express a CDF as an integral of a density over the region to its left
  • Set up the probability equation that defines a quantile
  • Find quantiles by integrating uniform and exponential densities
  • Split an integral correctly when a density is piecewise-defined
  • Check a proposed quantile against its probability level
  • Recognize when a quantile equation needs numerical rather than algebraic solution

From Density to Quantile

A density describes how probability is distributed locally, but a quantile asks a cumulative question: how far along the number line must we go to collect a specified probability? Connecting these views requires integration. First accumulate the density up to a candidate value to obtain the CDF; then solve for the value at which that cumulative probability reaches the desired level.

For a continuous distribution, this often reduces to an equation of the form “integral of the density equals \(p\).” The important details are choosing the correct integration limits, respecting the support, and splitting the integral wherever the density formula changes.

Definition: A random variable \(X\) has density \(f\) if \(f(x)\geq 0\), \(\int_{-\infty}^{\infty} f(t)\,dt=1\), and, for every measurable set \(A\), \(P(X\in A)=\int_A f(t)\,dt\). Its cumulative distribution function is \(F(x)=P(X\leq x)\). For \(0<p<1\), its \(p\)-quantile is the generalized inverse \(Q(p)=\inf\{x:F(x)\geq p\}\).

The CDF as an Integral

The density determines probabilities by integration. In particular, the event \(X\leq x\) corresponds to the interval \((-\infty,x]\), so its probability is the integral of the density over that interval.

Result: If \(X\) has density \(f\), then for every real \(x\), $$ F(x)=\int_{-\infty}^{x} f(t)\,dt. $$ If the density is zero outside an interval \([a,b]\), this may be written as \(F(x)=0\) for \(x<a\), \(F(x)=\int_a^x f(t)\,dt\) for \(a\leq x\leq b\), and \(F(x)=1\) for \(x>b\).

This identity follows directly from the definition of a density: \(F(x)=P(X\in(-\infty,x])\), and probabilities of sets are obtained by integrating \(f\) over those sets. Since a single point has integral zero, the choice to include or exclude the endpoint \(x\) does not change the value.

To find a quantile, set the CDF equal to the target probability and solve for \(x\). When the CDF is continuous and strictly increasing across the relevant range, the solution is unique and agrees with the generalized-inverse definition. A convenient sufficient condition on an interval is that every subinterval of positive length has positive integral of \(f\). A density can be zero at some points and still satisfy this condition; what matters is that it does not assign zero probability to an entire interval.

Quantile equation: For a continuous distribution whose CDF is strictly increasing over its support, the \(p\)-quantile \(q_p\), for \(0<p<1\), is the unique solution of $$ \int_{-\infty}^{q_p} f(t)\,dt=p. $$ If \(f\) is supported on \([a,b]\), the equation becomes \(\int_a^{q_p} f(t)\,dt=p\), with \(q_p\in(a,b)\).

For completeness, when \(F\) is continuous and strictly increasing from 0 to 1 on its support, the intermediate value theorem gives a unique \(q_p\) such that \(F(q_p)=p\). Strict increase ensures that no smaller point has CDF at least \(p\), so \(\inf\{x:F(x)\geq p\}=q_p\). Substituting the integral expression for \(F\) gives the quantile equation above. This argument also explains why the density itself is not set equal to \(p\): the probability level is reached by accumulating density across an interval.

Worked Quantiles

Worked Example: A Uniform Density

Let \(X\) be uniform on \([0,4]\), with density \(f(x)=1/4\) for \(0\leq x\leq4\) and zero otherwise. Find the 30th percentile.

The density is normalized because \(\int_0^4 (1/4)\,dt=1\). For \(0\leq x\leq4\), integrate from the left endpoint of the support:

$$ F(x)=\int_0^x \frac14\,dt=\frac{x}{4}. $$

The 30th percentile is the value \(q_{0.30}\) for which \(F(q_{0.30})=0.30\). Thus

$$ \frac{q_{0.30}}{4}=0.30 \quad\Longrightarrow\quad q_{0.30}=1.20. $$

This value lies in \([0,4]\), as required. Checking it in the integral gives \(\int_0^{1.2}(1/4)\,dt=1.2/4=0.30\).

Worked Example: An Exponential Density

Suppose \(X\) has an exponential density with rate \(2\): \(f(x)=2e^{-2x}\) for \(x\geq0\), and \(f(x)=0\) otherwise. Find its 80th percentile.

The density integrates to one since \(\int_0^\infty 2e^{-2t}\,dt=1\). For \(x\geq0\), its CDF is

$$ F(x)=\int_0^x 2e^{-2t}\,dt =\left[-e^{-2t}\right]_0^x =1-e^{-2x}. $$

Set this accumulated probability equal to \(0.80\), then solve:

$$ 1-e^{-2q_{0.80}}=0.80 \quad\Longrightarrow\quad e^{-2q_{0.80}}=0.20 \quad\Longrightarrow\quad q_{0.80}=-\frac12\log(0.20) \approx 0.8047. $$

The solution is positive, as it must be because the support is \([0,\infty)\). Substitution verifies it: \(e^{-2q_{0.80}}=0.20\), so \(F(q_{0.80})=1-0.20=0.80\).

When the Density Is Piecewise

If the density changes formula at a point, the integral must be split at that point whenever the interval of integration crosses it. The CDF remains an accumulated probability: probability gathered before the change point must be carried forward, rather than discarded when the second formula begins.

Worked Example: A Quantile Across a Density Change

Let \(X\) have density

$$ f(x)= \begin{cases} \frac14, & 0\leq x\leq1,\\ \frac34, & 1<x\leq2,\\ 0, & \text{otherwise}. \end{cases} $$

Find the 60th percentile. First check the total probability: \(\int_0^1 (1/4)\,dt+\int_1^2 (3/4)\,dt=1/4+3/4=1\). The probability accumulated by \(x=1\) is \(1/4\). Because \(0.60>0.25\), the desired quantile lies in the second interval, so both pieces contribute:

$$ F(x)=\int_0^1 \frac14\,dt+\int_1^x \frac34\,dt =\frac14+\frac34(x-1),\qquad 1<x\leq2. $$

Now set this expression equal to \(0.60\) and solve:

$$ \frac14+\frac34(q_{0.60}-1)=\frac35, \qquad \frac34(q_{0.60}-1)=\frac35-\frac14=\frac{7}{20}, $$
$$ q_{0.60}-1=\frac{7}{20}\cdot\frac43=\frac{7}{15}, \qquad q_{0.60}=\frac{22}{15}\approx1.4667. $$

The result is in \((1,2)\), which confirms that the correct piece of the density was used. Substitution gives \(F(22/15)=1/4+(3/4)(7/15)=1/4+7/20=12/20=0.60\).

A reliable approach is to identify which part of the support contains the desired quantile before solving an equation. For a piecewise density, compute the cumulative probability at each change point. These values divide the probability levels into ranges. Once the relevant range is known, integrate all earlier pieces and then the current piece.

1
Locate the support and target level.
Record where the density is nonzero and the desired probability \(p\).
2
Accumulate probability.
Integrate from the left edge of the support, splitting at every change in the density formula that the integration crosses.
3
Solve and check.
Set the accumulated probability equal to \(p\), solve for the candidate, and verify that it lies in the interval where the chosen formula applies.

When an Integral Equation Has No Closed-Form Solution

Not every density leads to an algebraic formula for a quantile. For example, for \(X\sim N(0,1)\), the \(p\)-quantile satisfies \(\int_{-\infty}^{q_p}(1/\sqrt{2\pi})e^{-t^2/2}\,dt=p\). That equation defines the quantile precisely even though the integral does not simplify to an elementary expression. A numerical method or a table may be used to approximate its solution.

Whatever method is used, the defining check is the same: the probability to the left of the proposed value should be \(p\). For a numerical answer, this is assessed by evaluating the CDF at the candidate and checking that it is sufficiently close to the target probability.

Common Pitfalls

  • Setting the density equal to the probability level. The equation \(f(q_p)=p\) is generally not the quantile equation. A density is a local rate of probability per unit of \(x\), while the quantile is found by solving \(\int_{-\infty}^{q_p}f(t)\,dt=p\).
  • Starting from the wrong lower limit. If the support begins at \(a\), integrate from \(a\), not from zero unless \(a=0\). In an unrestricted formula the lower limit is \(-\infty\), with the density zero wherever the variable cannot occur.
  • Forgetting earlier pieces. In the piecewise example, the integral on \((1,x]\) alone is not \(F(x)\). It omits the probability \(1/4\) already accumulated on \([0,1]\).
  • Using a formula outside its interval. A solution obtained from one piece is valid only if it lies in that piece's interval. Check the location after solving.
  • Confusing density height with probability. A density value can exceed one; probabilities come from areas, that is, integrals over intervals or sets.
Key takeaway: A quantile from a density is found by accumulating probability, not by inspecting the density at one point. Integrate over the support up to the candidate, split the integral where the formula changes, solve for the target probability, and check the result against its interval and probability level.

Check Your Understanding

Use the integral definition of the CDF to answer each question. Check any proposed quantile by substituting it back into the accumulated probability.

  1. If a density is supported on \([2,5]\), what are the appropriate integration limits for \(F(x)\) when \(2\leq x\leq5\)?
  2. A uniform density on \([0,10]\) is \(1/10\). Set up and solve the integral equation for its 25th percentile.
  3. For a density that changes formula at \(x=1\), why must an integral for \(F(x)\), with \(x>1\), include the contribution from values below 1?
  4. In the piecewise example, which interval contains the 20th percentile, and what equation determines it?
  5. Explain why solving \(f(q_p)=p\) does not, in general, find a \(p\)-quantile.