Quant Sandbox
DerivativesPortfolio & RiskFixed IncomeCorporate FinanceProbability & MeasureStochastic ModelsMarket MicrostructureGuide
Guide
Derivatives pricing0 / 17
01Forwards, calls and puts02Combining positions03Arbitrage and the forward price04Put–call parity05The one-step binomial model06Risk-neutral probabilities07Multi-step trees and backward induction08American options and early exercise09Delta and hedging10Geometric Brownian motion11The Black–Scholes formula12The Greeks: gamma, vega, theta and rho13Options on dividend-paying stocks, indices, currencies and futures14Implied volatility and the volatility smile15Stochastic volatility and the Heston model16Static replication: Breeden–Litzenberger and Carr–Madan17Exotic options: barriers, Asians and digitals
Portfolio & risk0 / 12
01Returns and volatility02Diversification and correlation03The efficient frontier and the capital market line04Risk aversion and the optimal complete portfolio05CAPM, beta and the security market line06Performance measures: Sharpe, Treynor, Jensen and information ratio07Factor models and systematic risk08The Fama–French factor models09Value at Risk and expected shortfall10Systemic risk and contagion11Portfolio constraints and the no-short-sales frontier12Estimating expected returns and covariances
Fixed income0 / 10
01Bond prices and yields02Duration and convexity03Immunization and duration matching04Spot rates, forward rates and the yield curve05Non-parallel curve moves and key-rate durations06Bond futures and the cheapest-to-deliver07Interest rate swaps08Callable bonds and negative convexity09Credit risk: default probabilities and credit spreads10Real rates, inflation and inflation-linked bonds
Corporate finance0 / 10
01Interest, compounding and discounting02Annuities, perpetuities and loan amortization03Net present value and internal rate of return04Project risk: sensitivity, scenarios and Monte Carlo NPV05The weighted average cost of capital06Capital structure and the Modigliani–Miller theorems07Dividends, payout policy and the dividend discount model08Discounted cash flow valuation09Relative valuation with multiples10Real options: the value of flexibility
Probability and measure0 / 13
01Measuring the size of sets02σ-algebras and Borel sets03Lebesgue measure and null sets04Measurable functions05The Lebesgue integral06Convergence theorems07Probability spaces and Kolmogorov's axioms08Random variables and their distributions09Expectation, variance and inequalities10Independence and product measures11Modes of convergence and the law of large numbers12Conditional probability and conditional expectation13Measure theory in option pricing
Stochastic models0 / 17
01Random walks and Brownian motion02The law of large numbers and the central limit theorem03Probability spaces, σ-algebras and random variables04Filtrations, adapted processes and stopping times05Conditional expectation and martingales06Properties of Brownian motion07The reflection principle and first passage times08The Brownian bridge09The Itô integral10Itô's lemma11Kolmogorov equations and the Feynman–Kac formula12Change of measure and Girsanov's theorem13Monte Carlo option pricing14Simulating SDEs: the Euler–Maruyama scheme15Correlated Brownian motions and multi-asset models16Mean reversion: Ornstein–Uhlenbeck and Vasicek17Jumps and the Merton jump-diffusion model
Market microstructure0 / 11
01Market makers and liquidity02The limit order book03Queue position and fill probability04Adverse selection and informed trading05The Glosten–Milgrom model06Measuring and decomposing the bid–ask spread07Informed trading and Kyle's lambda08Price impact and optimal execution09Inventory risk and quote skewing10Optimal quoting: the Avellaneda–Stoikov model11Market making profit and loss attribution
Knowledge graph

© 2026 Quant Sandbox · A study aid for quantitative finance

Privacy & dataNo cookies

This site does not use cookies and asks for no personal data. It keeps a few small settings in your browser's local storage — your chosen theme and language, the sidebar layout, and your progress and answers in the Guides — so it remembers them on your next visit. This data never leaves your device; clearing your browser storage removes it. Inputs you change can also be captured in the page URL, so you can share or bookmark a specific setup. The site uses Vercel Web Analytics, a privacy-friendly, cookieless service that records only anonymous, aggregated usage (such as page views) without identifying you or tracking you across other sites.

Guides/Probability and measure/08

Random variables and their distributions

Lesson 8 of 13 · 1 min read

"Measurable functions" showed how a function on a space can be measured: when fff is measurable, the set f−1(B)f^{-1}(B)f−1(B) is an event for every Borel set BBB, and the image measure records how much of the space is sent into BBB. "Probability spaces and Kolmogorov's axioms" then supplied the spaces on which this will happen: two dice, a dart thrown at a square, a uniform number UUU in [0,1][0, 1][0,1], an endless sequence of coin tosses. This lesson puts the two together. A random variable is a measurable function on a probability space, a score, a count, a waiting time, and its distribution is its image measure, a probability measure on the number line that says how the values are spread. The lesson explains why one increasing function, the distribution function, describes the whole distribution, how atoms and densities appear in it, which distributions turn up most often, and how the inverse of the distribution function turns uniform numbers into draws from any distribution at all.

Random variables

