Quant Sandbox
DerivativesPortfolio & RiskFixed IncomeCorporate FinanceStochastic ModelsGuide
Guide
Derivatives pricing
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 rho13Implied volatility and the volatility smile14Stochastic volatility and the Heston model15Static replication: Breeden–Litzenberger and Carr–Madan16Exotic options: barriers, Asians and digitals
Portfolio & risk
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 risk08Value at Risk and expected shortfall
Fixed income
01Bond prices and yields02Duration and convexity03Immunization and duration matching04Spot rates, forward rates and the yield curve05Bond futures and the cheapest-to-deliver06Interest rate swaps07Callable bonds and negative convexity08Credit risk: default probabilities and credit spreads
Corporate finance
01Interest, compounding and discounting02Annuities, perpetuities and loan amortization03Net present value and internal rate of return04The weighted average cost of capital05Capital structure and the Modigliani–Miller theorems06Discounted cash flow valuation07Relative valuation with multiples08Real options: the value of flexibility
Stochastic models
01Random walks and Brownian motion02Probability spaces, σ-algebras and random variables03Filtrations, adapted processes and stopping times04Conditional expectation and martingales05Properties of Brownian motion06The reflection principle and first passage times07The Brownian bridge08The Itô integral09Itô's lemma10Kolmogorov equations and the Feynman–Kac formula11Change of measure and Girsanov's theorem12Monte Carlo option pricing13Simulating SDEs: the Euler–Maruyama scheme14Mean reversion: Ornstein–Uhlenbeck and Vasicek15Jumps and the Merton jump-diffusion model
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.

Guide/Stochastic models

Probability spaces, σ-algebras and random variables

Lesson 2 of 15 · 1 min read

The lesson "Random walks and Brownian motion" used probabilities, expectations and independence freely. The continuous-time models that follow need these words to have exact meanings, because they talk about information, about events that depend on a whole path, and about averages conditional on what is known. This lesson sets up the measure-theoretic framework: the sample space, σ-algebras, probability measures and random variables. A fair die serves as the running example throughout, and the last section previews conditional expectation, the subject of the lesson after next.

Sample space and events

A random experiment is modelled by a set Ω\OmegaΩ, the sample space, whose elements ω∈Ω\omega \in \Omegaω∈Ω are the possible outcomes. For one roll of a die, Ω={1,2,3,4,5,6}\Omega = \{1, 2, 3, 4, 5, 6\}Ω={1,2,3,4,5,6}. For the coin-flip walk of the previous lesson with nnn tosses, Ω={H,T}n\Omega = \{H, T\}^nΩ={H,T}n, and one ω\omegaω is a whole sequence of tosses. For Brownian motion, one ω\omegaω is a whole continuous path.

An event is a subset A⊆ΩA \subseteq \OmegaA⊆Ω: the event occurs if the realised outcome ω\omegaω lies in AAA. The event "the die shows an even number" is {2,4,6}\{2, 4, 6\}{2,4,6}. Set operations translate logic: A∩BA \cap BA∩B is "AAA and BBB", A∪BA \cup BA∪B is "AAA or BBB", the complement Ac=Ω∖AA^c = \Omega \setminus AAc=Ω∖A is "not AAA".

σ-algebras

We do not assign a probability to every subset of Ω\OmegaΩ. Instead we fix a collection F\mathcal{F}F of subsets, the events we are allowed to ask about, and require it to be closed under the logical operations. A collection F\mathcal{F}F of subsets of Ω\OmegaΩ is a σ-algebra if

(i) Ω∈F,(ii) A∈F⇒Ac∈F,(iii) A1,A2,…∈F⇒⋃n=1∞An∈F.\text{(i) } \Omega \in \mathcal{F}, \qquad \text{(ii) } A \in \mathcal{F} \Rightarrow A^c \in \mathcal{F}, \qquad \text{(iii) } A_1, A_2, \ldots \in \mathcal{F} \Rightarrow \bigcup_{n=1}^{\infty} A_n \in \mathcal{F}.(i) Ω∈F,(ii) A∈F⇒Ac∈F,(iii) A1​,A2​,…∈F⇒n=1⋃∞​An​∈F.

