Quant Memo
Core

Quantile Functions and the Inverse CDF

The CDF answers "how likely is a value below x?"; its inverse, the quantile function, answers the question a risk manager actually asks — "what value corresponds to the 1st percentile?" — and it is also the standard trick for turning a random number generator into any distribution you want.

Prerequisites: Random Variables & Distributions, Value at Risk (VaR)

Value at risk is a sentence like "there is a 1 percent chance of losing more than $2 million tomorrow." The number $2 million wasn't found by asking "how likely is a $2 million loss?" — that's the cumulative distribution function (CDF), and it runs the wrong direction. It was found by asking "what loss level cuts off the worst 1 percent?" — which is the CDF's inverse, and it is a distinct mathematical object worth naming.

The analogy: a sorted line of outcomes

Imagine every possible outcome sorted from worst to best and lined up along a ruler from 0 to 1, where position 0 is the worst thing that can happen and position 1 the best. The CDF tells you, for any outcome, how far along that ruler it sits. The quantile function does the reverse: point at a spot on the ruler — say, "the worst 1 percent mark" — and it tells you which outcome lives there. VaR is a request to point at 0.01 and read off the outcome.

Writing it down

The CDF F(x)=P(Xx)F(x) = P(X \le x) is nondecreasing and runs from 0 to 1. Its inverse, the quantile function, is

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

In words: Q(p)Q(p) is the smallest value xx such that at least a pp fraction of the probability sits at or below it. Feed it p=0.5p = 0.5 and you get the median. Feed it p=0.01p = 0.01 and you get the 1st percentile — a 99 percent VaR level, read directly off the loss distribution's left tail.

Distribution · normal
-2.000.002.00μvalue →
Within ±1σ 68.3%mean μ 0.00std σ 1.00

Slide the mean and standard deviation above and watch the shape change; the quantile function is the same picture read sideways — instead of "how tall is the curve at xx," it answers "at what xx has the area under the curve up to that point reached pp."

The same object has a second job entirely unrelated to risk reporting: inverse transform sampling. If UU is a uniform random number between 0 and 1 — the one thing every computer can generate cheaply and reliably — then X=Q(U)X = Q(U) has exactly the distribution you wanted. This is how a random number generator that only knows how to produce uniform numbers gets turned into normal returns, exponential wait times, or any shape a Monte Carlo simulation needs.

Worked example 1: VaR as a quantile, step by step

A portfolio's daily P&L is modeled as N(0,100)\mathcal{N}(0, 100) (variance 100, so a standard deviation of $10 million). The 99 percent VaR is the loss at the 1st percentile: Q(0.01)=μ+σz0.01Q(0.01) = \mu + \sigma \cdot z_{0.01}, where z0.01=2.326z_{0.01} = -2.326 is the standard normal quantile at p=0.01p=0.01 (a standard, tabulated number). Plugging in: Q(0.01)=0+10×(2.326)=23.26Q(0.01) = 0 + 10 \times (-2.326) = -23.26. The 99 percent VaR is $23.26 million — read directly as Q(0.01)|Q(0.01)|, no separate calculation of "how likely is a $23.26 million loss" required, because the quantile function was built to answer this exact question.

Worked example 2: sampling an exponential from a uniform number

You need to simulate wait times between order fills, exponentially distributed with rate λ=2\lambda = 2 per second (mean 0.5 seconds). Its CDF is F(x)=1eλxF(x) = 1 - e^{-\lambda x}. Solve for the inverse: set p=1eλxp = 1 - e^{-\lambda x}, so eλx=1pe^{-\lambda x} = 1-p, giving

Q(p)=ln(1p)λ.Q(p) = -\frac{\ln(1-p)}{\lambda}.

In words: to sample a wait time, draw a uniform number pp between 0 and 1 and pass it through this formula. Suppose your random number generator hands you p=0.7p = 0.7: Q(0.7)=ln(0.3)/2=(1.204)/2=0.602Q(0.7) = -\ln(0.3)/2 = -(-1.204)/2 = 0.602 seconds. Draw a different uniform number, p=0.2p = 0.2: Q(0.2)=ln(0.8)/2=(0.223)/2=0.112Q(0.2) = -\ln(0.8)/2 = -(-0.223)/2 = 0.112 seconds. Repeat this thousands of times and the resulting wait times are, provably, exponentially distributed with rate 2 — built entirely from a uniform number generator and one formula.

p = 0.7 Q(0.7) = sampled value
Pick a uniform random number p on the vertical axis, trace across to the curve, then down to read off Q(p) — this is inverse transform sampling, turning one uniform draw into a draw from any target distribution.

What this means in practice

  • Every headline VaR or CVaR number is a quantile function evaluation. "99 percent VaR" literally means "evaluate QQ at p=0.01p=0.01."
  • Monte Carlo engines lean on inverse transform sampling whenever the quantile function has a closed form (uniform, exponential, and — via a numerical approximation — normal), because it needs only one uniform draw per sample.
  • Copula-based simulation (correlated risk factors with different marginal shapes) works by simulating correlated uniforms first, then passing each through its own quantile function — the technique only works because QQ exists for each marginal.

The quantile function is the CDF read backwards: instead of "how likely is a value below xx," it answers "which value cuts off the bottom pp fraction of outcomes." VaR is exactly this question, and inverse transform sampling exploits the same function to manufacture any distribution from uniform random numbers.

Do not confuse "the pp-th quantile" with "the value with pp percent chance of occurring exactly" — for a continuous distribution any single exact value has probability zero. The quantile is a cutoff, not a probability-weighted outcome, which is why VaR is routinely misread as "the worst loss you'll see" when it actually means "the loss level exceeded only pp percent of the time" — everything past that cutoff, however severe, is still possible and unmeasured by VaR itself.

Related concepts

Practice in interviews

Further reading

  • Casella & Berger, Statistical Inference (ch. 2)
  • Glasserman, Monte Carlo Methods in Financial Engineering (ch. 2)
ShareTwitterLinkedIn