Let (Ω,F,P)(\Omega, \mathcal{F}, \mathbb{P})(Ω,F,P) be a probability space. A random variable is a measurable function X:Ω→RX : \Omega \to \mathbb{R}X:Ω→R. By "Measurable functions" this means that {X∈B}=X−1(B)\{X \in B\} = X^{-1}(B){X∈B}=X−1(B) is an event for every Borel set BBB, and by the half-line test it is enough that {X≤x}\{X \le x\}{X≤x} is an event for every real number xxx. The name is old and slightly misleading: XXX is neither random nor a variable. It is a fixed function that attaches a number to every outcome, and the randomness lies in which outcome ω\omegaω the experiment produces. Writing P(X≤3)\mathbb{P}(X \le 3)P(X≤3) is shorthand for P({ω:X(ω)≤3})\mathbb{P}(\{\omega : X(\omega) \le 3\})P({ω:X(ω)≤3}).

Measurability is exactly what is needed to ask the questions one wants to ask. The number P(X≤x)\mathbb{P}(X \le x)P(X≤x) exists only if {X≤x}\{X \le x\}{X≤x} is an event. Take a die whose observer sees only the parity of the face, with the σ-algebra {∅,{1,3,5},{2,4,6},Ω}\{\emptyset, \{1, 3, 5\}, \{2, 4, 6\}, \Omega\}{∅,{1,3,5},{2,4,6},Ω}. For this observer the event "the face is at most 2" does not exist, since {1,2}\{1, 2\}{1,2} is not in the σ-algebra, so the face itself cannot be a random variable on this space, while "face mod 2" can. A random variable has to be computable from the information the events stand for.

Four examples, each on a model from "Probability spaces and Kolmogorov's axioms", show how varied random variables are.

  • The sum of two dice. On the 36 outcomes (d1,d2)(d_1, d_2)(d1​,d2​), each with probability 1/361/361/36, let S=d1+d2S = d_1 + d_2S=d1​+d2​. When every subset of Ω\OmegaΩ is an event, every function is measurable. The value 7 comes from six outcomes, (1,6),(2,5),…,(6,1)(1, 6), (2, 5), \ldots, (6, 1)(1,6),(2,5),…,(6,1), so P(S=7)=6/36=1/6\mathbb{P}(S = 7) = 6/36 = 1/6P(S=7)=6/36=1/6, while the value 2 comes from only (1,1)(1, 1)(1,1), so P(S=2)=1/36\mathbb{P}(S = 2) = 1/36P(S=2)=1/36.
  • Functions of a uniform number. On Ω=[0,1]\Omega = [0, 1]Ω=[0,1] with Lebesgue measure, U(ω)=ωU(\omega) = \omegaU(ω)=ω is a random variable, and so are U2U^2U2 and −ln⁡(1−U)-\ln(1 - U)−ln(1−U), which is +∞+\infty+∞ only at the single outcome ω=1\omega = 1ω=1 of probability 0. The event {U2≤0.25}\{U^2 \le 0.25\}{U2≤0.25} is [0,0.5][0, 0.5][0,0.5], so P(U2≤0.25)=0.5\mathbb{P}(U^2 \le 0.25) = 0.5P(U2≤0.25)=0.5. The event {−ln⁡(1−U)≤1}\{-\ln(1 - U) \le 1\}{−ln(1−U)≤1} is [0,1−e−1][0, 1 - e^{-1}][0,1−e−1], so its probability is 1−e−1=0.63211 - e^{-1} = 0.63211−e−1=0.6321.
  • Heads among the first tosses. On the coin model, where the tosses are the binary digits of ω\omegaω, let HnH_nHn​ count the digits equal to 1 among the first nnn. It depends on finitely many digits, so it is constant on dyadic intervals and measurable. Among the eight equally likely patterns of three tosses, three have exactly two heads, so P(H3=2)=3/8\mathbb{P}(H_3 = 2) = 3/8P(H3​=2)=3/8. For ten tosses, P(H10=5)=252/1024=0.2461\mathbb{P}(H_{10} = 5) = 252/1024 = 0.2461P(H10​=5)=252/1024=0.2461.
  • The distance of a dart from the centre. For a dart uniform on the unit square, let RRR be its distance from the centre. The set {R≤r}\{R \le r\}{R≤r} is a disc of radius rrr around the centre, and for r≤12r \le \tfrac12r≤21​ the disc lies inside the square, so its area is πr2\pi r^2πr2. Hence P(R≤0.25)=π/16=0.1963\mathbb{P}(R \le 0.25) = \pi/16 = 0.1963P(R≤0.25)=π/16=0.1963 and P(R≤0.5)=π/4=0.7854\mathbb{P}(R \le 0.5) = \pi/4 = 0.7854P(R≤0.5)=π/4=0.7854.

New random variables come from old ones by the rules of "Measurable functions". If XXX is a random variable and ggg is a Borel function, such as a continuous or monotone function, then g(X)g(X)g(X) is a random variable, because {g(X)∈B}={X∈g−1(B)}\{g(X) \in B\} = \{X \in g^{-1}(B)\}{g(X)∈B}={X∈g−1(B)}. Sums, products, maxima and limits of random variables are random variables, which is why U2U^2U2 and −ln⁡(1−U)-\ln(1 - U)−ln(1−U) above needed no separate check.

The distribution of a random variable

A random variable moves probability from Ω\OmegaΩ onto the number line. Think of one unit of sand spread over Ω\OmegaΩ, with the probability of an event as the amount of sand in it, and let XXX carry every grain from ω\omegaω to the position X(ω)X(\omega)X(ω). The distribution of XXX, also called its law, is the image measure of P\mathbb{P}P under XXX, as defined in "Measurable functions":

PX(B)=P(X∈B)=P(X−1(B)),B∈B(R).\mathbb{P}_X(B) = \mathbb{P}(X \in B) = \mathbb{P}\big(X^{-1}(B)\big), \qquad B \in \mathcal{B}(\mathbb{R}).PX​(B)=P(X∈B)=P(X−1(B)),B∈B(R).