Two consequences follow at once. From (i) and (ii), ∅=Ωc∈F\emptyset = \Omega^c \in \mathcal{F}∅=Ωc∈F. From (ii), (iii) and De Morgan's law ⋂nAn=(⋃nAnc)c\bigcap_n A_n = \big(\bigcup_n A_n^c\big)^c⋂n​An​=(⋃n​Anc​)c, countable intersections of events are events. The "σ" refers to the countable unions in (iii); they are needed for statements about infinitely many times, such as "the walk eventually exceeds 10", which is ⋃n{Wn>10}\bigcup_{n} \{W_n > 10\}⋃n​{Wn​>10}.

On the die, three σ-algebras will recur:

  • the trivial σ-algebra {∅,Ω}\{\emptyset, \Omega\}{∅,Ω}, which contains no information about the roll;
  • the parity σ-algebra {∅,{1,3,5},{2,4,6},Ω}\{\emptyset, \{1,3,5\}, \{2,4,6\}, \Omega\}{∅,{1,3,5},{2,4,6},Ω}, which can tell odd from even and nothing more;
  • the power set 2Ω2^{\Omega}2Ω of all 26=642^6 = 6426=64 subsets, which identifies the roll exactly.

Two reasons justify the restriction to a σ-algebra. The first is technical: on Ω=[0,1]\Omega = [0, 1]Ω=[0,1] there is no way to assign a "length" to every subset that is countably additive and unchanged by translation (Vitali's construction), so uncountable sample spaces force us to leave some sets out. The second is the reason that matters in finance: a σ-algebra smaller than 2Ω2^\Omega2Ω models partial information. An observer whose information is the parity σ-algebra can answer "was it even?" but not "was it a 6?".

For any collection C\mathcal{C}C of subsets, the intersection of all σ-algebras containing C\mathcal{C}C is again a σ-algebra, the smallest one containing C\mathcal{C}C. It is written σ(C)\sigma(\mathcal{C})σ(C) and called the σ-algebra generated by C\mathcal{C}C. On R\mathbb{R}R, the σ-algebra generated by the open intervals is the Borel σ-algebra B(R)\mathcal{B}(\mathbb{R})B(R). It contains every interval, every open and closed set and everything built from them by countable operations; we use it without constructing it further.

Probability measures

A probability measure on (Ω,F)(\Omega, \mathcal{F})(Ω,F) is a function P:F→[0,1]\mathbb{P} : \mathcal{F} \to [0, 1]P:F→[0,1] with P(Ω)=1\mathbb{P}(\Omega) = 1P(Ω)=1 that is countably additive: for pairwise disjoint A1,A2,…∈FA_1, A_2, \ldots \in \mathcal{F}A1​,A2​,…∈F,

P(⋃n=1∞An)=∑n=1∞P(An).\mathbb{P}\Big(\bigcup_{n=1}^{\infty} A_n\Big) = \sum_{n=1}^{\infty} \mathbb{P}(A_n).P(n=1⋃∞​An​)=n=1∑∞​P(An​).

The triple (Ω,F,P)(\Omega, \mathcal{F}, \mathbb{P})(Ω,F,P) is a probability space. The familiar rules are consequences: P(Ac)=1−P(A)\mathbb{P}(A^c) = 1 - \mathbb{P}(A)P(Ac)=1−P(A) (since AAA and AcA^cAc are disjoint with union Ω\OmegaΩ), and A⊆BA \subseteq BA⊆B implies P(A)≤P(B)\mathbb{P}(A) \le \mathbb{P}(B)P(A)≤P(B) (since B=A∪(B∖A)B = A \cup (B \setminus A)B=A∪(B∖A)). For the fair die, F=2Ω\mathcal{F} = 2^\OmegaF=2Ω and P(A)=∣A∣/6\mathbb{P}(A) = |A|/6P(A)=∣A∣/6. The same σ-algebra can carry several measures, which is how the real-world measure P\mathbb{P}P and the risk-neutral measure Q\mathbb{Q}Q coexist on one sample space.

Random variables

A random variable is a number determined by the outcome, X:Ω→RX : \Omega \to \mathbb{R}X:Ω→R, with one requirement: every question of the form "is X≤xX \le xX≤x?" must be an event, so that it has a probability. Formally, XXX is $\mathcal{F}$-measurable if

{X≤x}={ω∈Ω:X(ω)≤x}∈Ffor every x∈R.\{X \le x\} = \{\omega \in \Omega : X(\omega) \le x\} \in \mathcal{F} \quad \text{for every } x \in \mathbb{R}.{X≤x}={ω∈Ω:X(ω)≤x}∈Ffor every x∈R.

This is equivalent to X−1(B)∈FX^{-1}(B) \in \mathcal{F}X−1(B)∈F for every Borel set BBB, because the sets BBB with X−1(B)∈FX^{-1}(B) \in \mathcal{F}X−1(B)∈F form a σ-algebra that contains every half-line (−∞,x](-\infty, x](−∞,x], and these half-lines generate B(R)\mathcal{B}(\mathbb{R})B(R).

Measurability depends on the σ-algebra. On the die take X(ω)=1{ω≥5}X(\omega) = \mathbf{1}\{\omega \ge 5\}X(ω)=1{ω≥5}, which is 1 on {5,6}\{5, 6\}{5,6} and 0 otherwise. Then {X≤0}={1,2,3,4}\{X \le 0\} = \{1,2,3,4\}{X≤0}={1,2,3,4}, which is not in the parity σ-algebra, so XXX is not parity-measurable: knowing only the parity, you cannot tell whether X=1X = 1X=1.

The σ-algebra generated by a random variable

The σ-algebra generated by $X$ is the collection of all events that can be decided by observing XXX:

σ(X)={X−1(B):B∈B(R)}.\sigma(X) = \{ X^{-1}(B) : B \in \mathcal{B}(\mathbb{R}) \}.σ(X)={X−1(B):B∈B(R)}.

It is the smallest σ-algebra for which XXX is measurable. Read it as the list of questions that XXX answers. For X(ω)=ω mod 2X(\omega) = \omega \bmod 2X(ω)=ωmod2 on the die, σ(X)\sigma(X)σ(X) is the parity σ-algebra. The precise sense in which σ(X)\sigma(X)σ(X) is "the information in XXX" is the Doob–Dynkin lemma: a random variable YYY is σ(X)\sigma(X)σ(X)-measurable if and only if Y=f(X)Y = f(X)Y=f(X) for some Borel function fff. Knowing σ(X)\sigma(X)σ(X) lets you compute exactly the functions of XXX.

Finite sample spaces and partitions

When Ω\OmegaΩ is finite, every σ-algebra has a simple shape. For ω∈Ω\omega \in \Omegaω∈Ω let A(ω)A(\omega)A(ω) be the intersection of all events in G\mathcal{G}G that contain ω\omegaω; it is a finite intersection, so A(ω)∈GA(\omega) \in \mathcal{G}A(ω)∈G. These sets are called the atoms of G\mathcal{G}G. Two atoms are either equal or disjoint: if ω′∉A(ω)\omega' \notin A(\omega)ω′∈/A(ω), some C∈GC \in \mathcal{G}C∈G contains ω\omegaω but not ω′\omega'ω′, so CcC^cCc contains ω′\omega'ω′ and A(ω′)⊆CcA(\omega') \subseteq C^cA(ω′)⊆Cc is disjoint from A(ω)⊆CA(\omega) \subseteq CA(ω)⊆C. Hence the atoms partition Ω\OmegaΩ, and every event of G\mathcal{G}G is the union of the atoms of its points.

