C. Probability, Concentration & Information
Random variables, Gaussians, high-probability guarantees, martingales, KL divergence and risk measures
This primer assumes:
- A first course in linear algebra (matrices, inverses, determinants, eigenvalues) and single-variable calculus (derivatives, integrals including improper ones, Taylor series, $e^x$ and $\ln x$) (baseline)
- Positive semidefinite matrices & quadratic forms (Primer A)
- Block matrices, the Schur complement, determinants and log det (Primer A)
- Sets, quantifiers and why their order matters (Primer 0)
- Convex functions and Jensen's inequality (Primer B)
- Sequences, limits, geometric and telescoping series (Primer 0)
- Supremum, infimum and the extended reals (Primer 0)
- Gradients and Taylor expansions (Primer B)
No previous probability course is needed. Start with events and finite probability tables, then conditioning and transitions. Gaussian formulas use the matrix review in Primer A; the probability language is introduced here. Treat the measure-theory background and longer proofs as a second pass after you can do the Easy and Medium problems.
Begin with the three readiness checks. If a check is difficult, use its review link and worked answer, then try again without looking. After each section, try its Easy problem, use the separate hint if needed, and continue to Medium once you can explain the steps. Hard problems combine ideas or expose a common mistake. Keep the answers closed on your first attempt.
- Core language: Events, conditional averages and transitions. Section practice: 1, 2, 3.
- Confidence tools: Gaussian conditioning, concentration and simultaneous statements. Section practice: 4, 5, 6.
- Next layer: Adaptive data, information, tail risk and testing. Section practice: 7, 8, 9, 10.
The original cumulative exercises combine sections after this guided practice. Finish a study session by explaining one worked solution in your own words, then changing a number and solving it again.
Readiness checks — a short prerequisite refresher
These checks are diagnostic, with the needed calculation explained in each answer. A gap tells you where to review; it is not a reason to skip this primer.
Exercise C.R1 — Readiness: Translate a complement
An event $A$ has probability $0.15$. What is the probability that it does not occur? If $A$ means a constraint is violated, which event describes no violation?
Review if needed: sets and complements.
Show hint
Show worked solution
The complement $A^c$ contains exactly the outcomes outside $A$. Since the probabilities of these disjoint events add to $1$, $\mathbb P(A^c)=1-0.15=0.85$. If $A$ means violation, $A^c$ means no violation. This statement concerns the specified event; a guarantee across many times requires defining an event for the whole trajectory.
Exercise C.R2 — Readiness: Build a weighted average
A quantity is $2$ in one quarter of cases and $6$ in the other three quarters. Find the average. Why is simply adding $2+6$ incorrect?
Review if needed: sums and weights.
Show hint
Show worked solution
In four representative cases the values are $2,6,6,6$, whose average is $(2+6+6+6)/4=5$. Equivalently, $2(1/4)+6(3/4)=5$. Adding $2+6$ ignores both frequencies and the division by the number of cases. An expectation is this same weighted-average idea applied to a probability law.
Exercise C.R3 — Readiness: Check an outer product
For column vector $v=(1,2)^\top$, compute $vv^\top$ and show that its quadratic form is nonnegative for every vector $w=(w_1,w_2)^\top$.
Review if needed: outer products and PSD matrices.
Show hint
Show worked solution
The product is $vv^\top=\begin{bmatrix}1&2\\2&4\end{bmatrix}$. For any $w$, its quadratic form is $(w_1+2w_2)^2\ge0$, so this matrix is positive semidefinite. It is not positive definite: nonzero $w=(-2,1)^\top$ gives zero. Covariance matrices are averages of such outer products, which explains their nonnegative quadratic forms.
Book contents · Apply this chapter to a real decision · Glossary
Many guarantees in the modules are statements about a random experiment: a noisy measurement, one episode of a stochastic closed loop, a batch of training data, the random seed of a verifier. Others are deterministic and hold for every admissible state, disturbance or input, such as forward invariance or a verified network bound (Module 1 compares the types). To read a probabilistic guarantee you must be able to say what is random, which event is being measured and which average is taken. This primer builds that vocabulary from a first course in calculus and linear algebra, and then the tools the modules lean on: Gaussian conditioning (the engine of GP regression), concentration inequalities, union bounds, martingales for adaptively collected data, information measures, risk measures and distribution-free tests.
1. Random Variables, Expectation & Variance
Start with a finite table: a value $2$ occurring with probability $1/4$ contributes $2(1/4)=1/2$ to the mean. $\mathbb P(A)$ is a number assigned to an event $A$; $\mathbb E[X]$ averages a numerical random variable $X$. The first practice set rebuilds both operations before using covariance matrices.
When ready, try the Easy, Medium and Hard practice for this section. For a prerequisite gap, review sets and events.
A random variable is a number computed from the outcome, $X:\Omega\to\mathbb R$; a random vector takes values in $\mathbb R^n$; a random trajectory $\tau=(x_0,u_0,x_1,u_1,\dots)$ is a random sequence. The law (distribution) of $X$ is the map $B\mapsto\mathbb P(X\in B)$; $X\sim p$ reads "$X$ has law $p$".
- Discrete: $p(x)=\mathbb P(X=x)$ with $\sum_xp(x)=1$. Examples: Bernoulli$(q)$ with $\mathbb P(X=1)=q$, $\mathbb P(X=0)=1-q$; the point mass $\delta_s$ with $\mathbb P(X=s)=1$, so an initial law $\mu=\delta_{s_1}$ means "always start in $s_1$".
- Continuous with a density $p\ge0$: $\mathbb P(a\le X\le b)=\int_a^bp(x)\,dx$ and $\int p=1$; every single point then has probability $0$. Example: the uniform law $\mathcal U(a,b)$ with density $1/(b-a)$ on $[a,b]$. For a vector, $x_0\sim\mathcal U([-0.5,0.5]^2)$ means density $1$ on the square, i.e. two independent uniform coordinates. A density may exceed $1$ ($\mathcal U(0,0.5)$ has density $2$); only its integrals are probabilities.
- The CDF $F_X(z)=\mathbb P(X\le z)$ is nondecreasing and right-continuous, rising from $0$ to $1$. A jump of height $q\gt0$ at $z$ is an atom: $\mathbb P(X=z)=q$. A mixed law has atoms and a density part.
Worked example (an excursion with an atom). Let $X\sim\mathcal U(-1,1)$ be the signed distance of the state beyond a constraint boundary (positive means violated) and $Z=\max(X,0)=X^+$ the excursion. Then $\mathbb P(Z=0)=\mathbb P(X\le0)=\tfrac12$: an atom at zero. For $0\le z\le1$, $F_Z(z)=\mathbb P(X\le z)=(1+z)/2$, so $F_Z$ jumps from $0$ to $\tfrac12$ at $z=0$ and then rises linearly to $1$ (figure). A nondegenerate Gaussian has no atoms and assigns positive probability to negative values; a degenerate Gaussian is a single point mass. Neither represents this mixed law.
Subscripts name what is averaged: $\mathbb E_{x\sim\mu}[G(x)]$ averages $G$ over initial states drawn from $\mu$; $\mathbb E_{\tau\sim\pi}$ averages over trajectories generated jointly by the initial law, the policy $\pi$ and the transition law.
Worked example. For the excursion above, $\mathbb E[Z]=0\cdot\tfrac12+\int_0^1z\cdot\tfrac12\,dz=\tfrac14$: the atom contributes nothing, the density $\tfrac12$ on $(0,1]$ the rest. Counting violations: with $c_t=\mathbf 1\{x_t\gt1\}$ and $N=\sum_{t=1}^Tc_t$, linearity gives $\mathbb E[N]=\sum_t\mathbb P(x_t\gt1)$ even though the states of one episode are dependent. If each of $T=50$ steps violates with probability $0.004$, then $\mathbb E[N]=0.2$. Since $N$ is a nonnegative integer, $\mathbf 1\{N\ge1\}\le N$, hence $\mathbb P(\text{at least one violation})\le\mathbb E[N]=0.2$ whatever the dependence. A Boolean test becomes a signed monitor by subtracting one half: $\mathbf 1\{\text{test passed}\}-\tfrac12\in\{-\tfrac12,+\tfrac12\}$ is positive exactly when the test passes.
Worked example (ensemble spread). Two ensemble members predict means $\mu_1=(1,0)$ and $\mu_2=(-1,0)$. Their average is $\bar\mu=(0,0)$ and the outer-product estimate $\hat\Sigma=\tfrac12\sum_e(\mu_e-\bar\mu)(\mu_e-\bar\mu)^\top=\begin{bmatrix}1&0\\0&0\end{bmatrix}$ is PSD but singular: the members disagree only along the first axis. With $E$ members in $\mathbb R^n$ this estimate has rank at most $E-1$, so it is singular whenever $E\le n$ and must not be inverted. A fusion rule such as $\big(\tfrac1E\sum_e\Sigma_e^{-1}\big)^{-1}$ needs every member covariance $\Sigma_e$ to be positive definite.
Almost surely, support and essential supremum
The support of a law $\mu$ on $\mathbb R^n$ is the set of points $x$ such that every open ball around $x$ has positive probability (the smallest closed set of probability one): $\operatorname{supp}\mathcal U(a,b)=[a,b]$, $\operatorname{supp}\delta_s=\{s\}$, $\operatorname{supp}\mathcal N(0,\sigma^2)=\mathbb R$ for $\sigma\gt0$ (for $\sigma=0$ the support is $\{0\}$).
The essential supremum $\operatorname{ess\,sup}Z=\inf\{c:\ \mathbb P(Z\le c)=1\}$ is the smallest almost-sure upper bound.
Worked example. For the excursion, $\operatorname{ess\,sup}Z=1$. Now let a disturbance $W\sim\mathcal U(0,1)$ enter through $g(W)$ with $g=0$ except $g(0.5)=10$. The worst case over all disturbances is $\sup_wg(w)=10$, but $\mathbb P(g(W)=0)=1$, so $\operatorname{ess\,sup}g(W)=0$: an almost-sure analysis never sees the spike.
(b) If $g$ is continuous and $g(X)\le0$ almost surely, then $g\le0$ on all of $\operatorname{supp}(X)$. Proof. If $g(x_0)\gt0$ at some $x_0$ in the support, continuity gives a ball around $x_0$ on which $g\gt0$; that ball has positive probability, a contradiction. $\square$ Full support plus continuity is what upgrades an almost-sure guarantee to a robust one.
Measurable. The events form a $\sigma$-algebra (closed under complements and countable unions); a measurable function is one for which $\{X\in B\}$ is an event, i.e. a legitimate random variable. Everything built from continuous maps, indicators of boxes, sums, products, limits, max and min is measurable; "measurable feedback controller" or "measurable transition kernel" only asks that the probabilities we write down exist.
Measures and integrals. A measure assigns sizes to sets and is countably additive: Lebesgue measure is length, area or volume; counting measure counts points; a probability measure has total mass $1$. The integral $\int g\,d\nu$ is the ordinary integral for Lebesgue measure and the sum $\sum_xg(x)$ for counting measure. A density $p$ with respect to a reference measure $\nu$ means $\mathbb P(X\in A)=\int_Ap\,d\nu$: a mass function is a density with respect to counting measure. That is why one formula for expectations, entropy or KL covers sums and integrals at once. Mixed laws (atoms plus a density) and some policies have no density with respect to either; then statements are made for events directly, e.g. total variation as a supremum over events (Section 8).
Null sets and "almost everywhere". A null set has measure zero; a property holds almost everywhere (a.e.) if it fails only on a null set of the reference measure, usually Lebesgue. Points, lines, smooth curves in the plane and hyperplanes have zero volume, so a ReLU network, whose kinks lie on finitely many pieces of hyperplanes, is differentiable a.e.; a full-dimensional region contains a ball and has positive volume. A probability-zero exception never licenses a statement "for every parameter".
Averages of many samples
Keep two objects apart: the population quantity $\mathbb E[X]$ is a fixed number, the sample average $\bar X_N$ is random and changes with the data. The empirical distribution of $N$ samples puts mass $1/N$ on each observed value (mass $1/200$ on each of $200$ simulated episodes); its mean is the sample mean. How far $\bar X_N$ typically is from $\mathbb E[X]$ at finite $N$ is the subject of Section 3 (standard errors) and Section 5 (guaranteed bounds).
Example. Rewards with $|r_t|\le r_{\max}$ and discount $0\le\gamma\lt1$ give $\sum_t\gamma^t\mathbb E|r_t|\le r_{\max}/(1-\gamma)$, so $\mathbb E\big[\sum_t\gamma^tr_t\big]=\sum_t\gamma^t\mathbb E[r_t]$. Likewise, the difference quotients $\big[(Z-\nu-h)^+-(Z-\nu)^+\big]/h$ are bounded by $1$ and tend to $-\mathbf 1\{Z\gt\nu\}$ as $h\downarrow0$ and to $-\mathbf 1\{Z\ge\nu\}$ as $h\uparrow0$, so bounded convergence gives the right and left derivatives $-\mathbb P(Z\gt\nu)$ and $-\mathbb P(Z\ge\nu)$ of $\nu\mapsto\mathbb E[(Z-\nu)^+]$. They agree, and the ordinary derivative exists, exactly when $\mathbb P(Z=\nu)=0$ (the CVaR derivation in Module 1; atoms in Section 9).
Practice — Weighted averages and spread
Easy checks the basic operation; Medium connects steps; Hard asks you to justify a conclusion or identify a limitation. Each solution explains why the steps work.
Exercise C.S1 — Easy: Read a probability table
A random cost $X$ is $0$, $2$, or $4$ with probabilities $1/2$, $1/4$, and $1/4$. Check that this is a probability law. Find $\mathbb P(X\ge2)$ and $\mathbb E[X]$.
Review if needed: this section and sets and events.
Show hint
Show worked solution
- The probabilities are nonnegative and $1/2+1/4+1/4=1$, so they form a valid law.
- The event $X\ge2$ contains the outcomes $2$ and $4$. Therefore $\mathbb P(X\ge2)=1/4+1/4=1/2$.
- Weight all values, including zero: $\mathbb E[X]=0(1/2)+2(1/4)+4(1/4)=3/2$. A mean need not be one of the possible outcomes.
Exercise C.S2 — Medium: Variance is an average of squared distances
For the same law, compute $\mathbb E[X^2]$, $\operatorname{Var}(X)$ and the standard deviation. If $Y=3X+1$, find its mean and variance.
Review if needed: this section and sets and events.
Show hint
Show worked solution
- $\mathbb E[X^2]=0^2(1/2)+2^2(1/4)+4^2(1/4)=5$.
- Subtract the square of the mean: $\operatorname{Var}(X)=5-(3/2)^2=11/4=2.75$. The standard deviation is $\sqrt{11}/2\approx1.658$.
- Linearity gives $\mathbb E[Y]=3(3/2)+1=11/2$. Since $Y-\mathbb E[Y]=3(X-\mathbb E[X])$, its squared distances are nine times larger: $\operatorname{Var}(Y)=9(11/4)=99/4$.
Exercise C.S3 — Hard: A covariance calculation that detects dependence
Let $X$ be uniform on $\{-1,0,1\}$ and set $Y=X^2$. Compute the covariance matrix of $(X,Y)$. Are $X$ and $Y$ independent?
Review if needed: this section and sets and events.
Show hint
Show worked solution
- Symmetry gives $\mathbb E[X]=0$, while $\mathbb E[Y]=2/3$ and $\mathbb E[XY]=\mathbb E[X^3]=0$. Thus $\operatorname{Cov}(X,Y)=0$.
- $\operatorname{Var}(X)=2/3$. Since $Y^2=Y$, $\operatorname{Var}(Y)=2/3-(2/3)^2=2/9$. The covariance matrix is $\operatorname{diag}(2/3,2/9)$.
- They are dependent: $Y=0$ forces $X=0$, so $\mathbb P(X=0\mid Y=0)=1$, whereas $\mathbb P(X=0)=1/3$. Zero covariance did not remove this information.
2. Conditional Probability, Bayes & Conditional Expectation
Conditioning means keeping only outcomes consistent with new information and rescaling their weights. If an event leaves three equally likely outcomes, each remaining outcome has conditional probability $1/3$. Distinguish the information after the vertical bar from the question before it.
When ready, try the Easy, Medium and Hard practice for this section. For a prerequisite gap, review weighted expectations.
Conditioning is updating on information. Once we know that an event $B$ happened, only outcomes inside $B$ remain possible, and their probabilities are rescaled so that they again sum to one.
Worked example (an alarm and the base rate). A fault occurs in $1\%$ of runs; a monitor detects a fault with probability $0.95$ and raises a false alarm on a healthy run with probability $0.05$. Given an alarm,
About five out of six alarms are false: a small false-alarm rate is swamped by the many healthy runs. The false-alarm rate $\mathbb P(\text{alarm}\mid\text{healthy})$ of a test (Section 10) and the posterior $\mathbb P(\text{fault}\mid\text{alarm})$ are different numbers, and the second needs a prior.
Transition kernels and trajectory laws. A transition kernel $P(s'\mid s,a)$ is a family of conditional laws, one distribution of the next state for each state-action pair; a stochastic policy $\pi(a\mid s)$ is a conditional law of the action. The product rule chains them into the law of a trajectory,
and total probability gives marginals, $\mathbb P(s_1=s')=\sum_{s,a}\mu(s)\,\pi(a\mid s)\,P(s'\mid s,a)$. For instance, from $\mu=\delta_{s_0}$ with two actions of probability $0.5$ each that reach an unsafe state with probabilities $0.2$ and $0.6$, $\mathbb P(s_1\text{ unsafe})=0.5\cdot0.2+0.5\cdot0.6=0.4$. Decorations such as $\mathbb P^\pi_\mu$ or $\mathbb E_{\tau\sim\pi}$ record which $\mu$, $\pi$ and $P$ generate the trajectory; change any of them and every probability changes.
Worked example (averaging over a policy). In a state $s$, action $a_1$ has expected cost $\mathbb E[X\mid a_1]=2$ and action $a_2$ has $\mathbb E[X\mid a_2]=10$. Under $\pi=(0.7,0.3)$ the tower rule gives $\mathbb E[X]=0.7\cdot2+0.3\cdot10=4.4$. Under another policy $\pi'=(0.9,0.1)$ the conditional expectations, a property of the environment, are unchanged and only the weights move: $0.9\cdot2+0.1\cdot10=2.8$. The performance-difference lemma averages the advantage of $\pi$ over the actions of $\pi'$ in exactly this way.
Worked example (small and large errors). Residuals that are $\mathcal N(0,0.5^2)$ with probability $0.8$ and $\mathcal N(0,3^2)$ with probability $0.2$ (the "80% small, 20% large" option of the Module 15 explorer) have variance $0.8\cdot0.25+0.2\cdot9=2$. Their tail is nothing like that of $\mathcal N(0,2)$: $\mathbb P(|E|\gt5)=0.8\cdot\mathbb P(|Z|\gt10)+0.2\cdot\mathbb P(|Z|\gt\tfrac53)\approx0.019$, against $0.0004$ for the Gaussian with the same variance, while near zero the mixture is more concentrated ($\mathbb P(|E|\gt1)\approx0.18$ against $0.48$). An ensemble of $E$ Gaussian predictions is an equal-weight mixture: its covariance is the average member covariance (aleatoric part) plus the covariance of the member means (epistemic part, the $\hat\Sigma$ of Section 1).
Worked example (ten runs, no failure). Let $\theta$ be the failure probability of a controller, with a uniform prior on $[0,1]$. Ten independent runs show no failure, so $L(\theta)=(1-\theta)^{10}$ and the posterior density is $11(1-\theta)^{10}$ (a Beta$(1,11)$ law, Section 10). The ML estimate is $\hat\theta=0$, "it never fails", yet the posterior mean is $1/12\approx0.083$ and $\mathbb P(\theta\gt0.2\mid\mathcal D)=\int_{0.2}^111(1-\theta)^{10}d\theta=0.8^{11}\approx0.086$. For Gaussian models the posterior and the marginal likelihood are available in closed form (Section 4); non-Gaussian likelihoods, such as binary safe/unsafe labels or censored measurements, need approximations (Laplace, expectation propagation, sampling). Preference data give another likelihood: in the Bradley–Terry model an item with score $r_a$ beats one with score $r_b$ with probability $1/(1+e^{-(r_a-r_b)})$, and the negative log-likelihood of an observed preference is the logistic loss $\log(1+e^{-(r_a-r_b)})$.
Worked example (nested probabilities). A controller is stable with probability at least $1-\epsilon=0.95$ under a posterior truncated to a region $A$ of mass $c=0.99$. Under the untruncated posterior, $\mathbb P(\text{stable})\ge\mathbb P(\text{stable}\cap A)=\mathbb P(\text{stable}\mid A)\,\mathbb P(A)\ge0.95\cdot0.99=0.9405$. The same product rule composes a hyperparameter statement with a function statement: if the true hyperparameter lies in a box with probability at least $1-\delta_1$ and, given that, a confidence band holds with probability at least $1-\delta_2$, both hold with probability at least $(1-\delta_1)(1-\delta_2)\ge1-\delta_1-\delta_2$. If the result is afterwards validated on random test samples, the validation confidence is a third, frequentist probability over those samples (Section 6); keep it apart from posterior mass. The tower rule also explains conformal coverage (Section 10): conditional on the calibration data the coverage is a random variable $C$, and its average $\mathbb E[C]$ is the marginal coverage probability.
Practice — Condition on the information you actually have
Easy checks the basic operation; Medium connects steps; Hard asks you to justify a conclusion or identify a limitation. Each solution explains why the steps work.
Exercise C.S4 — Easy: Restrict and renormalise
Roll a fair six-sided die. Let $A$ mean an even result and $B$ mean a result greater than $3$. Find $\mathbb P(A)$, $\mathbb P(B)$ and $\mathbb P(A\mid B)$.
Review if needed: this section and weighted expectations.
Show hint
Show worked solution
- $A=\{2,4,6\}$ and $B=\{4,5,6\}$ each have probability $3/6=1/2$.
- The intersection is $A\cap B=\{4,6\}$, of probability $2/6$.
- Divide by the probability of the information: $\mathbb P(A\mid B)=(2/6)/(3/6)=2/3$. Conditioning changed the denominator because only three results remain possible.
Exercise C.S5 — Medium: Bayes by counting imaginary runs
A fault occurs in $10\%$ of runs. An alarm fires on $80\%$ of faulty runs and $20\%$ of healthy runs. Find the alarm probability and the fault probability after an alarm.
Review if needed: this section and weighted expectations.
Show hint
Show worked solution
- Of $1000$ hypothetical runs, $100$ are faulty and $900$ healthy. They produce $80$ true alarms and $180$ false alarms.
- Total probability therefore gives $\mathbb P(\text{alarm})=0.8(0.1)+0.2(0.9)=0.26$.
- Among the $260$ alarms, only $80$ indicate faults. Bayes gives $\mathbb P(\text{fault}\mid\text{alarm})=80/260=4/13\approx0.3077$. The detector's $0.8$ sensitivity answers the reversed conditional question.
Exercise C.S6 — Hard: Separate noise from disagreement
Choose a model label $L\in\{1,2\}$ with equal probabilities. Conditional on $L=1$, $X$ has mean $0$ and variance $1$; conditional on $L=2$, it has mean $4$ and variance $1$. Find the unconditional mean and variance without assuming either conditional law is Gaussian.
Review if needed: this section and weighted expectations.
Show hint
Show worked solution
- The tower rule averages the conditional means: $\mathbb E[X]=(0+4)/2=2$.
- The within-model term is $\mathbb E[\operatorname{Var}(X\mid L)]=(1+1)/2=1$.
- The conditional mean is $0$ or $4$, so its variance is $[(0-2)^2+(4-2)^2]/2=4$. Add the terms: $\operatorname{Var}(X)=1+4=5$. Averaging only the two variances would miss model disagreement.
3. Markov Chains, Stationary Distributions & Monte Carlo
A trajectory is one realised sequence; a distribution records how likely each state is across repeated sequences. A row distribution $(1,0)$ means starting in the first state for sure. Multiplying it by a transition matrix gives the law one step later, not a single sampled next state.
When ready, try the Easy, Medium and Hard practice for this section. For a prerequisite gap, review matrix-vector multiplication.
Worked example. Let $P=\begin{bmatrix}0.9&0.1\\0.5&0.5\end{bmatrix}$ (state 1 nominal, state 2 degraded). $\pi=\pi P$ gives $\pi_2=0.1\pi_1+0.5\pi_2$, so $\pi_2=\pi_1/5$ and $\pi=(5/6,1/6)$. From state 2: $p_1=(0.5,0.5)$, $p_2=(0.7,0.3)$, $p_3=(0.78,0.22)$, $p_4=(0.812,0.188)$; the gap to $\pi$ shrinks by the factor $0.4$ per step, the second eigenvalue of $P$ ($\operatorname{tr}P-1$). The chain never stops jumping; only its distribution settles, and the approach phase is the transient. If every state can reach every other (irreducible), $\pi$ is unique and positive; if moreover the chain is aperiodic (the possible return times to a state have greatest common divisor $1$; for an irreducible chain one self-loop $P_{ii}\gt0$, as here, suffices), $p_t\to\pi$ from any start. Periodicity does block convergence: $P=\begin{bmatrix}0&1\\1&0\end{bmatrix}$ has the unique $\pi=(\tfrac12,\tfrac12)$, yet started in state 1 its law alternates $(1,0),(0,1),(1,0),\dots$ for ever. A chain with one closed recurrent class plus transient states (unichain) also has a unique $\pi$.
Worked example. $Q=\begin{bmatrix}0.5&0.3\\0.2&0.4\end{bmatrix}$: $\det(I-Q)=0.5\cdot0.6-0.3\cdot0.2=0.24$ and $N=\tfrac1{0.24}\begin{bmatrix}0.6&0.3\\0.2&0.5\end{bmatrix}=\begin{bmatrix}2.5&1.25\\0.833&2.083\end{bmatrix}$. From state 1 the chain spends on average $2.5+1.25=3.75$ steps before absorption. (For $V\ge0$, the drift condition $\mathbb E[V(X_{t+1})\mid X_t=x]\le V(x)-1$ for all $x$ outside a set $C$ is the probabilistic Lyapunov (Foster) criterion: from $x$ the chain reaches $C$ after at most $V(x)$ steps on average.)
Worked example. $a=0.9$, $\sigma=0.1$: $v_\infty=0.01/0.19=0.0526$, a stationary standard deviation of $0.229$, $2.3$ times the per-step noise, because noise accumulates. In Module 1's loop $x_{t+1}=x_t-k(x_t-0.8)+w_t$ the error $e_t=x_t-0.8$ has $a=1-k$ and $v_\infty=\sigma^2/(k(2-k))$. Three different notions: the deterministic equilibrium ($\sigma=0$, $e=0$); stability of the recursion ($|a|\lt1$); the stationary distribution ($\sigma\gt0$: the state keeps moving, its law no longer changes).
Random functions over time. The recursion $f_t=\sqrt{1-\varepsilon}\,f_{t-1}+\sqrt{\varepsilon}\,g_t$ with $\varepsilon\in[0,1]$, centred independent innovations $g_t$ of variance $s^2$, independent of the centred $f_0$ with $\operatorname{Var}f_0=s^2$ keeps $\operatorname{Var}f_t=(1-\varepsilon)s^2+\varepsilon s^2=s^2$ for every $t$, while $\operatorname{Cov}(f_t,f_{t-k})=(1-\varepsilon)^{k/2}s^2$ decays: memory fades and the process reverts to its mean ($\varepsilon=0$ frozen, $\varepsilon=1$ fresh each step). With $a=1$ and i.i.d. centred increments of variance $\sigma^2\gt0$ independent of $x_0$, the random walk $x_t=x_0+\sum_{s\lt t}w_s$ has variance growing like $t\sigma^2$: no stationary law and no mean reversion. Sped up to $n$ steps per unit of time and with each step divided by $\sigma\sqrt n$, $W_n(t)=\frac1{\sigma\sqrt n}\sum_{s\lt\lfloor nt\rfloor}w_s$ has $\operatorname{Var}W_n(t)=\lfloor nt\rfloor/n\to t$, and as $n\to\infty$ it converges in distribution (Donsker's theorem) to the Wiener process $W$: $W(0)=0$, continuous paths and independent increments $W(t)-W(s)\sim\mathcal N(0,t-s)$, hence for $s\le t$, $\operatorname{Cov}(W(s),W(t))=\operatorname{Cov}\big(W(s),W(s)+(W(t)-W(s))\big)=\operatorname{Var}W(s)=s=\min(s,t)$.
Worked example (200 episodes). $40$ of $N=200$ episodes violate: $\hat p=0.2$, $\mathrm{SE}=\sqrt{0.2\cdot0.8/200}=0.028$, and the normal-approximation 95% interval is $0.2\pm1.96\cdot0.028=[0.145,\,0.255]$ ($1.96$ is the $97.5\%$ quantile of the standard normal, Section 4). With zero violations the formula gives $\mathrm{SE}=0$, which is meaningless. The exact statement: if the true rate were $p$, all $200$ runs are clean with probability $(1-p)^{200}$, which is below $0.05$ once $p\gt1-0.05^{1/200}=0.0149\approx3/200$ (the "rule of three"). Truncation bias: estimating $\mathbb E\sum_{t\ge0}\gamma^tc_t$ with $c_t\in[0,1]$ from episodes cut at horizon $H$ underestimates by at most $\gamma^H/(1-\gamma)$, which is $0.657$ for $\gamma=0.99$, $H=500$.
Practice — Transitions, long-run laws and Monte Carlo
Easy checks the basic operation; Medium connects steps; Hard asks you to justify a conclusion or identify a limitation. Each solution explains why the steps work.
Exercise C.S7 — Easy: Advance a distribution one step
A chain has states $A,B$ and row-stochastic transition matrix $P=\begin{bmatrix}0.8&0.2\\0.3&0.7\end{bmatrix}$. Start in $A$ with certainty. Find the distributions after one and two steps.
Review if needed: this section and matrix-vector multiplication.
Show hint
Show worked solution
- The initial row is $p_0=(1,0)$. Multiplying selects the first row: $p_1=(0.8,0.2)$.
- To reach $A$ in two steps, add the disjoint paths: $0.8(0.8)+0.2(0.3)=0.70$.
- Similarly $\mathbb P(s_2=B)=0.8(0.2)+0.2(0.7)=0.30$, so $p_2=(0.7,0.3)$. These entries sum to one, providing a useful arithmetic check.
Exercise C.S8 — Medium: Solve a stationary distribution
For the same $P$, solve $p_*P=p_*$ with $p_*=(a,1-a)$. Does stationarity mean that the chain stops moving?
Review if needed: this section and matrix-vector multiplication.
Show hint
Show worked solution
- The first coordinate gives $a=0.8a+0.3(1-a)=0.5a+0.3$.
- Therefore $a=0.6$ and $p_*=(0.6,0.4)$. Check the other coordinate: $0.6(0.2)+0.4(0.7)=0.4$.
- Stationarity describes an unchanged distribution. Individual paths still switch states: from $A$ the next state is $B$ with probability $0.2$. A random trajectory and its law are different objects.
Exercise C.S9 — Hard: Why copying data does not increase sample size
Let $Z_1,\dots,Z_{100}$ be independent Bernoulli variables with success probability $0.2$. Compare the variance of their average with an average of $100$ recorded entries formed by repeating each of $50$ independent Bernoulli draws twice. Both averages are unbiased; are they equally precise?
Review if needed: this section and matrix-vector multiplication.
Show hint
Show worked solution
- A Bernoulli draw has variance $p(1-p)=0.2(0.8)=0.16$. Independence gives variance $0.16/100=0.0016$ for the first mean.
- The second mean is $(2/100)\sum_{i=1}^{50}Z_i=(1/50)\sum_{i=1}^{50}Z_i$, so its variance is $0.16/50=0.0032$.
- The standard deviations are $0.04$ and $\sqrt{0.0032}\approx0.05657$. Copying observations preserves the expectation but doubles this variance; counting dependent entries as independent understates uncertainty.
4. The Multivariate Gaussian & Gaussian Conditioning
In $\mathcal N(10,4)$, the mean is $10$, the variance is $4$ and the standard deviation is $2$. Standardising $12$ gives $(12-10)/2=1$. Master this scalar calculation before the block-matrix conditioning formula.
When ready, try the Easy, Medium and Hard practice for this section. For a prerequisite gap, review block matrices and Schur complements.
| $z$ | $1$ | $1.2816$ | $1.6449$ | $1.96$ | $2$ | $2.3263$ | $3$ | $3.0902$ |
|---|---|---|---|---|---|---|---|---|
| $\Phi(z)$ | $0.8413$ | $0.90$ | $0.95$ | $0.975$ | $0.9772$ | $0.99$ | $0.99865$ | $0.999$ |
| $2\Phi(-z)$ | $0.3173$ | $0.20$ | $0.10$ | $0.05$ | $0.0455$ | $0.02$ | $0.0027$ | $0.002$ |
Worked example (one-sided safety probability). If the posterior of $f(x)$ is $\mathcal N(\mu,\sigma^2)$, then $\mathbb P(f(x)\ge\mu+\beta\sigma)=1-\Phi(\beta)=\Phi(-\beta)$. Requiring this to be at least $\alpha$ means $\Phi(\beta)\le1-\alpha$; for $\alpha=0.9$ that is $\beta\le-1.2816$. A safety probability above one half therefore forces a negative multiplier, i.e. a lower confidence bound; an optimistic $\beta\ge0$ certifies at most probability $\tfrac12$. Numerics: $Q(10)=7.6\cdot10^{-24}$, but $1-\Phi(10)$ evaluated in double precision is exactly $0$ because $\Phi(10)$ rounds to $1$ (cancellation). Tail probabilities should be computed from $\operatorname{erfc}$ directly; the formula is exact, the subtraction is not.
Worked example (Gaussian chance constraint). Let $x\sim\mathcal N(m,\Sigma)$ with $m=(0.5,0.5)$, $\Sigma=\begin{bmatrix}0.04&0.01\\0.01&0.09\end{bmatrix}$ and $h=(1,1)$. Then $h^\top x\sim\mathcal N(1,\,0.04+0.09+2\cdot0.01)=\mathcal N(1,0.15)$ and $\mathbb P(h^\top x\le2)=\Phi(1/0.387)=\Phi(2.58)=0.995$. In general $\mathbb P(h^\top x\le b)\ge p\iff h^\top m+\Phi^{-1}(p)\sqrt{h^\top\Sigma h}\le b$: a deterministic, tightened constraint (here $1+1.645\cdot0.387=1.64\le2$ for $p=0.95$). The equivalence is exact only if $x$ really is Gaussian.
Worked example (repeated measurements). Let $y_1,\dots,y_m$ be i.i.d. $\mathcal N(f,\sigma^2)$. Then $\bar y\sim\mathcal N(f,\sigma^2/m)$, and since $\sum_i(y_i-f)^2=\sum_i(y_i-\bar y)^2+m(\bar y-f)^2$ (the cross term $2(\bar y-f)\sum_i(y_i-\bar y)$ vanishes), the likelihood of $f$ is $e^{-m(\bar y-f)^2/(2\sigma^2)}$ times a factor free of $f$: the mean with noise variance $\sigma^2/m$ carries all the information about $f$.
Precision addition. For a scalar prior $f\sim\mathcal N(m_0,s_0^2)$ and one observation $y=f+\varepsilon$ with noise $\varepsilon\sim\mathcal N(0,\sigma^2)$ independent of $f$ ($s_0,\sigma\gt0$), the theorem with $\Sigma_{xx}=\Sigma_{xy}=s_0^2$, $\Sigma_{yy}=s_0^2+\sigma^2$ gives posterior variance $s^2=s_0^2\sigma^2/(s_0^2+\sigma^2)$, i.e.
precisions (inverse variances) add and the mean is a precision-weighted average; $m$ repeated observations enter through $\bar y$ with precision $m/\sigma^2$. Conditioning independent parts on their sum works the same way: for independent $X_1\sim\mathcal N(0,a)$, $X_2\sim\mathcal N(0,b)$ and $S=X_1+X_2$, $\mathbb E[X_1\mid S]=\frac{a}{a+b}S$ and $\operatorname{Var}(X_1\mid S)=\frac{ab}{a+b}$ (a simulator part and a residual part of an objective, say).
A truncated Gaussian on $[a_{\rm lo},a_{\rm hi}]$ has density $\varphi\big(\tfrac{a-m}{s}\big)\big/\big(s\,[\Phi(\tfrac{a_{\rm hi}-m}{s})-\Phi(\tfrac{a_{\rm lo}-m}{s})]\big)$ on the interval (Section 2's renormalisation), and seeded Gaussian draws are the standard way to generate random test networks, weights and noise; they sample, they do not cover.
Practice — Standardise and condition Gaussian laws
Easy checks the basic operation; Medium connects steps; Hard asks you to justify a conclusion or identify a limitation. Each solution explains why the steps work.
Exercise C.S10 — Easy: Variance is not standard deviation
Let $X\sim\mathcal N(10,4)$. Find $\mathbb P(X\le12)$ and $\mathbb P(8\le X\le12)$ using $\Phi(1)\approx0.8413$.
Review if needed: this section and block matrices and Schur complements.
Show hint
Show worked solution
- Standardise with $Z=(X-10)/2$. The threshold $12$ becomes $(12-10)/2=1$.
- Hence $\mathbb P(X\le12)=\Phi(1)\approx0.8413$.
- The interval becomes $-1\le Z\le1$. By symmetry its probability is $\Phi(1)-\Phi(-1)=2\Phi(1)-1\approx0.6826$. A one-standard-deviation interval does not have $95\%$ coverage.
Exercise C.S11 — Medium: One noisy measurement
A scalar $f$ has prior $\mathcal N(0,4)$. Observe $y=f+\varepsilon=3$, where $\varepsilon\sim\mathcal N(0,1)$ is independent of $f$. Find the posterior mean and variance, and the variance of a future noisy measurement with independent noise variance $1$.
Review if needed: this section and block matrices and Schur complements.
Show hint
Show worked solution
- Posterior precision is $1/4+1=5/4$, so the variance is $s^2=4/5=0.8$.
- The precision-weighted mean is $s^2(0/4+3/1)=12/5=2.4$. It lies between the prior mean and the observation, nearer the more precise observation.
- A future measurement adds independent noise, so its predictive variance is $0.8+1=1.8$. The latent variance $0.8$ alone would understate measurement uncertainty.
Exercise C.S12 — Hard: A chance constraint along a direction
Let $X$ be jointly Gaussian with mean $(1,2)$ and covariance $\begin{bmatrix}1&0.5\\0.5&4\end{bmatrix}$. For $S=X_1+X_2$, compute its mean and variance. Find the smallest $b$ satisfying $\mathbb P(S\le b)\ge0.95$, using $\Phi^{-1}(0.95)\approx1.64485$.
Review if needed: this section and block matrices and Schur complements.
Show hint
Show worked solution
- An affine projection of a jointly Gaussian vector is Gaussian. Its mean is $1+2=3$.
- Its variance is $h^\top\Sigma h=1+4+2(0.5)=6$, so $S\sim\mathcal N(3,6)$.
- The smallest threshold is the exact $95\%$ quantile: $b_\ast=3+\sqrt6\,\Phi^{-1}(0.95)\approx7.0291$. Substituting the supplied rounded quantile gives the estimate $3+1.64485\sqrt6\approx7.0290$, which is strictly below $b_\ast$ and does not meet the exact $0.95$ probability requirement. This uses the one-sided quantile; the familiar $1.96$ is a rounded radius for a two-sided $95\%$ interval.
5. Concentration: Markov, Chebyshev, Hoeffding & Sub-Gaussian Noise
A tail bound is an upper limit on a probability, not a prediction that the limit is attained. If a nonnegative cost has mean $2$, Markov bounds the chance of cost at least $8$ by $2/8=1/4$. Stronger bounds below require additional assumptions; check them before substituting numbers.
When ready, try the Easy, Medium and Hard practice for this section. For a prerequisite gap, review logarithms and rates.
A standard error says how far an average typically lands from its mean. A safety argument needs a bound on the probability of a large deviation that holds for every $N$, with no normal approximation. Each inequality below buys a faster-decaying tail with a stronger assumption.
Chebyshev: if $\operatorname{Var}X\lt\infty$ and $a\gt0$, then $\mathbb P(|X-\mathbb EX|\ge a)\le\operatorname{Var}(X)/a^2$. Proof. Markov for $(X-\mathbb EX)^2$ at level $a^2$. $\square$
For the mean of $N$ i.i.d. terms of variance $\sigma^2$, $\operatorname{Var}\bar X_N=\sigma^2/N$ gives $\mathbb P(|\bar X_N-m|\ge t)\le\sigma^2/(Nt^2)$: polynomial decay.
Worked example (standardised prediction errors). If, given the history, $f(x_t)\sim\mathcal N(\mu_t,\sigma_t^2)$ and the query $x_t$ was chosen from past data (so it is fixed once we condition on the history), then $\mathbb P\big(|f(x_t)-\mu_t|\gt\sqrt\rho\,\sigma_t\mid\text{history}\big)\le e^{-\rho/2}$. Choosing $\rho=2\ln(1/\delta)$ makes this $\delta$: for $\delta=0.05$, $\sqrt\rho=2.45$, slightly conservative against the exact two-sided $1.96$.
If $a=b$, centring forces $X=0$ almost surely and the claim is immediate. Otherwise $a\lt b$. By convexity, $e^{\lambda x}$ lies below its chord on $[a,b]$: $e^{\lambda x}\le\frac{b-x}{b-a}e^{\lambda a}+\frac{x-a}{b-a}e^{\lambda b}$. Take expectations using $\mathbb EX=0$ and write $\theta=-a/(b-a)\in[0,1]$, $h=\lambda(b-a)$: $\mathbb Ee^{\lambda X}\le e^{L(h)}$ with $L(h)=-\theta h+\log(1-\theta+\theta e^h)$. Then $L(0)=0$, $L'(0)=0$ and $L''(h)=q(1-q)\le\tfrac14$ with $q=\theta e^h/(1-\theta+\theta e^h)\in[0,1]$. Taylor's theorem with remainder gives $L(h)\le h^2/8=\lambda^2(b-a)^2/8$. $\square$
Worked example (how many runs?). Outcomes in $[0,1]$, accuracy $t=0.05$, failure probability $\delta=0.05$. Chebyshev with $\operatorname{Var}\le\tfrac14$: $N\ge1/(4\delta t^2)=2000$. Hoeffding: $N\ge\ln(40)/(2\cdot0.0025)=737.8$, so $738$. The central-limit approximation $(1.96\cdot0.5/0.05)^2\approx385$ is smaller but is not a guarantee. For rare events Hoeffding is loose; the Chernoff–KL bound $\mathbb P(\mathrm{Bin}(N,p)\ge Nq)\le e^{-N\,\mathrm{kl}(q\|p)}$ for $q\gt p$ (and the mirror image for $q\lt p$), with the KL divergence between Bernoulli laws $\mathrm{kl}(q\|p)=q\ln\frac qp+(1-q)\ln\frac{1-q}{1-p}$ (Section 8), is much sharper: for $p=0.01$, $q=0.03$, $N=1000$ it gives $1.9\cdot10^{-6}$ where Hoeffding gives $0.45$ (the exact value is $2\cdot10^{-7}$).
| Zero-mean noise | hard bound | std. dev. | best $R$ | Hoeffding $R$ |
|---|---|---|---|---|
| $\mathcal U(-1,1)$ | $1$ | $1/\sqrt3\approx0.577$ | $1/\sqrt3\approx0.577$ | $1$ |
| $\pm0.5$ with probability $\tfrac12$ each | $0.5$ | $0.5$ | $0.5$ | $0.5$ |
| $0.99$ w.p. $0.01$, $-0.01$ w.p. $0.99$ | $0.99$ | $0.0995$ | $\sqrt{0.98/(2\ln99)}\approx0.327$ | $0.5$ |
| $\mathcal N(0,\sigma^2)$ | none | $\sigma$ | $\sigma$ | n/a |
| Student-$t$, 3 d.o.f. | none | $\sqrt3=1.73$ | none: not sub-Gaussian | n/a |
Heavy and uneven noise. A Student-$t$ variable with $\nu\in\{1,2,\dots\}$ degrees of freedom is $T=Z/\sqrt{V/\nu}$, where $Z,Z_1,\dots,Z_\nu$ are independent standard normals and $V=\sum_{j=1}^\nu Z_j^2$. Its density decays only polynomially, like $|t|^{-(\nu+1)}$, so the absolute moments $\mathbb E|T|^k$ of order $k\ge\nu$ are infinite and $\mathbb Ee^{\lambda T}=\infty$ for every $\lambda\ne0$: no sub-Gaussian parameter exists. For $\nu=3$ (variance $3$), $\mathbb P(|T|\gt5)=0.015$ against $0.004$ for $\mathcal N(0,3)$, and $\mathbb P(|T|\gt10)=0.002$ against $8\cdot10^{-9}$. Heteroscedastic noise $\varepsilon_t=s(x_t)\xi_t$ with $\xi_t\sim\mathcal N(0,1)$ independent of the past and $|s(x)|\le R$ everywhere is conditionally $R$-sub-Gaussian: one envelope $R$ covers every input.
Practice — Choose a bound whose assumptions hold
Easy checks the basic operation; Medium connects steps; Hard asks you to justify a conclusion or identify a limitation. Each solution explains why the steps work.
Exercise C.S13 — Easy: An upper bound can be loose
A nonnegative random cost $X$ has mean $2$. Bound $\mathbb P(X\ge8)$ with Markov's inequality. What does the same method say about $\mathbb P(X\ge1)$?
Review if needed: this section and logarithms and rates.
Show hint
Show worked solution
- Markov applies because $X\ge0$: $\mathbb P(X\ge8)\le\mathbb E[X]/8=2/8=1/4$.
- At threshold $1$ the algebra gives $\mathbb P(X\ge1)\le2$. Combining with the universal probability bound gives at most $1$.
- This second result is valid but uninformative. A bound is an upper limit, not an estimate of the actual tail probability, and these assumptions alone need not give a useful limit at every threshold.
Exercise C.S14 — Medium: Plan a Hoeffding sample size
Independent observations lie in $[0,1]$ and have a common mean $\mu$. How many observations suffice to bound $|\bar X_N-\mu|$ by $0.1$ with confidence at least $0.95$ using Hoeffding?
Review if needed: this section and logarithms and rates.
Show hint
Show worked solution
- Two-sided Hoeffding gives failure probability at most $2e^{-0.02N}$. Divide by $2$: $e^{-0.02N}\le0.025$.
- Taking logarithms and dividing by the negative coefficient reverses the inequality: $N\ge\ln(40)/0.02\approx184.44397$.
- Use $N=185$, the smallest integer certified by this bound. Rounding down gives a failure bound slightly above $0.05$. The derivation requires independence and the stated range.
Exercise C.S15 — Hard: A bounded bias survives averaging
Let independent errors be uniform on $[0,2]$. A learner treats them as zero-mean noise and chooses $R=2$. Explain why the zero-mean sub-Gaussian condition fails. Centre the errors correctly and give a valid Hoeffding sub-Gaussian parameter for the centred errors.
Review if needed: this section and logarithms and rates.
Show hint
Show worked solution
- The error mean is $1$, so the sample mean converges to $1$, not $0$. A hard bound does not remove bias.
- For a zero-mean sub-Gaussian condition, the MGF must obey $\mathbb E e^{\lambda\varepsilon}\le e^{\lambda^2R^2/2}$ for both signs near zero. Its left-hand side has expansion $1+\lambda\mathbb E\varepsilon+O(\lambda^2)=1+\lambda+O(\lambda^2)$, contradicting the bound for small positive $\lambda$.
- Set $\xi=\varepsilon-1$. Then $\mathbb E\xi=0$ and $\xi\in[-1,1]$. Hoeffding's lemma certifies $R=(1-(-1))/2=1$. The observation model must still account for the removed bias.
6. “With Probability at Least $1-\delta$”: Union Bounds & Confidence Statements
A $95\%$ statement about one quantity and a $95\%$ statement about every quantity are different events. Ten failure budgets of $0.005$ add to a total budget of $0.05$. Write the desired event first, then decide how the confidence budget must be shared.
When ready, try the Easy, Medium and Hard practice for this section. For a prerequisite gap, review unions and quantifiers.
Worked example (what joint coverage costs). A two-sided Gaussian band at one point with $\delta=0.05$ needs $\beta=1.96$. For $T=100$ rounds at $\delta/T$ each it needs $\Phi^{-1}(1-0.00025)=3.48$; for $T=10^4$, $4.56$: the price grows only like $\sqrt{\log T}$. If the per-step failures were independent with probability $0.001$, joint success over $100$ steps would be exactly $0.999^{100}=0.905$ against the union bound's $0.9$: barely conservative, and the union bound stays valid under dependence, where the product formula does not. The same logic turns per-step chance constraints into a joint one: $\mathbb P(x_t\notin C)\le\delta$ for each $t$ does not give $\mathbb P(\exists t\le T:\ x_t\notin C)\le\delta$, but $\mathbb P(x_t\notin C)\le\delta/T$ for each $t$ does.
Anytime budgets. To cover all $t=1,2,\dots$ at once, spend a summable sequence: $\delta_t=\frac{\delta}{t(t+1)}$ gives $\sum_{t\ge1}\delta_t=\delta\sum_{t\ge1}\big(\frac1t-\frac1{t+1}\big)=\delta$ by telescoping; $\delta_t=\delta/\pi_t$ with $\pi_t=\pi^2t^2/6$, so that $\sum_t\pi_t^{-1}=1$, does the same via $\sum_t1/t^2=\pi^2/6$. For $\delta=0.05$ and $\delta_t=\delta/(t(t+1))$, a two-sided Gaussian band needs $\beta_t=\Phi^{-1}(1-\delta_t/2)=2.24,\ 3.51,\ 4.57,\ 5.45$ at $t=1,10,100,1000$.
| Frequentist band (RKHS) | Bayesian band (GP posterior) | |
|---|---|---|
| the unknown $f$ | fixed, with $\|f\|_k\le B$ | random, $f\sim\mathcal{GP}(0,k)$ |
| source of randomness | measurement noise (and the algorithm's own) | the prior over $f$ and the noise |
| "probability $1-\delta$" | over repeated runs on this $f$ | over functions from the prior, given the data |
| guarantee lost when | $\|f\|_k\gt B$ or the noise is not conditionally sub-Gaussian | the prior or the likelihood is wrong |
Uniform over inputs. On a finite domain a union bound over the $|D|$ points only adds $\log|D|$ under the square root: with the Gaussian tail of Section 5 the multiplier becomes $\beta_t=\sqrt{2\log(|D|\pi_t/\delta)}$. On a continuum there are infinitely many points: one needs a discretisation plus a Lipschitz argument, or a self-normalised martingale bound (Section 7) that controls the whole function at once. Nested (PAC) statements. When a bound is itself calibrated from random data, two probabilities appear: $\mathbb P_{\mathcal Z}\big\{\mathbb P(\text{good}\mid\mathcal Z)\ge1-\gamma\big\}\ge1-\kappa$, "probably ($1-\kappa$, over the calibration sample $\mathcal Z$) approximately ($1-\gamma$, over fresh draws) correct". Example: let $B$ be the maximum of $m$ i.i.d. samples of a continuous quantity with CDF $F$. $F(B)$ is the fraction of fresh draws that $B$ covers, and $\mathbb P\{F(B)\lt1-\gamma\}=(1-\gamma)^m$ because all $m$ samples must fall below the $(1-\gamma)$-quantile. For $\gamma=0.05$ and $\kappa=0.01$, $m\ge\ln0.01/\ln0.95=89.8$: $90$ samples.
Practice — Budget failure probability explicitly
Easy checks the basic operation; Medium connects steps; Hard asks you to justify a conclusion or identify a limitation. Each solution explains why the steps work.
Exercise C.S16 — Easy: One statement or all statements?
Three safety checks each fail with probability at most $0.01$. Give a lower bound on the probability that all three pass. Must the failures be independent?
Review if needed: this section and unions and quantifiers.
Show hint
Show worked solution
- Call the failure events $F_1,F_2,F_3$. The event that at least one check fails is $F_1\cup F_2\cup F_3$.
- The union bound gives $\mathbb P(F_1\cup F_2\cup F_3)\le0.01+0.01+0.01=0.03$.
- Take the complement: all pass with probability at least $0.97$. No independence is needed. Multiplying $0.99^3$ would require independence and would answer a stronger, differently assumed calculation.
Exercise C.S17 — Medium: A finite grid of confidence intervals
You want simultaneous confidence $0.95$ for $10$ sample means. Each uses $N$ independent observations in $[0,1]$ with a common mean $\mu_i$ within that data set, and must estimate its $\mu_i$ with absolute error at most $0.1$. Assign equal failure budgets and find a sufficient common $N$. The ten data sets may depend on one another.
Review if needed: this section and unions and quantifiers.
Show hint
Show worked solution
- Each mean receives failure budget $\delta_i=0.005$. Independence is required among the observations used for each application of Hoeffding.
- Solve $2e^{-0.02N}\le0.005$: $N\ge\ln(400)/0.02\approx299.5732$. Thus $300$ observations per mean suffice.
- The union bound adds ten failure budgets to $0.05$. It does not require the different means to be independent. A pointwise $95\%$ interval for each mean would provide only a $50\%$ lower bound for all ten together.
Exercise C.S18 — Hard: Guarantees at every time
For times $t=1,2,\dots$, assign failure budgets $\delta_t=0.05/[t(t+1)]$. Prove that all time-indexed statements hold together with probability at least $0.95$, provided each has failure probability at most $\delta_t$. Can you instead assign $0.05$ at every time?
Review if needed: this section and unions and quantifiers.
Show hint
Show worked solution
- The sum through time $T$ telescopes to $\sum_{t=1}^T\delta_t=0.05(1-1/(T+1))$.
- As $T\to\infty$, the total budget is $0.05$. The countable union bound therefore limits the probability of any failure, at any time, to $0.05$.
- A fixed budget $0.05$ per time sums to infinity, giving no useful simultaneous bound. For example, independent failures of probability $0.05$ eventually occur with probability one, since the probability of no failure through $T$ is $0.95^T\to0$.
7. Adaptive Data, Filtrations & Martingales
Think of a filtration as a notebook containing everything observed so far. A choice made from that notebook is fixed when conditioning on the past; new noise is still random. This is why adaptively chosen experiments can need conditional assumptions even when ordinary independent-sample formulas look familiar.
When ready, try the Easy, Medium and Hard practice for this section. For a prerequisite gap, review conditional expectation.
A safe-exploration algorithm chooses its next query $x_t$ from everything it has seen. The data $(x_1,y_1),(x_2,y_2),\dots$ are then neither independent nor identically distributed: $x_t$ depends on past noise, and so may the spread of the next measurement. What survives is a "fresh noise" property, and martingales are its language.
Why "zero-mean given the past" and not just "zero-mean". Let $\varepsilon_1=\pm1$ with probability $\tfrac12$ each and $\varepsilon_2=\varepsilon_1$ (the sensor repeats its error). Both have mean zero, but $\mathbb E[\varepsilon_2\mid\varepsilon_1]=\varepsilon_1\ne0$ and $\operatorname{Var}(\varepsilon_1+\varepsilon_2)=4$ instead of $2$: averaging does not cancel the error. Conversely, heteroscedastic noise $\varepsilon_t=s(x_t)\xi_t$ with fresh standard normal $\xi_t$ and adaptively chosen $x_t$ is not i.i.d., yet $\mathbb E[\varepsilon_t\mid\mathcal F_{t-1}]=s(x_t)\,\mathbb E[\xi_t]=0$ (take out what is known). For such sequences, and $s\lt t$, $\mathbb E[\varepsilon_s\varepsilon_t]=\mathbb E\big[\varepsilon_s\,\mathbb E[\varepsilon_t\mid\mathcal F_{t-1}]\big]=0$, so $\operatorname{Var}\sum_t\varepsilon_t=\sum_t\mathbb E\varepsilon_t^2$ exactly as for independent noise.
The method of mixtures: one bound for all times. Ville applied to $M^\lambda$ is time-uniform, but each fixed $\lambda$ is tuned to one scale of $S_t$. The remedy is to average over $\lambda$, since a nonnegative mixture of supermartingales is again one. With $R=1$ and $\lambda\sim\mathcal N(0,1/v)$, completing the square gives
Ville with $c=1/\delta$: with probability at least $1-\delta$, simultaneously for all $t$, $|S_t|\lt\sqrt{2(v+t)\big[\ln(1/\delta)+\tfrac12\ln(1+t/v)\big]}$, a sum self-normalised by its accumulated variance $v+t$. For $v=1$, $\delta=0.05$, $t=100$: $|S_t|\lt32.7$, against $27.2$ from Hoeffding valid at $t=100$ only, and $50.8$ from a union bound with $\delta_t=\delta/(t(t+1))$. Module 3 does the same in feature space: $v+t$ becomes the matrix $V+\sum_sX_sX_s^\top$ and $\sqrt{v/(v+t)}$ a determinant ratio, whose logarithm is, up to sign, the information gain of Section 8. Martingale noise also drives stochastic approximation: updates $\theta_{t+1}=\theta_t+\eta_t(h(\theta_t)+\varepsilon_t)$ with $\sum_t\eta_t=\infty$, $\sum_t\eta_t^2\lt\infty$ (Robbins–Monro), with martingale-difference noise of bounded conditional second moment, make the weighted noise series converge; together with stability and regularity assumptions they average out the noise $\sum_t\eta_t\varepsilon_t$ and, under further conditions, converge almost surely to stable zeros of $h$; primal-dual methods run two such recursions with step sizes decaying at different rates (two timescales).
Practice — Use only information available before the draw
Easy checks the basic operation; Medium connects steps; Hard asks you to justify a conclusion or identify a limitation. Each solution explains why the steps work.
Exercise C.S19 — Easy: A fair random walk
Let $\varepsilon_1,\varepsilon_2,\dots$ be independent fair signs, taking $-1$ and $1$ with equal probability. Put $S_t=\sum_{i=1}^t\varepsilon_i$, with $S_0=0$. What is $\mathbb E[S_{t+1}\mid\mathcal F_t]$, where $\mathcal F_t$ records the first $t$ signs?
Review if needed: this section and conditional expectation.
Show hint
Show worked solution
- Expand the next state: $S_{t+1}=S_t+\varepsilon_{t+1}$.
- Conditioning on $\mathcal F_t$ leaves the known term unchanged, while independence gives $\mathbb E[\varepsilon_{t+1}\mid\mathcal F_t]=0$.
- Thus $\mathbb E[S_{t+1}\mid\mathcal F_t]=S_t$. Each $S_t$ is integrable and determined by the recorded past, so these are the martingale conditions. The walk can move on every step despite having no conditional drift.
Exercise C.S20 — Medium: An adaptive multiplier can preserve zero drift
Before seeing a fair sign $\varepsilon_t$, choose $a_t=2$ if the current random-walk sum $S_{t-1}\ge0$, and $a_t=1$ otherwise. Define $D_t=a_t\varepsilon_t$. Show that $\mathbb E[D_t\mid\mathcal F_{t-1}]=0$ and find a valid conditional sub-Gaussian parameter.
Review if needed: this section and conditional expectation.
Show hint
Show worked solution
- $a_t$ is a function of the past, so it can be taken outside the conditional expectation: $\mathbb E[D_t\mid\mathcal F_{t-1}]=a_t\mathbb E[\varepsilon_t\mid\mathcal F_{t-1}]=0$.
- Given the past, $D_t$ lies in $[-a_t,a_t]$. Conditional Hoeffding certifies parameter $a_t$.
- Since $a_t\le2$, the uniform choice $R=2$ is valid at every time. The increments need not be independent; predictability and a conditional zero-mean bound are the properties used here.
Exercise C.S21 — Hard: Looking ahead breaks the argument
A learner first observes a fair sign $\varepsilon_t$ and then chooses $a_t=\varepsilon_t$. It claims that $D_t=a_t\varepsilon_t$ has mean zero because the original noise is fair. Compute its conditional mean and identify the failed step.
Review if needed: this section and conditional expectation.
Show hint
Show worked solution
- If $\varepsilon_t=1$, then $D_t=1$; if $\varepsilon_t=-1$, then $D_t=(-1)(-1)=1$. Thus $D_t=1$ surely.
- Consequently $\mathbb E[D_t\mid\mathcal F_{t-1}]=1$, and its accumulated sum grows deterministically rather than forming a zero-drift martingale.
- The multiplier was chosen using the new noise, so it is not known from $\mathcal F_{t-1}$. Pulling it outside that conditional expectation is invalid. Unconditional fairness of the original noise is insufficient after such a choice.
8. Entropy, KL Divergence, Total Variation & Mutual Information
Here the objects being compared are whole probability laws. For $p=(0.75,0.25)$ and $q=(0.5,0.5)$, the first outcome's probability changes by $0.25$. TV asks how much event probabilities can differ; KL averages logarithmic probability ratios and depends on direction.
When ready, try the Easy, Medium and Hard practice for this section. For a prerequisite gap, review discrete probability laws.
Worked example. The policy $(0.7,0.2,0.1)$ has $H=0.7\ln\frac1{0.7}+0.2\ln5+0.1\ln10=0.802$ nats ($1.157$ bits), below $\ln3=1.099$; a fair coin has $\ln2=0.693$; $\mathcal U(0,\tfrac12)$ has $h=\ln\tfrac12=-0.693\lt0$. An entropy bonus with a temperature rewards spread-out policies. The expected entropy reduction of a measurement $Y$ about $X$, $H(X)-\mathbb E_y[H(X\mid Y=y)]$, is the mutual information below. A model with low predictive entropy is confident, which is not the same as accurate.
Worked example (direction matters). $p=(0.5,0.5)$, $q=(0.9,0.1)$: $\mathrm{KL}(p\|q)=0.5\ln\frac{0.5}{0.9}+0.5\ln5=0.511$ but $\mathrm{KL}(q\|p)=0.9\ln1.8+0.1\ln0.2=0.368$. If $q=(1,0)$ excludes the second action, $\mathrm{KL}(p\|q)=\infty$ while $\mathrm{KL}(q\|p)=\ln2$: a new policy that tries an action the old one never takes is infinitely far in $\mathrm{KL}(\text{new}\|\text{old})$. From a uniform $q$ over $|\mathcal A|$ actions, $\mathrm{KL}(p\|q)=\log|\mathcal A|-H(p)\le\log|\mathcal A|$, the usual bound on an initial divergence.
Maximum likelihood is forward KL: $\mathbb E_{x\sim p^\ast}[\log q_\theta(x)]=-H(p^\ast)-\mathrm{KL}(p^\ast\|q_\theta)$, and $H(p^\ast)$ does not depend on $\theta$, so maximising the expected log-likelihood minimises $\mathrm{KL}(p^\ast\|q_\theta)$; a weighted likelihood $\sum_iw_i\log\pi_\theta(a_i\mid s_i)$ fits $\pi_\theta$ to the reweighted target in the same forward direction.
Variational inference and EM rest on the identity $\log p_\theta(x)=\mathbb E_{z\sim q}\big[\log\frac{p_\theta(x,z)}{q(z)}\big]+\mathrm{KL}\big(q\,\|\,p_\theta(z\mid x)\big)$ for any law $q$ of a latent $z$ with $\mathrm{KL}\big(q\,\|\,p_\theta(z\mid x)\big)\lt\infty$ (in particular, $q$ puts no mass where the posterior has none): the first term (the ELBO) is a lower bound on the log-likelihood, tight when $q$ is the posterior. (For other $q$ the ELBO is $-\infty$: the bound still holds, the identity would read $-\infty+\infty$.) EM alternates an E-step (set $q$ to the posterior, or fit it) and an M-step (maximise the ELBO over $\theta$).
Worked example. For $p=(0.5,0.5)$, $q=(0.9,0.1)$: $d_{\rm TV}=\tfrac12(0.4+0.4)=0.4$, and Pinsker gives $0.4\le\sqrt{0.511/2}=0.505$ and $0.4\le\sqrt{0.368/2}=0.429$. A trust region $\mathrm{KL}\le\epsilon$ therefore caps every event probability change at $\sqrt{\epsilon/2}$. If two laws of a whole data sequence are within $d_{\rm TV}=\epsilon$, then every event, such as "the test point is covered", changes probability by at most $\epsilon$; this compares laws, not the realised samples.
$f$-divergences generalise both: for convex $f$ with $f(1)=0$, $D_f(p\|q)=\sum_iq_if(p_i/q_i)=\mathbb E_q[f(p/q)]\ge0$ (Jensen), defined when $p_i=0$ wherever $q_i=0$. $f(w)=w\log w$ gives KL, $f(w)=\tfrac12|w-1|$ gives $d_{\rm TV}$, and $f(w)=\tfrac12(w-1)^2$ gives half the Pearson $\chi^2$ divergence $\sum_i(p_i-q_i)^2/q_i$ (for the example above, $\chi^2=0.4^2/0.9+0.4^2/0.1=1.78$). The Wasserstein-1 distance for laws on $\mathbb R$ with finite first absolute moments is $W_1(p,q)=\inf\mathbb E|X-Y|$ over couplings $=\sup\{\mathbb E_pg-\mathbb E_qg:\ g\ \text{1-Lipschitz}\}$ measures how far mass must move: for point masses at $0$ and $\epsilon\gt0$, $d_{\rm TV}=1$ and $\mathrm{KL}=\infty$, but $W_1=\epsilon$. Its 1-Lipschitz "critics" are why Lipschitz networks appear in Wasserstein GANs.
Worked example. Unit prior variances, $\sigma^2=0.25$ (so $\sigma^{-2}K=4K$). Two uncorrelated points: $\tfrac12\ln\det(5I)=\tfrac12\ln25=1.609$ nats. Correlation $0.5$: $\det\begin{bmatrix}5&2\\2&5\end{bmatrix}=21$, $\tfrac12\ln21=1.522$: correlated measurements tell us less. The same point twice: $\det\begin{bmatrix}5&4\\4&5\end{bmatrix}=9$, $\tfrac12\ln9=\tfrac12\ln(1+2\cdot4)=1.099$, exactly one measurement with noise variance $\sigma^2/2$. On a one-point domain $\gamma_T=\tfrac12\ln(1+4T)$: $0.80$, $1.86$, $3.00$ nats for $T=1,10,100$. Such slow growth is best seen on a logarithmic axis, where equal vertical steps mean equal ratios.
Practice — Compare distributions, not individual samples
Easy checks the basic operation; Medium connects steps; Hard asks you to justify a conclusion or identify a limitation. Each solution explains why the steps work.
Exercise C.S22 — Easy: Entropy of a fair and a biased coin
Using natural logarithms, compute the entropy of a fair Bernoulli variable and a Bernoulli variable with success probability $1/4$. Use $H(p)=-p\ln p-(1-p)\ln(1-p)$.
Review if needed: this section and discrete probability laws.
Show hint
Show worked solution
- For the fair coin, both terms are $-(1/2)\ln(1/2)$, so $H(1/2)=\ln2\approx0.693147$ nats.
- For the biased coin, $H(1/4)=-(1/4)\ln(1/4)-(3/4)\ln(3/4)\approx0.562335$ nats.
- The fair coin has higher entropy because its result is less predictable. These numbers use natural logs; base-two logs would express the same information in bits.
Exercise C.S23 — Medium: Total variation and directional KL
For $p=(0.75,0.25)$ and $q=(0.5,0.5)$, compute $\operatorname{TV}(p,q)$, $D_{\rm KL}(p\|q)$ and $D_{\rm KL}(q\|p)$.
Review if needed: this section and discrete probability laws.
Show hint
Show worked solution
- $\operatorname{TV}(p,q)=(|0.75-0.5|+|0.25-0.5|)/2=0.25$.
- $D_{\rm KL}(p\|q)=0.75\ln(1.5)+0.25\ln(0.5)\approx0.130812$ nats.
- Reversing the weights gives $D_{\rm KL}(q\|p)=0.5\ln(2/3)+0.5\ln2\approx0.143841$. The unequal answers show that KL is directional; it is not a distance metric.
Exercise C.S24 — Hard: Support mismatch and a useless KL bound
Let $p=(1,0)$ and $q=(0.5,0.5)$. Compute both KL directions and TV, using the convention $0\ln(0/q)=0$. Apply Pinsker to the finite KL direction.
Review if needed: this section and discrete probability laws.
Show hint
Show worked solution
- $D_{\rm KL}(p\|q)=1\ln(1/0.5)+0=\ln2\approx0.693147$.
- $D_{\rm KL}(q\|p)=+\infty$, because the second outcome has $q$-probability $0.5$ but $p$-probability zero. TV is still finite: $(0.5+0.5)/2=0.5$.
- Pinsker gives $\operatorname{TV}(p,q)\le\sqrt{\ln2/2}\approx0.588705$, consistent with $0.5$ but not exact. Applying it to the infinite direction would provide no information.
9. Quantiles, Value-at-Risk & CVaR
A quantile is a threshold; CVaR is a tail average. With probability mass at a threshold, selecting the worst $10\%$ can require taking only part of that mass. Draw or list the CDF before using a conditional-tail shortcut.
When ready, try the Easy, Medium and Hard practice for this section. For a prerequisite gap, review CDFs and atoms.
Worked example (splitting an atom). Let $Z\in\{0,1,5\}$ with probabilities $0.7,0.2,0.1$. Then $F^{-1}(u)=0$ on $(0,0.7]$, $1$ on $(0.7,0.9]$ and $5$ on $(0.9,1)$ (figure), and $\mathbb E[Z]=\int_0^1F^{-1}=0.2+0.5=0.7$. At $\alpha=0.85$: $\operatorname{VaR}_{0.85}=1$ and $\operatorname{CVaR}_{0.85}=\frac{0.05\cdot1+0.1\cdot5}{0.15}=3.67$. The atom at $1$ occupies $u\in(0.7,0.9]$ and only its top $0.05$ lies in the tail: it is included fractionally. The naive $\mathbb E[Z\mid Z\ge\operatorname{VaR}]=0.7/0.3=2.33$ is wrong here; it equals CVaR when $F$ is continuous at the quantile.
Gaussian CVaR. For $Z\sim\mathcal N(\mu,\sigma^2)$, $\operatorname{VaR}_\alpha=\mu+\sigma\Phi^{-1}(\alpha)$ and, from $\mathbb E[Z\mid Z\ge q]=\mu+\sigma\varphi(z_q)/(1-\Phi(z_q))$ with $z_q=(q-\mu)/\sigma$, $\operatorname{CVaR}_\alpha=\mu+\sigma\,\varphi(\Phi^{-1}(\alpha))/(1-\alpha)$; at $\alpha=0.95$ this is $\mu+2.063\,\sigma$. Papers that write $\alpha$ for the tail fraction print $\mu+\sigma\varphi(\Phi^{-1}(\alpha))/\alpha$, the same quantity since $\varphi$ is even. In a Gaussian cost critic written $\mathcal N(Q_c^\pi,V_c^\pi)$ the second argument $V_c^\pi$ is a variance (take its square root), not the cost value function.
Chance, expectation and CVaR constraints. For an episode cost $Z$: $\mathbb E[Z]\le d$ constrains the average, $\mathbb P(Z\gt0)\le\delta$ (equivalently $\operatorname{VaR}_{1-\delta}(Z)\le0$) the frequency of failure, and $\operatorname{CVaR}_\alpha(Z)\le d$ frequency and magnitude together. If $Z=100$ with probability $0.01$ and $0$ otherwise: $\mathbb E[Z]=1$, $\mathbb P(Z\gt0)=0.01$ and $\operatorname{CVaR}_{0.95}(Z)=\frac{0.01\cdot100}{0.05}=20$: with budget $d=2$ and level $\delta=0.05$ the mean and chance constraints hold, and only the CVaR constraint ($20\gt2$) sees the rare catastrophe. A finite-horizon chance constraint $\mathbb P(\forall t\in\{1,\dots,T\}:\ s_t\in\mathcal S)\ge1-\delta$, with $T\ge1$ and $s_0\in\mathcal S$ almost surely, concerns the whole trajectory; it is implied by per-step levels $\delta/T$ (Section 6) and by an expected number of violations $\mathbb E[N]\le\delta$ (Section 1).
Empirical quantiles, robust summaries and expectiles. Sorting $N$ observed values gives empirical quantiles (median, quartiles). The interquartile mean averages the middle $50\%$ and is robust to outlying runs; a bootstrap interval resamples the $N$ runs with replacement many times and reads off percentiles of the recomputed statistic. These describe one random experiment; they are not bounds on the next network or seed. Quantiles minimise an asymmetric absolute loss: for integrable $Z$, $\operatorname{VaR}_\tau\in\arg\min_m\mathbb E[(\tau-\mathbf 1\{Z\lt m\})(Z-m)]$, where the minimisers form an interval of $\tau$-quantiles whose smallest point is $F^{-1}(\tau)$ (for $Z\in\{0,1\}$ with probabilities $\tfrac12,\tfrac12$ and $\tau=\tfrac12$ every $m\in[0,1]$ minimises). For $\mathbb E[Z^2]\lt\infty$ the $\tau$-expectile minimises the asymmetric squared loss $\mathbb E[|\tau-\mathbf 1\{Z\lt m\}|(Z-m)^2]$. $\tau=\tfrac12$ gives the mean, and as $\tau\to1$ ($\tau\to0$) the expectile tends to the essential supremum (infimum), which is how offline RL approximates a maximum (minimum) over actions seen in the data.
Practice — Read a tail with discrete atoms
Easy checks the basic operation; Medium connects steps; Hard asks you to justify a conclusion or identify a limitation. Each solution explains why the steps work.
Exercise C.S25 — Easy: Find the first threshold reaching the target
A loss $L$ equals $0$, $10$, $100$ with probabilities $0.8$, $0.15$, $0.05$. Using $\operatorname{VaR}_\alpha(L)=\inf\{z:F_L(z)\ge\alpha\}$, find VaR at levels $0.8$, $0.9$ and $0.95$.
Review if needed: this section and CDFs and atoms.
Show hint
Show worked solution
- The CDF reaches $0.8$ at loss $0$, $0.95$ at loss $10$, and $1$ at loss $100$.
- The first threshold reaching $0.8$ is $0$, so $\operatorname{VaR}_{0.8}=0$. The first reaching $0.9$ is $10$, so $\operatorname{VaR}_{0.9}=10$.
- At level $0.95$, equality at $10$ suffices, giving $\operatorname{VaR}_{0.95}=10$. This quantile convention matters at atoms: a $5\%$ chance of loss $100$ remains beyond that threshold.
Exercise C.S26 — Medium: Take the worst ten percent, including part of an atom
For the same law, compute $\operatorname{CVaR}_{0.9}(L)$ as the average of the worst $10\%$ of probability mass. Compare it with $\mathbb E[L]$ and with $\mathbb E[L\mid L\ge10]$.
Review if needed: this section and CDFs and atoms.
Show hint
Show worked solution
- The worst $10\%$ consists of mass $0.05$ at $100$ and mass $0.05$ at $10$. Its mean is $(0.05(100)+0.05(10))/0.1=55$.
- The full mean is $0.8(0)+0.15(10)+0.05(100)=6.5$.
- Conditioning on $L\ge10$ instead uses $20\%$ mass and gives $6.5/0.2=32.5$. It is not CVaR: the atom at VaR must be split to select precisely the desired tail mass.
Exercise C.S27 — Hard: Verify the optimisation formula at a kink
For the same loss, minimise $g(\nu)=\nu+10\mathbb E[(L-\nu)^+]$, where $z^+=\max(z,0)$. Find its slopes on $(-\infty,0)$, $(0,10)$, $(10,100)$ and $(100,\infty)$, and its minimum.
Review if needed: this section and CDFs and atoms.
Show hint
Show worked solution
- The tail probabilities on the four intervals are $1$, $0.2$, $0.05$ and $0$, so the slopes are respectively $-9$, $-1$, $0.5$ and $1$.
- The function decreases up to $10$ and increases after $10$, so its minimum occurs at the kink $\nu=10$.
- Only loss $100$ contributes a positive excess there: $\mathbb E[(L-10)^+]=0.05(90)=4.5$. Hence $g(10)=10+10(4.5)=55$, agreeing with the split-tail calculation. A derivative need not exist at the minimiser.
10. Binomial Tails, Hypothesis Tests & Exchangeability
A test specifies which random data would count against a fixed hypothesis. With no failures in four independent runs, the likelihood under failure probability $p$ is $(1-p)^4$. This is a probability of data given a parameter, not a posterior probability of that parameter.
When ready, try the Easy, Medium and Hard practice for this section. For a prerequisite gap, review conditional probabilities.
Worked example (binomial tails and the scenario bound). For $n=20$, $p=0.1$: $\mathbb P(K=0)=0.9^{20}=0.122$ and $\mathbb P(K\le1)=0.122+20\cdot0.1\cdot0.9^{19}=0.392$. For the scenario bound, let $\theta_N^\ast$ solve a convex program in $d$ decision variables whose $N$ constraints are sampled i.i.d. from $P$, and let $V(\theta)$ be the probability that the constraint of a fresh sample is violated by $\theta$. If every such program is feasible (with nonempty interior) and has a unique solution (or a fixed tie-break rule), the scenario theorem (Module 15) gives $P^N\{V(\theta_N^\ast)\gt\epsilon\}\le\sum_{i=0}^{d-1}\binom Ni\epsilon^i(1-\epsilon)^{N-i}$, exactly the lower tail $\mathbb P(\mathrm{Bin}(N,\epsilon)\le d-1)$: for $d=2$, $\epsilon=0.05$ it is $0.037$ at $N=100$, and $N=181$ is the first sample size that brings it below $10^{-3}$. The scalar case $d=1$ is the max-of-samples bound of Section 6; keeping the $(r+1)$-th largest of $m$ samples instead of the maximum changes the failure probability to $\mathbb P(\mathrm{Bin}(m,\gamma)\le r)$.
Worked example. $95$ successes in $100$ at $\alpha=0.05$: $p_L=0.898$, whereas the normal approximation $0.95-1.645\cdot0.0218=0.914$ is over-optimistic. $100$ successes in $100$ at $\alpha=0.001$: $p_L=0.001^{1/100}=0.933$; with $n=10^4$ it is $0.99931$, approaching $1$ only like $1-\ln(1/\alpha)/n$. In randomized smoothing the certified radius is $\sigma\Phi^{-1}(p_L)$, e.g. $0.5\cdot\Phi^{-1}(0.933)=0.75$.
Worked example (an event trigger). Under the null model the standardised residual $r_t=(y_t-\mu_{t-1}(x_t))/\sqrt{\sigma_{t-1}^2(x_t)+\sigma^2}$ is $\mathcal N(0,1)$. Triggering a reset when $|r_t|\gt3$ gives false-alarm probability $0.0027$ per step, i.e. $2.7$ expected false alarms in $1000$ unchanged steps. To keep the probability of any false alarm over $1000$ steps below $0.05$ (union bound), test each step at $5\cdot10^{-5}$: $|r_t|\gt\Phi^{-1}(1-2.5\cdot10^{-5})=4.06$.
Beta laws, the probability integral transform and conditional coverage. For $a,b\gt0$, the Beta$(a,b)$ law on $[0,1]$ has density proportional to $x^{a-1}(1-x)^{b-1}$, mean $\frac a{a+b}$ and variance $\frac{ab}{(a+b)^2(a+b+1)}$ (Beta$(1,11)$ was the posterior in Section 2).
If $S$ has a continuous CDF $F$, then $F(S)\sim\mathcal U(0,1)$ (the probability integral transform), and the $k$-th smallest of $n$ i.i.d. uniforms is Beta$(k,n+1-k)$. So if the calibration and test scores are i.i.d. with a continuous CDF $F$ (the score function fixed beforehand, e.g. fitted on separate data) and $1\le k\le n$, the coverage of one fixed calibration set, $C=\mathbb P(S_{n+1}\le S_{(k)}\mid S_1,\dots,S_n)=F(S_{(k)})$, is Beta$(k,n+1-k)$ whatever $F$ is.
Exchangeability with almost surely distinct scores fixes only its mean $\mathbb E[C]=\frac k{n+1}$ (with $S_2=1-S_1$, $S_1\sim\mathcal U(0,1)$, the pair is exchangeable, but for $n=k=1$ the coverage is $\mathbf 1\{S_1\ge\tfrac12\}$, not uniform).
For $n=19$, $k=18$: mean $0.9$, standard deviation $0.065$, and $\mathbb P(C\lt0.8)=19\cdot0.8^{18}\cdot0.2+0.8^{19}=0.083$. Testing on $m=2000$ fresh points adds binomial noise; by total variance (Section 2) the measured coverage has variance $\operatorname{Var}C+\mathbb E[C(1-C)]/m=0.00429+0.00004$, which equals $p(1-p)\frac{n+1+m}{m(n+2)}$ with $p=\frac k{n+1}$: the calibration set, not the test set, dominates the spread.
Practice — Separate a test outcome from its coverage
Easy checks the basic operation; Medium connects steps; Hard asks you to justify a conclusion or identify a limitation. Each solution explains why the steps work.
Exercise C.S28 — Easy: Exactly two failures
Four independent runs each fail with probability $0.1$. Find the probability of exactly two failures and the probability of at least one failure.
Review if needed: this section and conditional probabilities.
Show hint
Show worked solution
- A specified pair failing while the other two pass has probability $0.1^2(0.9)^2=0.0081$.
- There are $\binom42=6$ distinct pairs, so exactly two failures has probability $6(0.0081)=0.0486$.
- Zero failures has probability $0.9^4=0.6561$. Thus at least one has probability $1-0.6561=0.3439$. Independence is what permits these products.
Exercise C.S29 — Medium: Zero failures still leaves uncertainty
Observe zero failures in $100$ independent runs with a fixed unknown failure probability $p$. Find the exact one-sided $95\%$ upper confidence limit by solving $(1-p_U)^{100}=0.05$. Interpret it without assigning a posterior probability to $p$.
Review if needed: this section and conditional probabilities.
Show hint
Show worked solution
- Solving gives $p_U=1-0.05^{1/100}\approx0.029513$.
- If a proposed true $p$ exceeds this limit, seeing zero failures would have probability below $0.05$. Inverting these tests gives the upper confidence-limit procedure.
- The parameter $p$ is fixed in this frequentist statement; the data and reported limit are random. This is not a claim that the fixed $p$ has posterior probability $0.95$ of lying below the observed limit. In particular, zero observed failures does not prove $p=0$.
Exercise C.S30 — Hard: Ranks, ties and marginal coverage
There are $19$ calibration scores and one future score. Assume all $20$ scores are jointly exchangeable and distinct almost surely. A prediction rule accepts the future point when its score is at most the $18$th smallest calibration score. Find its marginal acceptance probability. Why need this not be $90\%$ for each subgroup?
Review if needed: this section and conditional probabilities.
Show hint
Show worked solution
- Exchangeability and absence of ties make the future score's rank uniform on $1,\dots,20$.
- It is at most the $18$th calibration score exactly when its overall rank is at most $18$. Hence acceptance probability is $18/20=0.9$.
- This averages over calibration data and the future point. For example, two equally common subgroups with conditional coverages $0.8$ and $1$ also average to $0.9$. Marginal coverage alone does not guarantee either subgroup's target, or conditional coverage for the observed calibration set.
Interactive: Concentration & Gaussian Conditioning
Part A draws 2000 independent samples of size up to $400$ from a law on $[0,1]$ (seeded, so results reproduce) and compares the observed frequency of a deviation $|\bar X_N-m|\ge t$ with Chebyshev, Hoeffding and the normal approximation. Part B conditions a 2-D Gaussian with standard deviations $\sigma_x,\sigma_y$ and correlation $\rho$ (Section 1) on $y=y_0$ with the Schur complement and checks the formula against the samples that fall in a thin slab around $y_0$.
Left: histogram of the 2000 sample means at the chosen $N$, the band $m\pm t$ (green) and the normal approximation $\mathcal N(m,\sigma^2/N)$ (grey). Right: $\mathbb P(|\bar X_N-m|\ge t)$ against $N$, both axes logarithmic: observed frequencies (teal; hollow on the floor when no run deviated), Chebyshev $\sigma^2/(Nt^2)$ (orange), Hoeffding $2e^{-2Nt^2}$ (blue), normal approximation (grey, dashed); the red line marks the chosen $N$.
Left: $3000$ seeded samples of $(x,y)$ with $x=\sigma_xz_1$, $y=\sigma_y(\rho z_1+\sqrt{1-\rho^2}z_2)$; ellipses of Mahalanobis radius $1$ and $2$ (blue); the slab $|y-y_0|\lt0.1\sigma_y$ (orange points); the regression line $x=\mathbb E[x\mid y]$ (purple, dashed); the conditional mean (red ring). Right: prior density of $x$ (grey, dashed), conditional density from the Schur complement (orange) and histogram of $x$ over the slab.
What to look for. (A) The true deviation probability stays below both bounds, for every law: they are guarantees for anything with values in $[0,1]$. The observed frequency only estimates it from $2000$ runs, so where a bound drops below about $10^{-3}$ one or two deviating runs can lift the observed frequency above it (seed 1, Bernoulli$(0.5)$, $N=215$, $t=0.15$: $1/2000$ against Hoeffding's $1.3\cdot10^{-4}$). Chebyshev decays like $1/N$ and Hoeffding exponentially; at $t=0.1$ Chebyshev is still the tighter one up to $N\approx191$ for the uniform law (whose variance $1/12$ is far below the worst case $1/4$ that Hoeffding implicitly assumes), after which Hoeffding wins. The normal approximation follows the dots for smooth laws but is not a bound: for Bernoulli$(0.1)$ at $N=10$ the true deviation probability is $0.61$ while the approximation says $0.29$.
Gaussian conditioning panel. Dragging $y_0$ moves the conditional mean along the purple line but leaves the conditional variance $\sigma_x^2(1-\rho^2)$ unchanged; at $\rho=0$ the observation changes nothing, and as $|\rho|\to1$ it pins $x$ down. The slab statistics agree with the formula up to sampling error plus a small bias, because a slab of finite width is not the line $y=y_0$ (at the default settings the exact slab mean is $0.997$ instead of $1$, far inside the sampling error of about $0.06$); far in the tail the slab empties, and only the formula still works.
From the mathematics to a real decision
A probability calculation becomes useful when it changes an action. A sensor reading alone does not say whether to stop a process: that also depends on how often trouble occurs, how the sensor behaves, and what each action costs. This chapter follows that chain from assumptions to a decision, then transfers it to calibration and repeated operation. All numbers below define hypothetical models; they are not measurements of a particular machine.
- Combine a base rate and a sensor model before choosing an action.
- Translate posterior uncertainty into a tolerance statement with physical units.
- Distinguish independent measurement noise from uncertainty shared by repeated measurements.
- Separate a model probability, a statistical confidence statement, and an all-outcomes guarantee.
Begin with the decision, then describe the uncertainty
Imagine a small conveyor carrying sealed packages. A hidden fault can cause a package to jam the next station. Before releasing each package, a sensor either raises an alarm or stays quiet. Inspection takes time but finds and removes the fault perfectly in this simplified model. The operator must decide whether to inspect after seeing the sensor result.
Write $F$ for the event that the package is faulty and $A$ for an alarm. Assume the fault probability is $0.04$, the sensor alarms on $90\%$ of faulty packages, and it alarms on $8\%$ of sound packages. These are three different quantities: $\mathbb P(F)=0.04$, $\mathbb P(A\mid F)=0.90$, and $\mathbb P(A\mid F^c)=0.08$. The complement $F^c$ means sound. No independence assumption between the fault and the alarm is appropriate: detecting dependence is the sensor's purpose.
Measure consequences in a chosen unit of equivalent operating cost. Inspection costs $6$ units, whether or not a fault is present. Releasing a faulty package costs $30$ units; releasing a sound one costs zero. These values express the hypothetical operator's priorities. A different loss for a jam would legitimately produce a different decision from the same probabilities.
After information $I$, let $p_I=\mathbb P(F\mid I)$. The conditional expected losses of inspection and release are $6$ and $30p_I$. Minimising expected loss therefore means inspecting when $30p_I\gt6$, or equivalently $p_I\gt0.20$. At equality both actions have the same expected loss in this model.
This threshold does not promise that a released package is sound. It specifies a tradeoff in expectation. If even one jam is unacceptable, replace the objective with that requirement before calculating; a small expected cost is a different mathematical claim.
Worked example 1 — Should an alarm trigger inspection?
Step 1: construct joint probabilities. Multiplication converts a conditional rate into a fraction of all packages. Faulty packages with alarms have probability $0.04(0.90)=0.036$. Sound packages with alarms have probability $0.96(0.08)=0.0768$. Adding these disjoint possibilities gives $\mathbb P(A)=0.1128$.
Step 2: condition on what was observed. Among the packages that alarm, the faulty fraction is the faulty-and-alarm probability divided by the entire alarm probability:
The second calculation uses missed faults and all quiet packages. Each denominator describes the information actually available at the decision time.
Step 3: compare actions in each information state. After an alarm, release has expected loss $30(0.31915)\approx9.5745$ units, exceeding inspection's $6$. After silence, release costs only about $0.1353$ units in expectation. The optimal rule is therefore inspect on an alarm and release after silence.
Step 4: evaluate the entire rule. Inspection occurs with probability $0.1128$. A faulty package is released only when the fault is missed, with probability $0.004$. The expected cost per package is consequently
Always releasing costs $30(0.04)=1.2$ units per package; always inspecting costs $6$. The sensor-based rule improves the stated objective compared with either constant action. This conclusion depends on the inspection model, cost values, and probabilities remaining applicable to the incoming packages.
“The sensor catches $90\%$ of faults, so an alarm means a $90\%$ fault probability” reverses the conditioning. The $90\%$ denominator is all faulty packages; the decision concerns all alarming packages. Repair the calculation by constructing both routes into the alarm group. Even a capable detector can produce many false alarms when sound packages are common.
Worked example 2 — Combine calibration measurements without double counting
Now consider a displacement sensor with one unknown fixed offset $\theta$, measured in millimetres. Before calibration, model $\theta\sim\mathcal N(0,4)$; the variance has units $\mathrm{mm}^2$. Two reference measurements satisfy $y_1=\theta+\varepsilon_1$ and $y_2=\theta+\varepsilon_2$, where the noises have distributions $\mathcal N(0,1)$ and $\mathcal N(0,4)$. Assume both noises are independent of one another and of $\theta$. The hypothetical observed values are $y_1=2$ mm and $y_2=-1$ mm.
Step 1: identify the shared quantity. Both measurements observe the same offset. They are independent conditional on $\theta$, but not independent before conditioning: $\operatorname{Cov}(y_1,y_2)=\operatorname{Var}(\theta)=4\ \mathrm{mm}^2$. Averaging the readings as if they were unrelated draws of the offset would misdescribe the experiment.
Step 2: collect the quadratic terms. The prior density and two likelihoods multiply. Ignoring positive factors that do not depend on $\theta$, their negative twice-log-density is
The coefficient of $\theta^2$ is the posterior precision, the reciprocal of variance. Completing the square gives $\tfrac32(\theta-\tfrac76)^2$ plus a constant. Thus the posterior mean is $m=7/6$ mm and the posterior variance is $s^2=2/3\ \mathrm{mm}^2$. Equivalently, add precisions $1/4+1+1/4=3/2$ and precision-weighted observations $0/4+2/1-1/4=7/4$, then divide $7/4$ by $3/2$.
Step 3: specify the correction and requirement. Subtract $c=m$ from future readings to correct this fixed offset. The residual offset $\theta-c$ has posterior mean zero and standard deviation $s=\sqrt{2/3}\approx0.8165$ mm. Suppose the requirement concerns the offset alone: its magnitude should be at most $2$ mm with posterior probability at least $0.98$.
Step 4: interpret the result. The correction meets that posterior requirement under the Gaussian model. The statement concerns uncertainty in the fixed offset, conditional on these readings. A new noisy reading contains fresh measurement noise as well; its error needs a predictive variance, considered in the exercises. Neither statement is a hard bound: Gaussian distributions allow arbitrarily large errors.
Apply the model to a changed decision
Attempt each question before opening its hint. State the event or random variable being bounded before choosing a formula. These applications deliberately change a decision or assumption rather than ask for another isolated probability calculation.
Exercise C.B1 — Easy: A new production line changes the inspection decision
Keep the sensor rates and costs from example 1, but change the incoming fault probability to $0.01$. Should an alarm still trigger inspection? Compare always releasing with retaining the old inspect-on-alarm rule.
Review: conditional probability and Bayes; the inspection decision.
Show hint
Recompute both routes into an alarm, then compare the posterior fault probability with $0.20$.
Show worked solution
The alarm probability is $0.01(0.90)+0.99(0.08)=0.0882$. Its fault probability is $0.009/0.0882=5/49\approx0.10204$. Release after an alarm costs $30(5/49)\approx3.0612$, below $6$, so release is preferred. Silence has an even smaller fault probability, $0.001/0.9118\approx0.001097$, and also favours release. Always releasing costs $30(0.01)=0.30$ units. The old rule costs $6(0.0882)+30(0.001)=0.5592$. Reusing an unchanged rule can therefore increase expected cost after the base rate changes.
Exercise C.B2 — Medium: Offset uncertainty is not reading uncertainty
After example 2, a new measurement has zero-mean Gaussian noise $\varepsilon_{\mathrm{new}}\sim\mathcal N(0,1\ \mathrm{mm}^2)$, independent of the offset and calibration noises. After subtracting the posterior mean offset, what is the probability that its total error lies within $2$ mm? Does the $0.98$ requirement hold for this new quantity?
Review: Gaussian conditioning and standardisation; the calibration model.
Show hint
The total error is $\theta-m+\varepsilon_{\mathrm{new}}$. Add the variances of these independent Gaussian terms conditional on the calibration data.
Show worked solution
The predictive mean is zero and variance is $2/3+1=5/3\ \mathrm{mm}^2$. Its standard deviation is $\sqrt{5/3}\approx1.2910$ mm. Standardisation gives probability $2\Phi(2/\sqrt{5/3})-1\approx0.87866$. It fails the $0.98$ requirement. Correcting the mean offset removes neither uncertainty about that offset nor fresh measurement noise. The earlier $0.98569$ probability answered a narrower question.
Exercise C.B3 — Hard: Repeated use shares the same uncertain offset
Average $100$ new corrected readings of the same fixed displacement after example 2. Their zero-mean noises are mutually independent and independent of the offset and calibration noises, each with variance $1\ \mathrm{mm}^2$. Find the average's error variance and its limiting value as the number of readings grows. Explain why the variance is not $(5/3)/100$.
Review: variance and covariance; shared offset uncertainty.
Show hint
Write the average error as one shared offset error plus an average of fresh noises. Only the second term is averaged away.
Show worked solution
For $n$ readings the average error is $(\theta-m)+n^{-1}\sum_{i=1}^n\varepsilon_i$. Independence gives variance $2/3+1/n$, hence $203/300\approx0.67667\ \mathrm{mm}^2$ at $n=100$. The limiting variance is $2/3$, with standard deviation about $0.8165$ mm. Distinct reading errors have covariance $2/3$ because they share the offset. Dividing each reading's entire variance by $100$ incorrectly assumes those errors are independent. Better calibration, rather than more repeated readings of an unknown displacement, is needed to reduce this uncertainty floor.
Exercise C.B4 — Hard: Plan a batch reliability requirement
A revised inspection process has an assumed per-package escape probability $q$. Require the probability of any escaped fault in a batch of $50$ packages to be at most $0.02$. Find a sufficient bound on $q$ without independence. If escapes are independent with equal probability, find the exact largest $q$. Does example 1's $q=0.004$ meet either bound?
Review: union bounds and simultaneous events; the escape probability.
Show hint
Use a union bound first. Under independence, compute the probability that all $50$ packages avoid an escape.
Show worked solution
The union bound gives batch failure probability at most $50q$, so $q\le0.02/50=0.0004$ is sufficient. Independence gives exact probability $1-(1-q)^{50}$; solving $1-(1-q)^{50}\le0.02$ yields $q\le1-0.98^{1/50}\approx0.000403973$. Example 1 exceeds both limits. Under independence its batch failure probability is $1-0.996^{50}\approx0.18160$. The slightly larger exact allowance relies on independence; the union-bound allowance does not. These are calculations under assumed rates, not confidence bounds inferred from test data.
Recall the claim before trusting the number
Close the examples and explain why an alarm's accuracy is insufficient to choose an action, why two calibration readings can share uncertainty despite independent noises, and why an offset tolerance differs from a reading tolerance. Then identify which quantity is averaged over packages, which is uncertain after calibration, and which is an event covering an entire batch.
The reusable sequence is: define the decision and units; state the random model; condition on available information; compare the quantities required by the objective; write the conclusion with its assumptions. Continue to Gaussian-process regression to extend Gaussian conditioning across inputs, or to risk constraints to compare average and tail requirements. When the decision changes a physical trajectory, Primer D's state-space models supply the next layer.
Exercises
These cumulative problems connect several ideas. If a step feels too large, return to the section practice route, where each topic has an Easy, Medium and Hard problem with a separate hint, worked solution and prerequisite review link.
Further Reading
| Resource | What to read it for |
|---|---|
| Blitzstein & Hwang, Introduction to Probability, 2nd ed., CRC Press 2019 (free online) | Sections 1–3: random variables, conditioning, Markov chains, inequalities; many worked problems |
| Pishro-Nik, Introduction to Probability, Statistics, and Random Processes, Kappa Research 2014 (open access) | Sections 1, 4, 6, 10: CDFs and mixed laws, the multivariate normal, confidence intervals, hypothesis tests |
| Rasmussen & Williams, Gaussian Processes for Machine Learning, MIT Press 2006 (free PDF) | Section 4: Gaussian identities (Appendix A), GP regression (Ch. 2), marginal likelihood (Ch. 5) |
| Vershynin, High-Dimensional Probability, Cambridge University Press 2018; 2nd ed. 2026 (free PDF) | Section 5: sub-Gaussian variables, Hoeffding and Chernoff bounds |
| Lattimore & Szepesvári, Bandit Algorithms, Cambridge University Press 2020 (free PDF) | Sections 5 and 7: Ch. 5 (concentration, sub-Gaussianity), Ch. 3 (martingales, stopping times), Ch. 20 (the method of mixtures) |
| Williams, Probability with Martingales, Cambridge University Press 1991 | Section 7: filtrations, conditional expectation, optional stopping, done rigorously |
| Levin & Peres (with Wilmer), Markov Chains and Mixing Times, 2nd ed., AMS 2017 (free PDF) | Section 3: stationary distributions, convergence, transience |
| Cover & Thomas, Elements of Information Theory, 2nd ed., Wiley 2006 | Section 8: entropy, KL, mutual information, differential entropy of Gaussians |
| Rockafellar & Uryasev, “Optimization of conditional value-at-risk”, Journal of Risk 2(3), 2000 | Section 9: the CVaR minimisation formula |
| Wasserman, All of Statistics, Springer 2004 | Sections 6 and 10: confidence intervals, tests, the bootstrap, compactly |
| Angelopoulos & Bates, “A Gentle Introduction to Conformal Prediction and Distribution-Free Uncertainty Quantification”, arXiv 2021 | Section 10: exchangeability, split conformal, conditional coverage |