It tells how much sand ends up in BBB. It is a probability measure on the Borel sets: the whole line receives P(Ω)=1\mathbb{P}(\Omega) = 1P(Ω)=1, and disjoint sets BkB_kBk​ have disjoint preimages, so countable additivity of P\mathbb{P}P carries over. For the sum of two dice the distribution is a collection of point masses, PS=∑s=2126−∣s−7∣36 δs\mathbb{P}_S = \sum_{s=2}^{12} \frac{6 - |s - 7|}{36}\, \delta_sPS​=∑s=212​366−∣s−7∣​δs​, in the notation of "Measuring the size of sets": masses 1/36,2/36,…,6/36,…,1/361/36, 2/36, \ldots, 6/36, \ldots, 1/361/36,2/36,…,6/36,…,1/36 at 2,3,…,122, 3, \ldots, 122,3,…,12. For U2U^2U2 on the uniform space, PU2([0,c])=c\mathbb{P}_{U^2}([0, c]) = \sqrt{c}PU2​([0,c])=c​.

The distribution forgets which outcome produced which value. It keeps only how the values are spread, and different random variables can have exactly the same distribution. On [0,1][0, 1][0,1] the variables UUU and 1−U1 - U1−U satisfy P(U≤0.3)=0.3\mathbb{P}(U \le 0.3) = 0.3P(U≤0.3)=0.3 and P(1−U≤0.3)=P(U≥0.7)=0.3\mathbb{P}(1 - U \le 0.3) = \mathbb{P}(U \ge 0.7) = 0.3P(1−U≤0.3)=P(U≥0.7)=0.3, and the same holds for every interval, so they have the same distribution. Yet they are different functions: they agree only at ω=12\omega = \tfrac12ω=21​, and they differ by more than 12\tfrac1221​ exactly when U<14U < \tfrac14U<41​ or U>34U > \tfrac34U>43​, which has probability 12\tfrac1221​. For two dice, 14−S=(7−d1)+(7−d2)14 - S = (7 - d_1) + (7 - d_2)14−S=(7−d1​)+(7−d2​), and 7−d7 - d7−d is again a uniform face, so SSS and 14−S14 - S14−S have the same distribution while agreeing only when S=7S = 7S=7.

Two random variables with the same distribution are called equal in distribution, written X=dYX \overset{d}{=} YX=dY. This is much weaker than X=YX = YX=Y: the first says that the values are spread alike, the second that they agree outcome by outcome. Random variables on different probability spaces can be equal in distribution as well. That is why a model is usually specified through a distribution, as in "XXX is exponential with mean 2", without saying what Ω\OmegaΩ is.

The distribution function

A distribution is a function on sets, a large object. One number for each real xxx turns out to be enough. The distribution function of XXX is

F(x)=P(X≤x),x∈R.F(x) = \mathbb{P}(X \le x), \qquad x \in \mathbb{R}.F(x)=P(X≤x),x∈R.

In sand terms, F(x)F(x)F(x) is the amount of sand at or to the left of xxx. For the uniform UUU, F(x)=xF(x) = xF(x)=x on [0,1][0, 1][0,1], 000 to the left and 111 to the right. For U2U^2U2 it is x\sqrt{x}x​ on [0,1][0, 1][0,1]. For a fair die it is the staircase F(x)=⌊x⌋/6F(x) = \lfloor x \rfloor / 6F(x)=⌊x⌋/6 on [0,6][0, 6][0,6], which stays at 000 before the first face and at 111 from the last face on. Four properties hold for every random variable, and each one follows from a rule of "Measuring the size of sets".

  • Non-decreasing. If x≤yx \le yx≤y then {X≤x}⊆{X≤y}\{X \le x\} \subseteq \{X \le y\}{X≤x}⊆{X≤y}, so F(x)≤F(y)F(x) \le F(y)F(x)≤F(y) by monotonicity.
  • Limits 0 and 1. The events {X≤n}\{X \le n\}{X≤n} increase to Ω\OmegaΩ, so F(n)→1F(n) \to 1F(n)→1 by continuity from below. The events {X≤−n}\{X \le -n\}{X≤−n} decrease to ∅\emptyset∅, so F(−n)→0F(-n) \to 0F(−n)→0 by continuity from above, which is allowed because the total mass is finite.
  • Right-continuous. The event {X≤x}\{X \le x\}{X≤x} is the intersection of the decreasing events {X≤x+1/n}\{X \le x + 1/n\}{X≤x+1/n}, so F(x+1/n)↓F(x)F(x + 1/n) \downarrow F(x)F(x+1/n)↓F(x), again by continuity from above.
  • Left limits. The event {X<x}\{X < x\}{X<x} is the increasing union of {X≤x−1/n}\{X \le x - 1/n\}{X≤x−1/n}, so the limit from the left is F(x−)=P(X<x)F(x-) = \mathbb{P}(X < x)F(x−)=P(X<x). It can be smaller than F(x)F(x)F(x), because the point xxx itself belongs to {X≤x}\{X \le x\}{X≤x}. This is why FFF is continuous from the right but not necessarily from the left.