On a finite Ω\OmegaΩ, a σ-algebra G\mathcal{G}G is the same thing as a partition of Ω\OmegaΩ into mmm atoms: the events of G\mathcal{G}G are exactly the unions of atoms, so there are 2m2^m2m of them. A random variable is G\mathcal{G}G-measurable if and only if it is constant on each atom.

The parity σ-algebra has atoms {1,3,5}\{1,3,5\}{1,3,5} and {2,4,6}\{2,4,6\}{2,4,6}, so 22=42^2 = 422=4 events. The partition into pairs {1,2},{3,4},{5,6}\{1,2\}, \{3,4\}, \{5,6\}{1,2},{3,4},{5,6} gives 23=82^3 = 823=8 events, and 1{ω≥5}\mathbf{1}\{\omega \ge 5\}1{ω≥5} is measurable for it, being constant on each pair. The power set has six atoms and 26=642^6 = 6426=64 events.

Independence

Two events are independent if P(A∩B)=P(A) P(B)\mathbb{P}(A \cap B) = \mathbb{P}(A)\,\mathbb{P}(B)P(A∩B)=P(A)P(B). Two σ-algebras G\mathcal{G}G and H\mathcal{H}H are independent if this holds for every A∈GA \in \mathcal{G}A∈G and every B∈HB \in \mathcal{H}B∈H, and random variables XXX and YYY are independent if σ(X)\sigma(X)σ(X) and σ(Y)\sigma(Y)σ(Y) are. In words: learning the answer to any question about XXX does not change the probabilities of any question about YYY.

