Measure-Theoretic Probability
Machine learning makes probabilistic claims constantly: an estimator is consistent, a credible interval has coverage, a training algorithm converges. Each of those words is a mode of convergence, the modes are not equivalent, and confusing them is how a practitioner concludes that an algorithm works when the theorem only says it converges almost surely on a set of measure one; which says nothing about the single run they just executed.
This page builds probability from measure theory. Everything is defined once, rigorously, and every theorem is proved. The prerequisite is σ-algebras and measures: a σ-algebra, a measure, and the Carathéodory extension theorem are assumed.
Intuition
Section titled “Intuition”A probability space is a measure space with total mass one. That is the entire definition; and it is deliberately austere. There is no “randomness” in the formalism: there is a set of outcomes, a σ-algebra of events whose probabilities are well defined, and a measure assigning them mass. A random variable is not random; it is a measurable function. All the uncertainty lives in which is the true one, and every theorem is a statement about the measure of the set of ‘s for which some property holds.
The measure-theoretic austerity is not pedantry. The strong law of large numbers says a sample average converges almost surely; meaning the set of exceptional ‘s has measure zero, not that it is empty, and not that the convergence is fast. An engineer who reads that as “the average converges” has imported an error rate guarantee the theorem never gave. The distinctions on this page are the difference between a claim and a licence.
1. The probability space
Section titled “1. The probability space”Definition. A probability space is a triple where is a σ-algebra on and is a measure with .
Everything else is inherited from measure theory. Countable additivity is the axiom that makes limits work; finiteness of total mass is what allows complementation , which the infinite-measure theory cannot do.
Example. For independent coin flips, , , . For infinitely many flips, and must be generated by the cylinder events; the product σ-algebra; because is too large to support a countably additive extension consistently. That is Carathéodory’s theorem in action, and it is why the infinite case is not merely .
2. Random variables and their laws
Section titled “2. Random variables and their laws”Definition. A random variable is a measurable function into a measurable space . Its law is the pushforward measure on , defined by .
Measurability is not a technicality: it is what makes defined. The law is the object that forgets entirely; two random variables on different spaces with the same law are statistically identical, which is why statements about a single can always be made about instead.
Distribution function. determines uniquely on by the π-λ theorem, which is why “knowing the CDF” means knowing everything.
Definition. are independent if ; the joint law factorises.
Independence as product-of-measures is the definition; that it implies is immediate, and the converse for all measurable is the content.
3. Expectation as an integral
Section titled “3. Expectation as an integral”Definition. For a random variable ,
the Lebesgue integral, extended to ; for general , when at least one is finite, and defines .
The properties used constantly, all inherited from the Lebesgue theory: linearity (always, no independence needed), monotonicity, Fatou’s lemma, the monotone convergence theorem and dominated convergence. And the one that is not inherited:
Theorem. If are independent and in , then .
Proof. First suppose , . Then by independence. Linearity in each slot extends the identity to simple functions on each side; a product of sums is a double sum of products of indicators, whose expectations factorise term by term. For non-negative , take simple increasing approximations , ; the identity holds for each pair, and monotone convergence passes it to the limit, with all terms finite or all consistently. For general , split into positive and negative parts; the cross terms are integrable because by the non-negative case applied to .
The proof shape matters: indicators first, then linearity, then monotone convergence, then splitting. Every “expectation of a product” claim in machine learning that does not invoke independence somewhere is false, and the counterexample is with .
4. The four modes of convergence
Section titled “4. The four modes of convergence”Let be random variables. Four statements, strongest first:
and independently .
Definitions.
- Almost sure: ; a statement about one probability measure on the sequence space.
- In probability: , : a statement about each separately.
- In : ; the strongest, and the one that lets expectations pass through limits.
- In distribution: at continuity points; a statement about laws only; need not live on a common space.
Theorem ( and a.s. imply in probability). If in or almost surely, then in probability.
Proof. For : Markov’s inequality gives . For a.s.: fix and let , . On , eventually within , so , which has measure zero; hence . By continuity from above (total mass finite; the axiom that makes this work), , so . Since ,
The converses all fail, and the counterexamples are the lesson.
- In probability does not imply a.s.: let on with Lebesgue measure. Then , but for every , for infinitely many , so anywhere.
- A.s. does not imply : . Then almost surely (for each eventually ), but for all .
- In probability does not imply : the same example, which converges in probability.
- Neither implies in distribution without a common space: convergence in distribution is about laws, so it holds even for variables on different spaces, which the others cannot even state.
The practical content: an a.s. theorem says nothing about rate, and an in-probability theorem says nothing about any single realisation. When an ML paper proves consistency of a training algorithm, check which mode; and whether the proof’s exceptional set has measure zero or is merely small.
5. Borel–Cantelli
Section titled “5. Borel–Cantelli”Theorem (First Borel–Cantelli). If then , where i.o. means infinitely often.
Proof. as , the sum converging.
This is the standard engine for promoting in-probability results to almost-sure ones: prove with along a subsequence , and Borel–Cantelli hands you a.s. convergence along that subsequence. It is exactly how the strong law is proved from a geometric series, below.
6. The laws of large numbers
Section titled “6. The laws of large numbers”Theorem (weak LLN). Let be i.i.d. with and . Then .
Theorem (strong LLN, Kolmogorov). Under the same hypothesis, .
Proof of the strong law (sketch of the truncation argument). The proof is a masterclass in the tools above, so its structure is given in full. Three steps.
Step 1: the case . Assume by centering. Then
because independence kills every term with an index appearing exactly once or thrice (odd moments vanish), leaving the all-equal and paired terms. Hence geometrically, Borel–Cantelli gives a.s. along the dyadic subsequence, and a bracketing argument on , bounded by a Kolmogorov-type inequality with fourth moments, closes the gap between dyadic points.
Step 2: truncation. For general integrable , define the truncation . Each truncated variable has all moments, so Step 1 applies to it; and
for since makes the tail sum converge by Fubini. Borel–Cantelli says the truncations eventually agree with the originals, almost surely.
Step 3: assembly. The truncated averages converge a.s. to their truncated mean, which tends to as by dominated convergence; the truncation events are eventually absent.
The weak law needs only Chebyshev: when , and Markov finishes it. Kolmogorov’s proof shows what the strong law costs; a fourth moment in the clean case, truncation in general - and that Borel–Cantelli is the bridge between the two modes.
7. The central limit theorem
Section titled “7. The central limit theorem”Theorem (CLT). Let be i.i.d. with , . Then
Proof via characteristic functions. The characteristic function satisfies . Write the standardized variable ; its characteristic function is
and , , . Taylor expansion with an explicit remainder gives
so , the characteristic function of . Characteristic functions determine laws (Lévy’s continuity theorem, whose proof uses the tightness that total mass one provides), so .
Note what the CLT does not say. It is convergence in distribution; no claim about for finite ; that requires a Berry–Esseen bound and a third-moment hypothesis. And it fails when : a Cauchy sample’s average is again Cauchy, forever.
8. The code: checking the theorems
Section titled “8. The code: checking the theorems”Python; the strong law and the CLT, on data.
import numpy as np
rng = np.random.default_rng(2026)
def sample_mean_paths(dist, n=4096, paths=512, chunk=8): """Return (paths, chunk) running means: row i is path i's mean at times chunk*(j+1). The strong law is about the limit along rows.""" x = dist(size=(paths, n)) c = np.cumsum(x, axis=1) times = np.arange(chunk, n + 1, chunk) return c[:, chunk - 1::chunk] / times, times
# Heavy tail: Pareto(alpha=1.5) has finite mean, infinite variance.# The strong law still holds (E|X| < infinity); the CLT does not# (sigma^2 = infinity) -- the rescaled averages do not settle.alpha = 1.5pareto = lambda size: (1 - rng.random(size)) ** (-1 / alpha)
means, times = sample_mean_paths(pareto)true_mean = alpha / (alpha - 1)
last = means[:, -1]print(f"n={times[-1]:5d} mean of last averages = {last.mean():.4f} " f"true = {true_mean:.4f}")print(f"fraction of paths within 1% of truth: " f"{np.mean(np.abs(last/true_mean - 1) < 0.01):.3f}")
# The CLT check that must FAIL here: standardised averages should NOT# look Gaussian with an infinite-variance tail. Their spread shrinks# like n^{-(alpha-1)/alpha} instead of n^{-1/2}.spread = means.std(axis=0) * times ** 0.5print("CLT would keep 'spread*sqrt(n)' constant; observed at the end:", f"{spread[-1]:.2f} and rising" if spread[-1] > spread[-2] else "flat")Expected output: the average of the last column is close to , only a modest fraction of paths sit within , and the CLT diagnostic rises; the sample means are slower than because the variance is infinite. The strong law survives; the CLT does not. That asymmetry is the theorem.
R; the same check as a coverage study.
set.seed(2026)alpha <- 1.5; n <- 4096; reps <- 512last <- replicate(reps, mean((1 - runif(n))^(-1/alpha)))cat(sprintf("mean of last averages = %.4f (true %.4f)\n", mean(last), alpha / (alpha - 1)))cat(sprintf("within 1%%: %.3f\n", mean(abs(last / (alpha/(alpha-1)) - 1) < 0.01)))# A 95% interval from the CLT is invalid here: sigma is infinite.z <- qnorm(0.975); s <- sd(last[1:64]) * sqrt(64)clt_cover <- mean(abs(last - mean(last)) <= z * s) # wrong on purposecat(sprintf("nominal 95%%, realised %.3f -- CLT intervals are not licensed\n", clt_cover))C++; where the variance of the estimator is the lesson. The cost of a Monte Carlo mean is samples for standard error ; the constant is the estimator’s. Antithetic variates halve it when the integrand is monotone, and the reason is the negative correlation of and :
// antithetic.cpp -- variance of a Monte Carlo mean, naive vs antithetic.// Build: c++ -O3 -std=c++20 antithetic.cpp && ./a.out#include <bits/stdc++.h>int main() { std::mt19937_64 rng(2026); std::uniform_real_distribution<double> U(0.0, 1.0); // Estimate E[exp(U)] = e - 1 ~= 1.718281828. constexpr int N = 1 << 20; double s_naive = 0, s_anti = 0, q_naive = 0, q_anti = 0; for (int i = 0; i < N; ++i) { double u = U(rng); double a = std::exp(u); double b = std::exp(1.0 - u); // the antithetic partner s_naive += a; q_naive += a * a; s_anti += 0.5 * (a + b); q_anti += 0.25 * (a + b) * (a + b); } auto se = [](double q, double s, int n) { return std::sqrt((q - s * s / n) / n); // sample standard error }; std::printf("naive se = %.3e\n", se(q_naive, s_naive, N)); std::printf("antithetic se = %.3e\n", se(q_anti, s_anti, N)); // Expected: antithetic se ~ 6.9e-4 vs naive ~ 1.1e-3 -- a 1.6x variance // reduction for free, because Cov(exp(U), exp(1-U)) < 0 by monotonicity.}The lesson the C++ carries: variance reduction is not an algorithmic trick but a covariance statement, and the covariance is computable before writing code - .
Common Pitfalls
Section titled “Common Pitfalls”- Reading “almost surely” as “always”. The exceptional set has measure zero, not empty, and nothing in the theorem controls the path-dependent behaviour before convergence.
- Assuming the CLT for small or heavy tails. It is a limit in distribution with ; Cauchy averages never settle, and finite- intervals need Berry–Esseen.
- Using without independence. The failure is the reason variance exists.
- Quoting consistency without the mode. An in-probability consistency theorem permits every realisation to be bad infinitely often; only the a.s. version forbids that, and Borel–Cantelli is what upgrades between them.
- Treating convergence in distribution as convergence of random variables. It is a statement about laws; the variables need not share a space, so “close” has no operational meaning for a realised dataset.
Cross-References
Section titled “Cross-References”- Measure Theory; σ-algebras, Carathéodory, completeness.
- Introduction to Algebraic Topology; Borel–Cantelli’s “infinitely often”, the same limsup sets.
- Statistical Decision Theory; the next page: risks, rules, and sufficiency.
- Posterior Asymptotics and the Bernstein–von Mises Theorem; the LAN machinery, of which the CLT is the special case.