On the die, F(3)=3/6=12F(3) = 3/6 = \tfrac12F(3)=3/6=21​ while just to the left of 3, F(2.999)=2/6=13F(2.999) = 2/6 = \tfrac13F(2.999)=2/6=31​: a jump of size 16\tfrac1661​ at 3, with the value at the top of the jump. The properties let one read off probabilities. Since {X≤b}\{X \le b\}{X≤b} is the disjoint union of {X≤a}\{X \le a\}{X≤a} and {a<X≤b}\{a < X \le b\}{a<X≤b} for a<ba < ba<b,

P(a<X≤b)=F(b)−F(a),P(X=x)=F(x)−F(x−).\mathbb{P}(a < X \le b) = F(b) - F(a), \qquad \mathbb{P}(X = x) = F(x) - F(x-).P(a<X≤b)=F(b)−F(a),P(X=x)=F(x)−F(x−).

The second formula says that the probability of a single value is the size of the jump of FFF there. For the die, P(2<X≤5)=F(5)−F(2)=56−26=12\mathbb{P}(2 < X \le 5) = F(5) - F(2) = \tfrac56 - \tfrac26 = \tfrac12P(2<X≤5)=F(5)−F(2)=65​−62​=21​ and P(X=3)=12−13=16\mathbb{P}(X = 3) = \tfrac12 - \tfrac13 = \tfrac16P(X=3)=21​−31​=61​.

The function FFF determines the whole distribution. Two distributions with the same FFF agree on every interval (a,b](a, b](a,b]. By the uniqueness argument of "Lebesgue measure and null sets", two probability measures that agree on a family of sets closed under intersection agree on the σ-algebra generated by it, and the half-open intervals generate the Borel sets of "σ-algebras and Borel sets". So FFF is a complete description of PX\mathbb{P}_XPX​. The converse also holds: every function that is non-decreasing and right-continuous with limits 000 and 111 is the distribution function of some random variable. Section 7 constructs it.

Atoms, densities and mixed laws

A value xxx with P(X=x)>0\mathbb{P}(X = x) > 0P(X=x)>0 is an atom of the distribution: a point carrying a positive amount of sand, which shows as a jump of FFF. This word has nothing to do with the atoms of a σ-algebra, the blocks of a partition. A distribution has at most countably many atoms, because at most nnn values can have probability at least 1/n1/n1/n, since the total is 1. A distribution with all its mass on atoms is discrete, and the die and the sum of two dice are examples. Its distribution function is a staircase.

At the other extreme, a distribution has a density fff if P(a<X≤b)=∫abf(x) dx\mathbb{P}(a < X \le b) = \int_a^b f(x)\,dxP(a<X≤b)=∫ab​f(x)dx for all a<ba < ba<b, with f≥0f \ge 0f≥0 and total area 111. Then F(x)=∫−∞xf(t) dtF(x) = \int_{-\infty}^{x} f(t)\,dtF(x)=∫−∞x​f(t)dt is continuous, and where fff is continuous, F′=fF' = fF′=f. The density is the thickness of the sand layer, like the rod with density ρ\rhoρ in "Measuring the size of sets": the mass in a short interval of width hhh near xxx is about f(x) hf(x)\,hf(x)h. The exponential distribution with mean 1 has density f(x)=e−xf(x) = e^{-x}f(x)=e−x for x≥0x \ge 0x≥0, so F(x)=1−e−xF(x) = 1 - e^{-x}F(x)=1−e−x and P(1<X≤3)=e−1−e−3=0.3181\mathbb{P}(1 < X \le 3) = e^{-1} - e^{-3} = 0.3181P(1<X≤3)=e−1−e−3=0.3181.

A density value is not a probability. It can exceed 1: the uniform distribution on [0,12][0, \tfrac12][0,21​] has density 2 there. Every single value has probability 000, because the area under a curve over one point is zero, and so FFF has no jumps.

The two kinds can be mixed. Someone arrives at a traffic light. With probability 0.70.70.7 it is green and the wait is 000 minutes; otherwise the wait is exponential with mean 2 minutes. The wait XXX has

F(x)=0.7+0.3 (1−e−x/2)for x≥0,F(x)=0for x<0.F(x) = 0.7 + 0.3\,\big(1 - e^{-x/2}\big) \quad \text{for } x \ge 0, \qquad F(x) = 0 \quad \text{for } x < 0.F(x)=0.7+0.3(1−e−x/2)for x≥0,F(x)=0for x<0.

The function FFF jumps by 0.70.70.7 at 000, so P(X=0)=0.7\mathbb{P}(X = 0) = 0.7P(X=0)=0.7 and 000 is the only atom, and then it rises smoothly with slope 0.15 e−x/20.15\,e^{-x/2}0.15e−x/2 towards 1. In sand terms the distribution is 0.7 δ00.7\,\delta_00.7δ0​ plus 0.30.30.3 times an exponential layer. Most drivers do not wait at all, yet the waits of the others are spread over a continuum of values.

A fourth shape exists, and it is rare outside examples. Let ξ1,ξ2,…\xi_1, \xi_2, \ldotsξ1​,ξ2​,… be the tosses of the coin model, 000 for tails and 111 for heads, and let X=∑k≥12ξk/3kX = \sum_{k \ge 1} 2\xi_k / 3^kX=∑k≥1​2ξk​/3k. The base-3 digits of XXX are 000 or 222, so XXX always lies in the Cantor set CCC of "Lebesgue measure and null sets". Its distribution function is the Cantor function: F=12F = \tfrac12F=21​ on the whole removed middle third [13,23][\tfrac13, \tfrac23][31​,32​], F=14F = \tfrac14F=41​ on [19,29][\tfrac19, \tfrac29][91​,92​], F=34F = \tfrac34F=43​ on [79,89][\tfrac79, \tfrac89][97​,98​], and constant on every removed interval. The removed intervals have total length 1, so FFF is flat almost everywhere, yet it climbs from 0 to 1, and all of the climb happens on CCC, which has length 0. This FFF is continuous, so there are no atoms, and there is no density either: a density fff would give CCC the probability ∫Cf dx=0\int_C f\,dx = 0∫C​fdx=0, since CCC has length zero, but P(X∈C)=1\mathbb{P}(X \in C) = 1P(X∈C)=1. Such distributions are called singular.