Example on the fair die. Parity and σ(1{ω≥5})\sigma(\mathbf{1}\{\omega \ge 5\})σ(1{ω≥5}) are independent: the four non-trivial pairs give

P({1,3,5}∩{5,6})=16=12⋅13,P({1,3,5}∩{1,2,3,4})=13=12⋅23,\mathbb{P}(\{1,3,5\} \cap \{5,6\}) = \tfrac16 = \tfrac12 \cdot \tfrac13, \qquad \mathbb{P}(\{1,3,5\} \cap \{1,2,3,4\}) = \tfrac13 = \tfrac12 \cdot \tfrac23,P({1,3,5}∩{5,6})=61​=21​⋅31​,P({1,3,5}∩{1,2,3,4})=31​=21​⋅32​,

and the same for the even numbers, while pairs involving ∅\emptyset∅ or Ω\OmegaΩ hold trivially. Parity and low–high are not independent: P({1,3,5}∩{1,2,3})=13\mathbb{P}(\{1,3,5\} \cap \{1,2,3\}) = \tfrac13P({1,3,5}∩{1,2,3})=31​, but 12⋅12=14\tfrac12 \cdot \tfrac12 = \tfrac1421​⋅21​=41​.

Expectation

On a finite space the expectation is the probability-weighted average, E[X]=∑ωX(ω) P({ω})\mathbb{E}[X] = \sum_{\omega} X(\omega)\,\mathbb{P}(\{\omega\})E[X]=∑ω​X(ω)P({ω}). On a general space it is the Lebesgue integral E[X]=∫ΩX dP\mathbb{E}[X] = \int_\Omega X\, d\mathbb{P}E[X]=∫Ω​XdP, defined first for variables taking finitely many values and then by monotone limits; it keeps the rules you know: linearity, E[1A]=P(A)\mathbb{E}[\mathbf{1}_A] = \mathbb{P}(A)E[1A​]=P(A), and E[XY]=E[X] E[Y]\mathbb{E}[XY] = \mathbb{E}[X]\,\mathbb{E}[Y]E[XY]=E[X]E[Y] for independent integrable X,YX, YX,Y. For the die with X(ω)=ωX(\omega) = \omegaX(ω)=ω,

E[X]=1+2+⋯+66=3.5,E[X2]=916,Var⁡(X)=916−3.52=3512≈2.917.\mathbb{E}[X] = \frac{1 + 2 + \cdots + 6}{6} = 3.5, \qquad \mathbb{E}[X^2] = \frac{91}{6}, \qquad \operatorname{Var}(X) = \frac{91}{6} - 3.5^2 = \frac{35}{12} \approx 2.917.E[X]=61+2+⋯+6​=3.5,E[X2]=691​,Var(X)=691​−3.52=1235​≈2.917.

Conditional expectation as block averages

Given a σ-algebra G\mathcal{G}G on a finite Ω\OmegaΩ whose atoms all have positive probability, the conditional expectation E[X∣G]\mathbb{E}[X \mid \mathcal{G}]E[X∣G] is the random variable that, on each atom AAA, equals the average of XXX over AAA:

E[X∣G](ω)=E[X 1A]P(A)for ω∈A.\mathbb{E}[X \mid \mathcal{G}](\omega) = \frac{\mathbb{E}[X\,\mathbf{1}_A]}{\mathbb{P}(A)} \quad \text{for } \omega \in A.E[X∣G](ω)=P(A)E[X1A​]​for ω∈A.

It is the best guess of XXX by an observer who knows which atom occurred. It is G\mathcal{G}G-measurable, and it has the same average as XXX on every event of G\mathcal{G}G: E[E[X∣G] 1A]=E[X 1A]\mathbb{E}\big[\mathbb{E}[X \mid \mathcal{G}]\,\mathbf{1}_A\big] = \mathbb{E}[X\,\mathbf{1}_A]E[E[X∣G]1A​]=E[X1A​] for A∈GA \in \mathcal{G}A∈G. These two properties are the definition used on general spaces, which the lesson "Conditional expectation and martingales" takes up. Averaging inside blocks removes variation, and the law of total variance makes this exact:

