Module 04
Probability
How do we model uncertainty and random phenomena mathematically?
- lessons
- 24
- duration
- 38 h 30 min
- concepts
- 146
- available in English
- 24 / 24
- completed by you
0 of 24
Where it fits
Overview
Rigorous probability at the level needed by an ML researcher, from Kolmogorov's model and measure theory (σ-algebras, the Lebesgue integral, Radon-Nikodym and conditional expectation) to distributions, a thorough treatment of the multivariate Gaussian and limit theorems. Concentration inequalities run from Markov to McDiarmid and Johnson-Lindenstrauss, followed by distribution distances and random matrices at the frontier. Each result is proved or sketched, visualized and implemented in NumPy.
Why it matters
Modern machine learning rests on applied probability: GPT loss is an autoregressive log-likelihood, diffusion chains Gaussian conditionals, AlphaZero averages uncertain rewards, and quantitative strategies depend on tails and dependence. Concentration bounds say how much data is needed and when a benchmark can be trusted. Measure theory helps you read papers on generative models, RL and learning theory without stumbling over nonexistent densities or gradients that cannot be interchanged with expectation.
Lessons 24
- 01Probability spaces and Kolmogorov's axiomsA dense review of the Kolmogorov model: a sample space, a family of events and a measure satisfying three axioms. Derive the consequences most used in ML (monotonicity, inclusion–exclusion, the union bound and continuity) and apply them to hash collisions. The rigorous version of a family of events arrives in lesson 3.
- 02Conditional probability, Bayes' theorem and independenceConditioning renormalizes the measure over what is known. Review the chain rule, total probability and Bayes’ theorem in odds and log-odds form, using a low-base-rate security-alert triage example. Finish with subtleties of independence: pairwise versus mutual, conditional versus marginal, and Berkson’s paradox.
- 03Measure theory I: σ-algebras and measuresWhy probability cannot be assigned to every subset of [0,1] and the minimum structure required of events. Construct generated σ-algebras, the Borel σ-algebra, measures and Lebesgue measure via Carathéodory extension, using Dynkin’s π-λ theorem for uniqueness. Interpret a σ-algebra as available information from the outset.
- 04Random variables, laws and distribution functionsA random variable is a measurable function, and its law is the pushforward measure it induces. The distribution function characterizes the law; the quantile function inverts it and enables simulation from a uniform. Classify laws as discrete, absolutely continuous or singular, and interpret σ(X) as the information revealed by X.
- 05The Lebesgue integral and expectationExpectation is the Lebesgue integral of X with respect to P. Build it from simple functions, prove monotone convergence, Fatou's lemma and dominated convergence, and use them to justify exchanges of limits, derivatives and expectations underlying ML gradient estimators. Study Jensen, Hölder, Cauchy–Schwarz and Minkowski inequalities and Lᵖ spaces.
- 06Measure theory II: densities, Radon-Nikodym and change of measureA density is a Radon–Nikodym derivative: probability mass measured relative to a reference measure. This unifies mass functions and densities, explains mixed distributions, change of measure and likelihood ratios, and clarifies why a distribution concentrated on a low-dimensional manifold has no density.
- 07Random vectors, product measures and independenceA random vector has a joint law on ℝⁿ whose marginals are pushforward measures under projections. Product measures and the Fubini–Tonelli theorems formalize independence as factorization of the joint law and allow integrals to be exchanged. Kolmogorov's extension theorem guarantees the existence of the iid sequences used throughout.
- 08Moments: variance, covariance and correlationA geometric review: covariance is an inner product in L² and correlation a cosine. Study covariance matrices and linear transformations, variance of sums with correlation and why averaging correlated data helps less than expected, and Markov and Chebyshev tail bounds. Implement numerically stable streaming moments.
- 09A catalogue of distributions and their generative storiesA dense review of distributions recurring throughout the map, organized by their generative stories: Bernoulli trials, rare-event counts, waiting times, proportions, sums and heavy tails. Study their relationships as limits, sums and ratios, which moments exist, and how to avoid scipy.stats parameterization errors.
- 10Transformations of random variables and change of variablesHow a density changes when its variable is transformed: the Jacobian as a volume-change factor, sums of log-determinants in transformation chains (the exact basis of normalizing flows), convolution for sums of independent variables, Box–Muller and order statistics.
- 11Conditional distributions, hierarchical models and copulasConditional densities, Bayes’ theorem for densities, and hierarchical models that first generate a latent variable and then data. Copulas separate marginals from dependence (Sklar’s theorem) and reveal why correlation does not fully describe joint risk in the tails.
- 12Conditional expectationConditional expectation given a σ-algebra is the best prediction with available information: it exists by Radon-Nikodym and is an orthogonal projection in L². It underlies RL value functions, optimal diffusion denoisers, derivative prices and martingales. Resolve the Borel-Kolmogorov paradox using regular conditional distributions.
- 13Generating functions, cumulants and the characteristic functionSums of independent variables are convolutions; transforms turn them into products. Study probability, moment and cumulant generating functions, including the convexity behind Chernoff bounds, and the characteristic function, which always exists, determines the law and proves the central limit theorem.
- 14The multivariate Gaussian I: definition, geometry and samplingThe multivariate Gaussian underlies Gaussian processes, the Kalman filter, VAEs, diffusion and the multivariate CLT. Define it through linear combinations; study its geometry, affine closure, and numerically stable sampling and evaluation with Cholesky.
- 15The multivariate Gaussian II: marginalization, conditioning and linear-Gaussian modelsThe two operations that make Gaussians tractable: marginalization by selecting a sub-block and conditioning via the Schur complement. Study information form, conditional independence in the precision matrix, the linear Gaussian model underlying Gaussian processes, Kalman filtering and diffusion, sensor fusion and Stein's lemma.
- 16Modes of convergence of random variablesConvergence has at least four meanings in probability: almost surely, in probability, in Lᵖ and in distribution. Study their relationships and counterexamples, the Borel–Cantelli lemmas, uniform integrability, Lévy's continuity theorem, Slutsky's lemma and continuous mapping: the language of limit theorems and convergence results for stochastic algorithms.
- 17Laws of large numbersWhy average loss on a test set estimates risk, and when it does not. Prove the weak and strong laws, study Kolmogorov’s 0-1 law and cases where the average fails to converge (Cauchy, St Petersburg), and extend the result to uniform convergence of the empirical distribution function using Glivenko–Cantelli and the DKW inequality.
- 18The central limit theorem and its limitsThe CLT explains the appearance of Gaussians in error bars, minibatch noise, wide-network preactivations and aggregated returns. Prove it with characteristic functions, generalize to non-identical summands (Lindeberg–Feller) and multiple dimensions (Cramér–Wold), quantify its rate (Berry–Esseen), derive the delta method and study failure under heavy tails and stable laws.
- 19The Chernoff method and large deviationsMarkov and Chebyshev give polynomial tails; applying Markov to e^(λX) and optimizing over λ yields exponential tails. This is Chernoff’s method, whose optimal form is the Legendre transform of the cumulant: Cramér’s exact large-deviation exponent. Complete the picture with multiplicative bounds and the second-moment method for lower bounds.
- 20Sub-Gaussian and sub-exponential variables: Hoeffding and BernsteinThe modern language of concentration: sub-Gaussian and sub-exponential variables, their Orlicz norms and equivalent characterizations. These yield Hoeffding (range), Bernstein (variance plus range) and the maximal √(2 log n) inequality, three major tools for sizing evaluations and proving generalization bounds.
- 21Concentration of functions of many variables: McDiarmid and Gaussian concentrationConcentration is not confined to sums: any function of many independent variables that does not depend too much on any one concentrates. Prove McDiarmid using the Doob martingale and Azuma–Hoeffding, bound variance using Efron–Stein and state dimension-independent Gaussian concentration of Lipschitz functions. These tools underpin Rademacher bounds and differential privacy.
- 22Concentration of measure in high dimensions and Johnson-LindenstraussHigh-dimensional random geometry concentrates: Gaussian mass lies in a thin shell, random directions are nearly orthogonal, and ε-nets and Johnson-Lindenstrauss yield useful guarantees.
- 23Distances between distributions and couplingsCompare distributions using total variation and Wasserstein distances, construct couplings, study Kantorovich–Rubinstein duality and Gaussian formulas, and understand high-dimensional sampling costs.
- 24Frontier: random matrices and matrix concentrationWhen dimension grows with the amount of data, scalar probability is insufficient: random-matrix spectra matter. Study matrix Bernstein and covariance estimation error, extreme singular values, the semicircle and Marchenko–Pastur laws, and the BBP transition in spiked models. These tools underpin current research on double descent, high-dimensional PCA and trained-network weight spectra.
Module capstone
probakit: your own probability library with verified guarantees
Build a NumPy library integrating the module: (1) distribution classes with sample, log_prob, cdf and icdf and an explicit reference measure, including mixed distributions; (2) composable transformations with Jacobian log-determinants; (3) a multivariate Gaussian with marginalization, conditioning and information form, stabilized with Cholesky; (4) concentration bounds (Hoeffding, empirical Bernstein, Chernoff-KL and DKW) returning non-asymptotic intervals; and (5) W₁, W₂ and TV distances. A test suite checks the law of large numbers, CLT and bound coverage by simulation, and validates the library against scipy.stats. The library is reused in m05, m14 and m19.
Check what you already know
- Calculate a posterior probability using Bayes' theorem when the base rate is low.
- Explain why not every subset of [0,1] is measurable and what the π-λ theorem is for.
- Sample from an arbitrary distribution using its generalized quantile function.
- Use dominated convergence to justify exchanging gradient and expectation.
- Express a density as a Radon-Nikodym derivative and apply a change of measure.
- Calculate the variance of a mean of correlated variables.
- Derive the density of a multivariate transformation using its Jacobian.
- Calculate 𝔼[Y | X] as an L² projection and apply the law of total variance.
- Condition a partitioned multivariate Gaussian using the Schur complement.
- Distinguish almost-sure convergence, convergence in probability and convergence in distribution using counterexamples.
- Prove the central limit theorem using characteristic functions.
- Size an evaluation set using Hoeffding and Bernstein inequalities.
- Prove the Johnson-Lindenstrauss lemma.
References
- Probability: Theory and Examples
- Probability and Measure
- Probability with Martingales
- A First Look at Rigorous Probability Theory
- High-Dimensional Probability: An Introduction with Applications in Data Science
- Concentration Inequalities: A Nonasymptotic Theory of Independence
- Pattern Recognition and Machine Learning
- Introduction to Probability
- Fundamentals of Probability (6.436J)