A catalogue of common laws

A handful of distributions account for most of the cases one meets. Each comes from a short story, and recognising the story is the quickest way to know the distribution.

  • Bernoulli($p$). One toss of a coin that shows heads with probability ppp: P(X=1)=p\mathbb{P}(X = 1) = pP(X=1)=p and P(X=0)=1−p\mathbb{P}(X = 0) = 1 - pP(X=0)=1−p. This is the indicator 1A\mathbf{1}_A1A​ of an event AAA with P(A)=p\mathbb{P}(A) = pP(A)=p.
  • Binomial($n$, $p$). The number of heads in nnn tosses of such a coin, the tosses not influencing each other: P(X=k)=(nk)pk(1−p)n−k\mathbb{P}(X = k) = \binom{n}{k} p^k (1 - p)^{n-k}P(X=k)=(kn​)pk(1−p)n−k for k=0,…,nk = 0, \ldots, nk=0,…,n. For a fair coin and n=10n = 10n=10, P(X=5)=252/1024=0.2461\mathbb{P}(X = 5) = 252/1024 = 0.2461P(X=5)=252/1024=0.2461.
  • Geometric($p$). The number of tosses up to and including the first head: P(X=k)=(1−p)k−1p\mathbb{P}(X = k) = (1 - p)^{k-1} pP(X=k)=(1−p)k−1p for k=1,2,…k = 1, 2, \ldotsk=1,2,…. For a fair coin P(X=3)=18\mathbb{P}(X = 3) = \tfrac18P(X=3)=81​, the pattern tails, tails, heads. On the coin model, {X>k}\{X > k\}{X>k} means that the first kkk binary digits of ω\omegaω are all 0, which is the interval [0,2−k)[0, 2^{-k})[0,2−k), so P(X>k)=2−k\mathbb{P}(X > k) = 2^{-k}P(X>k)=2−k.
  • Poisson($\lambda$). The number of events in a unit of time when they occur at random at an average rate λ\lambdaλ: P(X=k)=e−λλk/k!\mathbb{P}(X = k) = e^{-\lambda} \lambda^k / k!P(X=k)=e−λλk/k! for k=0,1,2,…k = 0, 1, 2, \ldotsk=0,1,2,…. For λ=2\lambda = 2λ=2, P(X=2)=2e−2=0.2707\mathbb{P}(X = 2) = 2e^{-2} = 0.2707P(X=2)=2e−2=0.2707 and P(X≤1)=3e−2=0.4060\mathbb{P}(X \le 1) = 3e^{-2} = 0.4060P(X≤1)=3e−2=0.4060.
  • Uniform($a$, $b$). A number with all positions in [a,b][a, b][a,b] equally likely: density 1/(b−a)1/(b - a)1/(b−a) on [a,b][a, b][a,b] and F(x)=(x−a)/(b−a)F(x) = (x - a)/(b - a)F(x)=(x−a)/(b−a) there. The number UUU of "Probability spaces and Kolmogorov's axioms" is Uniform(000, 111).
  • Exponential(rate $\theta$). A waiting time without memory: density θe−θx\theta e^{-\theta x}θe−θx and F(x)=1−e−θxF(x) = 1 - e^{-\theta x}F(x)=1−e−θx for x≥0x \ge 0x≥0. Its mean is 1/θ1/\theta1/θ, so mean 2 means rate 12\tfrac1221​.
  • Normal($\mu$, $\sigma^2$). The bell curve, centred at μ\muμ with spread σ\sigmaσ: density 1σ2π e−(x−μ)2/(2σ2)\dfrac{1}{\sigma\sqrt{2\pi}}\, e^{-(x - \mu)^2 / (2\sigma^2)}σ2π​1​e−(x−μ)2/(2σ2). Its distribution function has no closed formula. For μ=0\mu = 0μ=0 and σ=1\sigma = 1σ=1, P(∣X∣≤1)=0.6827\mathbb{P}(|X| \le 1) = 0.6827P(∣X∣≤1)=0.6827 and P(∣X∣≤1.96)=0.95\mathbb{P}(|X| \le 1.96) = 0.95P(∣X∣≤1.96)=0.95. A later lesson of this track explains why sums of many small contributions look like this.

The Poisson distribution is a limit of binomial ones. Cut the unit of time into nnn short pieces and suppose that each piece contains one event with probability λ/n\lambda/nλ/n, the pieces not influencing each other. The number of events is then binomial(nnn, λ/n\lambda/nλ/n), and for a fixed kkk,