Var⁡(X)=Var⁡(E[X∣G])+E[Var⁡(X∣G)]  ≥  Var⁡(E[X∣G]).\operatorname{Var}(X) = \operatorname{Var}\big(\mathbb{E}[X \mid \mathcal{G}]\big) + \mathbb{E}\big[\operatorname{Var}(X \mid \mathcal{G})\big] \;\ge\; \operatorname{Var}\big(\mathbb{E}[X \mid \mathcal{G}]\big).Var(X)=Var(E[X∣G])+E[Var(X∣G)]≥Var(E[X∣G]).

Worked example with X(ω)=ωX(\omega) = \omegaX(ω)=ω. With parity information, E[X∣G]\mathbb{E}[X \mid \mathcal{G}]E[X∣G] is 333 on the odd numbers and 444 on the even ones, so its variance is 0.250.250.25. With low–high it is 222 or 555, variance 2.252.252.25. With pairs it is 1.51.51.5, 3.53.53.5 or 5.55.55.5, variance 8/3≈2.6678/3 \approx 2.6678/3≈2.667. With full information it is XXX itself, variance 35/1235/1235/12; with no information it is the constant 3.53.53.5, variance 000.

The figure shows the six outcomes as tiles coloured by the atoms of the chosen information G\mathcal{G}G, each tile listing ω\omegaω, X(ω)X(\omega)X(ω) and the block average E[X∣G](ω)\mathbb{E}[X \mid \mathcal{G}](\omega)E[X∣G](ω). Choose the information (none, parity, low–high, pairs, full) and the random variable (ω\omegaω, ω2\omega^2ω2 or 1{ω≥5}\mathbf{1}\{\omega \ge 5\}1{ω≥5}). The readouts give the number of events 2blocks2^{\text{blocks}}2blocks, E[X]\mathbb{E}[X]E[X], Var⁡(X)\operatorname{Var}(X)Var(X) and Var⁡(E[X∣G])\operatorname{Var}(\mathbb{E}[X \mid \mathcal{G}])Var(E[X∣G]). Check that the last never exceeds Var⁡(X)\operatorname{Var}(X)Var(X) and equals it with full information. With 1{ω≥5}\mathbf{1}\{\omega \ge 5\}1{ω≥5} and parity it is 000: the information is independent of XXX and does not improve the guess.

Conditional expectation on a dieOpen in Stochastic Learning Studio →
  1. ω = 1X = 1E[X | 𝒢] = 11.67
  2. ω = 2X = 4E[X | 𝒢] = 18.67
  3. ω = 3X = 9E[X | 𝒢] = 11.67
  4. ω = 4X = 16E[X | 𝒢] = 18.67
  5. ω = 5X = 25E[X | 𝒢] = 11.67
  6. ω = 6X = 36E[X | 𝒢] = 18.67
Events in 𝒢
4
E[X]
15.167
Var X
149.139
Var E[X | 𝒢]
12.250

Summary

  • A probability space (Ω,F,P)(\Omega, \mathcal{F}, \mathbb{P})(Ω,F,P) consists of outcomes, a σ-algebra of events closed under complements and countable unions, and a countably additive measure with P(Ω)=1\mathbb{P}(\Omega) = 1P(Ω)=1.
  • A random variable is an F\mathcal{F}F-measurable map: every event {X≤x}\{X \le x\}{X≤x} belongs to F\mathcal{F}F. Its generated σ-algebra σ(X)\sigma(X)σ(X) collects the questions XXX answers, and σ(X)\sigma(X)σ(X)-measurable variables are the functions of XXX.
  • On a finite Ω\OmegaΩ a σ-algebra is a partition into mmm atoms with 2m2^m2m events, and measurable means constant on atoms.
  • Independence of σ-algebras means every event of one is independent of every event of the other.
  • Conditional expectation on a partition is the block average; it is a coarser variable with Var⁡(E[X∣G])≤Var⁡(X)\operatorname{Var}(\mathbb{E}[X \mid \mathcal{G}]) \le \operatorname{Var}(X)Var(E[X∣G])≤Var(X).

The next lesson, "Filtrations, adapted processes and stopping times", lets the σ-algebra grow with time to model information that accumulates as prices are observed.

Try itExplore random walks and Brownian motion in the Stochastic Models studio →
3 questions on this lesson at the end of the series →
← PreviousRandom walks and Brownian motionNext →Filtrations, adapted processes and stopping times
Connections
Probability spaces, σ-algebras and rando…
Open the full graph →
Labs for this lesson
Stochastic Learning Studio