(nk)(λn)k(1−λn)n−k=λkk!⋅n(n−1)⋯(n−k+1)nk⋅(1−λn)n⋅(1−λn)−k  ⟶  λkk! e−λ.\binom{n}{k} \Big(\frac{\lambda}{n}\Big)^{k} \Big(1 - \frac{\lambda}{n}\Big)^{n-k} = \frac{\lambda^k}{k!} \cdot \frac{n(n-1)\cdots(n-k+1)}{n^k} \cdot \Big(1 - \frac{\lambda}{n}\Big)^{n} \cdot \Big(1 - \frac{\lambda}{n}\Big)^{-k} \;\longrightarrow\; \frac{\lambda^k}{k!}\, e^{-\lambda}.(kn​)(nλ​)k(1−nλ​)n−k=k!λk​⋅nkn(n−1)⋯(n−k+1)​⋅(1−nλ​)n⋅(1−nλ​)−k⟶k!λk​e−λ.

The second factor tends to 1, since it is a product of kkk factors each close to 1; the third tends to e−λe^{-\lambda}e−λ; the fourth tends to 1. For λ=2\lambda = 2λ=2 and k=2k = 2k=2 the binomial probabilities are 0.30200.30200.3020 for n=10n = 10n=10, 0.27340.27340.2734 for n=100n = 100n=100 and 0.27090.27090.2709 for n=1,000n = 1{,}000n=1,000, approaching the Poisson value 0.27070.27070.2707.

The exponential distribution has no memory. Its tail is P(X>x)=e−θx\mathbb{P}(X > x) = e^{-\theta x}P(X>x)=e−θx, so P(X>s+t)=e−θs e−θt=P(X>s) P(X>t)\mathbb{P}(X > s + t) = e^{-\theta s}\, e^{-\theta t} = \mathbb{P}(X > s)\, \mathbb{P}(X > t)P(X>s+t)=e−θse−θt=P(X>s)P(X>t). In words: among the waits longer than sss, the share that last more than ttt further is P(X>s+t)/P(X>s)=P(X>t)\mathbb{P}(X > s + t) / \mathbb{P}(X > s) = \mathbb{P}(X > t)P(X>s+t)/P(X>s)=P(X>t), the same share as for a wait that has just begun. A wait that has already lasted sss minutes is no closer to its end. With mean 2, s=1s = 1s=1 and t=2t = 2t=2, P(X>3)=0.2231\mathbb{P}(X > 3) = 0.2231P(X>3)=0.2231, and indeed P(X>1) P(X>2)=0.6065⋅0.3679=0.2231\mathbb{P}(X > 1)\,\mathbb{P}(X > 2) = 0.6065 \cdot 0.3679 = 0.2231P(X>1)P(X>2)=0.6065⋅0.3679=0.2231.

Quantiles

Turning FFF around answers a different question: below which value does XXX stay with probability uuu? When FFF is continuous and strictly increasing, there is exactly one such value, the inverse function F−1(u)F^{-1}(u)F−1(u). For the exponential distribution with mean 1, F−1(u)=−ln⁡(1−u)F^{-1}(u) = -\ln(1 - u)F−1(u)=−ln(1−u), so the median, u=12u = \tfrac12u=21​, is ln⁡2=0.6931\ln 2 = 0.6931ln2=0.6931, and the quartiles u=14u = \tfrac14u=41​ and u=34u = \tfrac34u=43​ are 0.28770.28770.2877 and 1.38631.38631.3863.

Jumps and flat parts break this. On the die, no xxx has F(x)=0.4F(x) = 0.4F(x)=0.4, because FFF jumps from 13\tfrac1331​ to 12\tfrac1221​ at 3. For the Cantor variable, every xxx in [13,23][\tfrac13, \tfrac23][31​,32​] has F(x)=12F(x) = \tfrac12F(x)=21​. The quantile function repairs both with the smallest suitable value:

F−1(u)=inf⁡{x∈R:F(x)≥u},0<u<1.F^{-1}(u) = \inf\{x \in \mathbb{R} : F(x) \ge u\}, \qquad 0 < u < 1.F−1(u)=inf{x∈R:F(x)≥u},0<u<1.

In words: the first point at which XXX has stayed below with probability at least uuu. The infimum is needed because the set of such xxx has no smallest element in general, and it is a minimum here because FFF is right-continuous: the set {x:F(x)≥u}\{x : F(x) \ge u\}{x:F(x)≥u} contains its left end, so F(F−1(u))≥uF(F^{-1}(u)) \ge uF(F−1(u))≥u. For the die, u=0.4u = 0.4u=0.4 gives {x:F(x)≥0.4}=[3,∞)\{x : F(x) \ge 0.4\} = [3, \infty){x:F(x)≥0.4}=[3,∞) and so F−1(0.4)=3F^{-1}(0.4) = 3F−1(0.4)=3. In fact every u∈(13,12]u \in (\tfrac13, \tfrac12]u∈(31​,21​] gives 3, and F−1(0.5)=3F^{-1}(0.5) = 3F−1(0.5)=3 while F−1(0.51)=4F^{-1}(0.51) = 4F−1(0.51)=4. For the Cantor variable F−1(12)=13F^{-1}(\tfrac12) = \tfrac13F−1(21​)=31​, and the quantile function skips the whole gap up to 23\tfrac2332​.

For the traffic light, F−1(u)=0F^{-1}(u) = 0F−1(u)=0 for every u≤0.7u \le 0.7u≤0.7, because the atom at 0 already makes F(0)=0.7≥uF(0) = 0.7 \ge uF(0)=0.7≥u. Above 0.70.70.7, solving 0.7+0.3(1−e−x/2)=u0.7 + 0.3(1 - e^{-x/2}) = u0.7+0.3(1−e−x/2)=u gives F−1(u)=−2ln⁡((1−u)/0.3)F^{-1}(u) = -2\ln\big((1 - u)/0.3\big)F−1(u)=−2ln((1−u)/0.3), so F−1(0.85)=−2ln⁡0.5=2ln⁡2=1.3863F^{-1}(0.85) = -2 \ln 0.5 = 2 \ln 2 = 1.3863F−1(0.85)=−2ln0.5=2ln2=1.3863 minutes. The median is F−1(0.5)=0F^{-1}(0.5) = 0F−1(0.5)=0: more than half of the drivers do not wait.

The one fact about F−1F^{-1}F−1 that matters below is an equivalence for every xxx and every u∈(0,1)u \in (0, 1)u∈(0,1):

F−1(u)≤x  ⟺  u≤F(x).F^{-1}(u) \le x \iff u \le F(x).F−1(u)≤x⟺u≤F(x).

If u≤F(x)u \le F(x)u≤F(x), then xxx belongs to the set whose infimum defines F−1(u)F^{-1}(u)F−1(u), so F−1(u)≤xF^{-1}(u) \le xF−1(u)≤x. If F−1(u)≤xF^{-1}(u) \le xF−1(u)≤x, then F(x)≥F(F−1(u))≥uF(x) \ge F(F^{-1}(u)) \ge uF(x)≥F(F−1(u))≥u, using that FFF is non-decreasing and that F(F−1(u))≥uF(F^{-1}(u)) \ge uF(F−1(u))≥u. The equivalence shows that F−1F^{-1}F−1 is non-decreasing, hence measurable by "Measurable functions".

Inverse transform sampling

The quantile function also runs in the other direction. Let UUU be uniform on (0,1)(0, 1)(0,1), the number ω\omegaω of the uniform model, and let FFF be any distribution function. Then X=F−1(U)X = F^{-1}(U)X=F−1(U) has distribution function FFF:

P(F−1(U)≤x)=P(U≤F(x))=F(x).\mathbb{P}\big(F^{-1}(U) \le x\big) = \mathbb{P}\big(U \le F(x)\big) = F(x).P(F−1(U)≤x)=P(U≤F(x))=F(x).

The first equality is the equivalence above, and the second holds because P(U≤c)=c\mathbb{P}(U \le c) = cP(U≤c)=c for c∈[0,1]c \in [0, 1]c∈[0,1]. By section 3, FFF then determines the distribution of XXX, and this also proves the converse promised there: every function with the four properties is a distribution function. In sand terms, the uniform interval (0,1)(0, 1)(0,1) is cut into pieces and mapped onto the number line. A jump of size qqq in FFF collects a piece of uuu-values of length qqq and sends all of them to one value, and a flat part of FFF is skipped.

Examples show how it works. For the die, F−1(u)=⌈6u⌉F^{-1}(u) = \lceil 6u \rceilF−1(u)=⌈6u⌉, and each face receives a piece of length 16\tfrac1661​ of the uuu-axis. For the exponential distribution with mean 2, F(x)=1−e−x/2F(x) = 1 - e^{-x/2}F(x)=1−e−x/2, so F−1(u)=−2ln⁡(1−u)F^{-1}(u) = -2\ln(1 - u)F−1(u)=−2ln(1−u), and u=0.9u = 0.9u=0.9 gives −2ln⁡0.1=4.605-2 \ln 0.1 = 4.605−2ln0.1=4.605 minutes. For the traffic light, u≤0.7u \le 0.7u≤0.7 gives a wait of 000 and u=0.85u = 0.85u=0.85 gives 1.3861.3861.386 minutes. A computer produces uniform numbers and nothing else, and this is how every other distribution is made from them.

The figure shows one uniform number at a time. Choose a distribution and move uuu on the vertical axis: the guide runs across to FFF and down to the value F−1(u)F^{-1}(u)F−1(u), and the readouts show that value and the probability of the atom there. The histogram collects 1,000 draws F−1(U)F^{-1}(U)F−1(U), each from its own uniform number, and the last two readouts compare their average with the exact mean. At the default, the exponential distribution and u=0.5u = 0.5u=0.5, the value is F−1(0.5)=ln⁡2=0.693F^{-1}(0.5) = \ln 2 = 0.693F−1(0.5)=ln2=0.693, there is no atom, and the average of the 1,000 draws is 1.0491.0491.049 against the exact mean 111. Switch to the traffic light: at u=0.5u = 0.5u=0.5 the guide hits the jump, the value is 000 and the atom is 0.70.70.7; of the 1,000 draws, 674 are exactly 000. On the die, u=0.5u = 0.5u=0.5 gives the value 333 with atom 16=0.167\tfrac16 = 0.16761​=0.167.

A uniform draw pushed through the quantile functionOpen in Random Variables
0.50
0.010.99
u
0.50
F⁻¹(u)
0.693
P(X = F⁻¹(u))
0.000
Mean of 1,000 draws
1.049
Exact mean
1.000

Each draw is F⁻¹ of a uniform number: a jump of F collects a whole interval of u, a flat part is skipped.

If FFF is continuous, the step also runs backwards: F(X)F(X)F(X) is uniform on (0,1)(0, 1)(0,1), because P(F(X)≤u)=P(X≤F−1(u))=F(F−1(u))=u\mathbb{P}(F(X) \le u) = \mathbb{P}(X \le F^{-1}(u)) = F(F^{-1}(u)) = uP(F(X)≤u)=P(X≤F−1(u))=F(F−1(u))=u. This probability integral transform fails when FFF has jumps: for the traffic light, F(X)=0.7F(X) = 0.7F(X)=0.7 with probability 0.70.70.7.

Worked example

Waiting at a traffic light

  1. The atom at zero, the jump of FFF there:

    P(X=0)=0.7\displaystyle \mathbb{P}(X = 0) = 0.7P(X=0)=0.7=0.7
  2. The distribution function at 1:

    F(1)=0.7+0.3 (1−e−1/2)\displaystyle F(1) = 0.7 + 0.3\,(1 - e^{-1/2})F(1)=0.7+0.3(1−e−1/2)=0.818041
  3. The distribution function at 4:

    F(4)=0.7+0.3 (1−e−2)\displaystyle F(4) = 0.7 + 0.3\,(1 - e^{-2})F(4)=0.7+0.3(1−e−2)=0.959399
  4. The probability of waiting more than 1 and at most 4 minutes:

    P(1<X≤4)=F(4)−F(1)\displaystyle \mathbb{P}(1 < X \le 4) = F(4) - F(1)P(1<X≤4)=F(4)−F(1)=0.141359
  5. The probability of waiting more than 2 minutes, from the tail:

    P(X>2)=1−F(2)=0.3 e−1\displaystyle \mathbb{P}(X > 2) = 1 - F(2) = 0.3\,e^{-1}P(X>2)=1−F(2)=0.3e−1=0.110364
  6. The quantile at 0.85 lies above the atom, so solve F(x)=0.85F(x) = 0.85F(x)=0.85:

    F−1(0.85)=−2ln⁡((1−0.85)/0.3)=2ln⁡2\displaystyle F^{-1}(0.85) = -2\ln\big((1 - 0.85)/0.3\big) = 2\ln 2F−1(0.85)=−2ln((1−0.85)/0.3)=2ln2=1.386294
  7. The median: already F(0)=0.7≥0.5F(0) = 0.7 \ge 0.5F(0)=0.7≥0.5, so

    F−1(0.5)=0\displaystyle F^{-1}(0.5) = 0F−1(0.5)=0=0

Means: a first look

The last two readouts of the figure compare an average of draws with an exact number. The average is easy to compute from draws: add them up and divide by 1,000. The exact number is what such averages settle on as the number of draws grows. For the die it is (1+2+⋯+6)/6=3.5(1 + 2 + \cdots + 6)/6 = 3.5(1+2+⋯+6)/6=3.5, and the 1,000 draws of the figure averaged 3.6113.6113.611. For the traffic light it is 0.7⋅0+0.3⋅2=0.60.7 \cdot 0 + 0.3 \cdot 2 = 0.60.7⋅0+0.3⋅2=0.6 minutes, since 70% of the drivers wait nothing and the others wait 2 minutes on average, and the draws averaged 0.6350.6350.635. For the exponential distribution with mean 1 it is 111, against 1.0491.0491.049. The gap shrinks as the number of draws grows.

Making this precise needs an integral against PX\mathbb{P}_XPX​, and this is the topic of the next lesson, "Expectation, variance and inequalities". It defines the mean as an integral over Ω\OmegaΩ, shows how to compute it from the distribution function, a density or a mixed law, and measures how widely draws scatter around it.

Summary

  • A random variable is a measurable function on a probability space; its distribution PX(B)=P(X∈B)\mathbb{P}_X(B) = \mathbb{P}(X \in B)PX​(B)=P(X∈B) is the image measure, a probability measure on the Borel sets that forgets which outcome gave which value.
  • The distribution function F(x)=P(X≤x)F(x) = \mathbb{P}(X \le x)F(x)=P(X≤x) is non-decreasing and right-continuous with limits 000 and 111, and it determines the distribution: P(a<X≤b)=F(b)−F(a)\mathbb{P}(a < X \le b) = F(b) - F(a)P(a<X≤b)=F(b)−F(a) and P(X=x)=F(x)−F(x−)\mathbb{P}(X = x) = F(x) - F(x-)P(X=x)=F(x)−F(x−).
  • Jumps of FFF are atoms and slopes are densities; a distribution can be discrete, have a density, be mixed like the traffic light, or, rarely, be continuous without a density like the Cantor function.
  • The common distributions, Bernoulli, binomial, geometric, Poisson, uniform, exponential and normal, each come from a short story, and the Poisson distribution is the limit of binomial(nnn, λ/n\lambda/nλ/n).
  • The quantile function F−1(u)=inf⁡{x:F(x)≥u}F^{-1}(u) = \inf\{x : F(x) \ge u\}F−1(u)=inf{x:F(x)≥u} satisfies F−1(u)≤x  ⟺  u≤F(x)F^{-1}(u) \le x \iff u \le F(x)F−1(u)≤x⟺u≤F(x), so F−1(U)F^{-1}(U)F−1(U) has distribution function FFF for a uniform UUU: inverse transform sampling.
Try itOpen the random variables lab
Previous · 07Probability spaces and Kolmogorov's axiomsNext · 09Expectation, variance and inequalities
Connections

Random variables and their distributions

Open the full graph
Builds on
05.07Probability spaces and Kolmogorov's axioms05.04Measurable functions05.01Measuring the size of sets05.03Lebesgue measure and null sets05.02σ-algebras and Borel sets
Leads to
05.09Expectation, variance and inequalities05.10Independence and product measures05.11Modes of convergence and the law of large numbers05.13Measure theory in option pricing
See it in the knowledge graph
Labs for this lesson
Random Variables