The ML Series · Part 1

The Mathematical
Foundations of
Machine Learning

Before understanding any ML algorithm — from linear regression to large language models — you need to understand what ML is actually trying to compute. This guide builds that understanding from first principles.

6
Core Concepts
14
Visualisations
1
Coherent Story
Probability Theory Distribution Estimation Maximum Likelihood ~30 min read
The big picture

Six ideas, one destination

Every ML algorithm ultimately optimises one equation: θ* = argmax (1/N) Σᵢ log p_θ(xᵢ). The six ideas below are the steps needed to understand where it comes from and why it is correct.

The Problem
We want f: X→Y mapping X-rays to diagnoses, but physics cannot give us f. We collect data D and learn statistically. The function approximation problem becomes a distribution estimation problem.
Why ML Exists
Probability Theory
To handle uncertainty rigorously we build the triplet (Ω, F, P). Sample space, events, and a probability measure satisfying Kolmogorov's three axioms. The formal language of uncertainty.
The Language
Random Variables
Ω is abstract. The RV X: Ω → ℝᵈ bridges abstract to numeric via the push-forward, moving (Ω,F,P) to (ℝ,B,P_X) where ML lives.
The Bridge
Distributions
With X (image) and Y (label) on the same Ω, we study their joint P_{XY}, marginals, and conditional P_{Y|X}. The IID assumption and the density function both enter here.
The Structure
The ML Framework
P_x is unknown. We pick a parametric model p_θ and minimise a distance d(P_x, P_θ). This generates four fundamental questions every algorithm must answer.
The Framework
KL Divergence & MLE
KL divergence as d. The Weak Law of Large Numbers makes P_x disappear. The result: θ* = argmax (1/N) Σᵢ log p_θ(xᵢ) — Maximum Likelihood Estimation.
The Solution
🎯
Everything points here: θ* = argmaxθ (1/N) Σᵢ log p_θ(xᵢ). Every section derives and justifies one part of this formula.
The core problem

What machine learning is actually trying to compute

Every ML algorithm exists to answer one underlying question. Understanding it precisely is the prerequisite for everything that follows.

Consider diagnosing disease from a chest X-ray. A 1000×1000 pixel image is a vector of one million numbers — a single point in ℝ¹⁰⁰⁰⁰⁰⁰. The diagnosis is a label: 0 for diseased, 1 for benign. We want a function f mapping any pixel vector to the correct label. The trouble: f cannot be derived from first principles. Two radiologists examining the same X-ray sometimes disagree. A deterministic function is the wrong model — the right one is a probability distribution P(Y|X).

The Four Objects of Every Learning Problem
Domain, range, unknown function, and dataset
What We Have
  • X (domain) — all possible inputs. X-ray: X = ℝ¹⁰⁰⁰⁰⁰⁰ — every pixel flattened to a vector
  • Y (range) — all possible outputs. Diagnosis: Y = {0 diseased, 1 benign}
  • D = {(x₁,y₁),...,(xₙ,yₙ)} — N observed pairs. The only evidence about f we will ever have
The Shift
  • f: X → Y — the unknown true mapping. Exists in nature but not derivable from physics
  • Labels are ambiguous — replace deterministic f(x)=y with P(Y|X)
  • Function approximation becomes distribution estimation
The fundamental shift in thinking
DETERMINISTIC f(x) = y One fixed answer. Fails with uncertainty. shift to probabilistic PROBABILISTIC P(Y | X) Distribution over outputs. Captures uncertainty.
Finding a deterministic mapping becomes estimating a conditional distribution — the foundation of all probabilistic machine learning.
The Strategy: Start, Observe, Refine
1

Start with an initial guess

Choose a parametric form — a neural network with random weights, a linear model. This is your starting hypothesis, almost certainly wrong, but a point in parameter space that can be moved.

2

Refine using observed data D

Each pair (xᵢ, yᵢ) provides a constraint. Adjust model parameters so the distribution places high probability on correct outputs. Every gradient descent step is one refinement. This is training.

3

Deploy on new inputs

The model should generalise — give good predictions on inputs not seen during training. If it only memorised D, it will fail on new data. This is the generalisation problem that statistical learning theory studies.

Probability theory

The rigorous language of uncertainty

Every probability statement rests on a carefully constructed mathematical foundation. Before reasoning about uncertain functions, we need that foundation built from scratch — three objects and three axioms.

Object 1
Ω — Sample Space
The set of all possible outcomes. Crucially abstract — it need not be numeric. "All possible patients" is a valid sample space. You define what an outcome means for your experiment.
Object 2
F — σ-algebra
A collection of subsets of Ω called events. Must be closed under complements and countable unions — so "not A" and "A or B" are always valid events.
Object 3
P — Probability Measure
P: F → [0,1] assigns a number to each event representing its likelihood. Not any function qualifies — P must satisfy three specific axioms.
The Probability Triplet and Kolmogorov's Three Axioms
Ω Sample space All possible outcomes F σ-algebra (events) Measurable subsets of Ω P: F → [0,1] Probability measure Assigns likelihood to events Kolmogorov's Three Axioms — the complete foundation of probability theory AXIOM i · NON-NEGATIVITY P(A) ≥ 0 for all A ∈ F No negative probabilities AXIOM ii · NORMALIZATION P(Ω)=1 · P(∅)=0 Something must happen Total probability = 1 AXIOM iii · ADDITIVITY A∩B=∅ ⟹ P(A∪B)=P(A)+P(B) Disjoint events: probs add Basis of all calculation
These three axioms are all of probability theory. Every theorem — from Bayes' rule to the central limit theorem — is derived solely from them. (Ω, F, P) is the complete formal specification of any probabilistic setup.
💡
Probability is one particular kind of measure. A measure assigns non-negative numbers to subsets consistently. Length, area, volume, and counting are all measures. Probability is the special measure normalised to 1, representing likelihood. This is why probability can be studied with the same rigour as geometry.
(Ω, F, P) — the complete formal specification of any probabilistic setup. Every ML system, no matter how complex, rests on this triplet.
Random variables

From abstract outcomes to numbers

The sample space Ω might be "all possible patients." You cannot integrate over patients or compute derivatives with respect to weather states. To do mathematics, you need numbers — and the random variable provides them.

Despite its name, a Random Variable is neither random nor a variable. It is a completely deterministic function X: Ω → ℝ. X(Heads)=1, X(Tails)=0 — always, deterministically. The randomness comes from which ω ∈ Ω occurs in the experiment, not from X itself.

When X maps Ω → ℝ, it transports the entire probability triplet — this is the push-forward. Three things move simultaneously: Ω to ℝ, the σ-algebra F to the Borel σ-algebra B (generated by intervals like (−∞, x]), and the probability measure P to a new measure P_X on ℝ called the distribution of X.

The push-forward — (Ω, F, P) transported to (ℝ, B, P_X) via random variable X
Abstract World (Ω, F, P) Ω abstract outcomes F (σ-algebra) events / subsets of Ω P: F → [0,1] probability measure Ω → ℝ via X(ω) F → B (Borel sets) P → P_X (distribution) R.V. X Real World (ℝ, B, P_X) ← work here numeric values X(ω) B (Borel σ-algebra) intervals like (−∞, x] P_X: distribution P[X⁻¹(−∞, x]]
The RV X simultaneously carries Ω to ℝ, F to B, and P to P_X. All ML computation happens in (ℝ, B, P_X) — never in the abstract Ω.
🎯
The inverse image X⁻¹(S) decoded: It is not a function inverse — it is the set of all outcomes ω that X maps into S: X⁻¹(S) = {ω ∈ Ω: X(ω) ∈ S}. The CDF formula P_X(x) = P[X⁻¹(−∞, x]] pulls (−∞, x] back through X into Ω, then P measures that set. For a fair coin with X(H)=1, X(T)=0: P_X(0.5) = P({ω: X(ω) ≤ 0.5}) = P({T}) = 0.5 ✓
Inverse image: collecting all ω that X maps into target set S
Ω (sample space) ω₁ ω₂ ω₃ ω₄ ω₅ X(ω) → ℝ (real line) 00 11 22 33 S = [1, 2] X⁻¹(S) = {ω₂, ω₃, ω₅} — pulled back into Ω
X⁻¹(S) always exists, even when X has no inverse. It collects all outcomes mapping into S, then P measures that event in Ω.
Distributions

Joint, marginal, and conditional

In supervised learning, two random variables — X (input) and Y (label) — are defined on the same Ω. Every patient ω gives both an image X(ω) and a label Y(ω). The joint distribution P_{XY} captures their complete probabilistic relationship.

Joint distribution table — three distribution types visible at once
Y = 0 (Diseased)Y = 1 (Benign)P_X — marginal
X = Low brightness0.300.050.35 (sum row)
X = Med brightness0.100.200.30
X = High brightness0.050.300.35
P_Y — marginal0.45 (sum col)0.551.00
Reading it: P_{XY}(low,0)=0.30. P_X(low)=0.35. Conditional P(Y=0|X=low) = 0.30/0.35 = 0.86 — a dark X-ray is 86% likely to be disease. This conditional is exactly what a trained classifier outputs.
Marginalisation
P_X = ∫ P_{XY} dY
Integrate out Y. What does a typical input look like, ignoring labels? Used for: anomaly detection (flag low P_X inputs), image generation (Diffusion, VAE, GAN), compression.
Conditional
P_{Y|X}(y|x) = P_{XY}/P_X
Given input x, what is the distribution over labels? This is what supervised learning approximates. The softmax output of a neural network is literally this quantity.
The chain rule connects all three: P_{XY} = P_{Y|X} · P_X = P_{X|Y} · P_Y. This identity is always exact — no assumptions required. It is the foundation of Bayes' theorem.
Two essential ideas

The IID assumption and the density function

Two ideas are so central to statistical learning they deserve focused treatment. The IID assumption is what makes learning from data mathematically valid. The density function is the tool for evaluating how well a model fits data.

The IID Assumption — In Full Detail

A dataset D = {x₁,...,xₙ} ~ i.i.d. P_x. These four letters pack in two separate and equally important assumptions.

Independent and Identically Distributed
Two distinct conditions — each doing a different and essential job
i.d. — Identically Distributed
  • Every data point xᵢ is drawn from the same distribution P_x
  • Patient 1 and Patient 1000 come from the same population — same disease prevalence, same imaging equipment
  • This is why training on past data generalises to future data: they come from the same P_x
  • When this breaks: distribution shift. Training on hospital A, deploying at hospital B with different equipment. The i.d. assumption fails and performance degrades
i. — Independent
  • Knowing xᵢ tells you absolutely nothing about xⱼ for j ≠ i
  • Formally: P(x₁,...,xₙ) = P(x₁) · P(x₂) · ··· · P(xₙ)
  • This factorisation means log-likelihood is a sum: log ∏ p(xᵢ) = Σ log p(xᵢ)
  • Without independence, P(x₁,...,xₙ) is one intractable joint object. Independence decomposes it into individually manageable terms — this is what makes MLE tractable
⚠ Critical: IID applies across datapoints, not across dimensions within one datapoint Patient 3's X-ray is independent of Patient 7's X-ray — this is the IID assumption. But Pixel (100,100) and Pixel (101,100) of the same X-ray are deeply correlated — nearby pixels have similar intensities, edges create coherent spatial patterns. The IID assumption says nothing about this within-image structure. That structure is captured by P_x itself, and it is precisely what convolutional networks learn to exploit.
When IID fails — time series. Sequential data violates independence: xₜ depends on xₜ₋₁. The replacements are stationarity (distribution doesn't drift over time — replacing "identically distributed"), Markov property P(xₜ|past) = P(xₜ|last k steps) (replacing independence with bounded dependence), and the Ergodic theorem — the time-series analogue of the WLLN. Models: RNNs, LSTMs, Transformers.
The Distribution Function vs The Density Function

There are two ways to describe the distribution of a continuous random variable. They carry the same information — one determines the other — but represent fundamentally different things. This distinction matters for everything that follows.

CDF vs PDF — two different mathematical objects describing the same distribution
CDF — Distribution Function F_X(x) F_X(x) = P(X ≤ x) · always in [0,1] · all RVs 1 0 x IS a probability. Always between 0 and 1. PDF — Density Function p_x(x) p_x(x) = dF_X/dx · can exceed 1 · continuous RVs only a b ∫ₐᵇ p dx NOT a probability at a point. Integrate for probability. d/dx ⇄ ∫dx
The shaded area ∫ₐᵇ p_x(t) dt = P(a ≤ X ≤ b) is the probability — integrating the density over an interval gives a probability. The density itself at a point is not.

The critical point: for a continuous random variable, the probability of any single exact value is zero. P(X = x) = 0 for any specific x. This is a mathematical consequence of having an uncountable range. Probability only makes sense for intervals in the continuous case.

What the Density Function Actually Means
Four precise ways to understand p_x(x)
  • Infinitesimal probability: P(x ≤ X ≤ x+ε) ≈ p_x(x) · ε for small ε. The density times a tiny interval width gives a tiny probability. Shrink the interval to zero and you shrink the probability to zero — never a positive probability at a single point.
  • Integration gives probability: P(a ≤ X ≤ b) = ∫ₐᵇ p_x(t) dt. The only valid way to extract a probability from a density is to integrate over an interval. The total area under the entire density curve always equals exactly 1.
  • Can exceed 1: A distribution concentrated tightly in [0, 0.1] can have density p_x(x) = 10 within that interval (since 0.1 × 10 = 1, the total area is still 1). There is no contradiction — density is probability per unit length, not probability itself.
  • Likelihood: Evaluating p_θ(xᵢ) for an observed data point xᵢ gives the likelihood of xᵢ under model p_θ. A higher value means the model places more probability mass near xᵢ — the observation is more consistent with the model. Even though this number can exceed 1, it is meaningful for comparing models and forms the basis of MLE.
Why ML works with densities, not CDFs. The MLE objective is Σᵢ log p_θ(xᵢ) — we evaluate the density at each observed data point. KL divergence is ∫ p(x) log[p(x)/q(x)] dx — written entirely in densities. The CDF F_X(x) is the theoretical object giving probabilities of half-lines. The density p_x(x) is the computational tool we actually differentiate and optimise over.
When to Estimate Which Distribution
Which distribution should I model?
P_{Y|X} — Supervised learning (most common). Labels available. Classification (Y discrete) or regression (Y continuous). Neural classifiers, logistic regression.
P_X — Unsupervised / generative. Anomaly detection (flag low P_X inputs), image generation (Diffusion, VAE, GAN), density estimation.
P_Y — Class prior. Imbalanced dataset detection, Bayesian inference P_{Y|X} ∝ P_{X|Y}·P_Y, cost-sensitive learning.
P_{XY} — Full joint. Missing data imputation, causal inference, multi-modal generation (image+text).
Functions of P_X — When full density is intractable. Mean E[X], variance, covariance (PCA), log-likelihood E[log p_θ(x)] — the MLE objective.
The learning framework

Four questions every algorithm must answer

With the mathematical tools in place, we can state the core problem precisely: given dataset D sampled i.i.d. from unknown P_x, estimate P_x. The word "unknown" is where everything gets hard — and the three-step framework below is how it is resolved.

The central challenge: P_x is completely unknown. You cannot compute any expectation involving P_x directly. Yet you need parameters θ* such that p_θ* ≈ P_x. The framework below makes this possible.
i

Model Choice — Assume a parametric family {p_θ : θ ∈ Θ}

P_x is an infinite-dimensional object. Restrict to a parametric family indexed by a finite vector θ. Each choice of θ gives one specific distribution.

  • Gaussian: p_θ(x) = N(x;μ,Σ), θ={μ,Σ} — tractable, unimodal only
  • GMM: Σₖ πₖ N(x;μₖ,Σₖ) — universal approximator for smooth densities
  • Neural net: learned function — most expressive, can represent virtually any P_x
ii

Distance Metric — Define d(P_x, P_θ) : P_x × P_θ → ℝ⁺

Measure how far p_θ is from the true P_x. Must satisfy d ≥ 0 and d=0 iff P_θ=P_x. The choice of d determines what the model learns and which algorithm results.

  • KL divergence → Maximum Likelihood Estimation
  • Jensen-Shannon divergence → GAN training
  • Wasserstein distance → WGAN

Problem: d requires computing something involving P_x — which is unknown. The WLLN resolves this in the next section.

iii

Optimisation — Find θ* = argmin_θ d(P_x, P_θ)

After making d computable, minimise it over θ. For neural networks with millions of parameters: gradient descent, iteratively updating θ in the direction that reduces d. This process is model training.

The four fundamental questions — every ML algorithm answers all four simultaneously
QUESTION A · STATISTICAL How to compute d(P_x, P_θ) without knowing P_x? P_x unknown → WLLN replaces expectations KL → MLE · JS → GAN · Wasserstein → WGAN Different d → different algorithm QUESTION B · OPTIMISATION How to solve the optimisation problem? θ ∈ ℝᴹ for millions of parameters SGD · Adam · RMSProp Every training step = one gradient update QUESTION C · MODEL SELECTION What parametric family to use for P_θ? Gaussian · GMM · Normalizing Flows VAE · GAN · Diffusion Models Expressiveness vs tractability tradeoff QUESTION D · GENERATION How to sample from P_θ*? MCMC · Ancestral sampling GAN: z~N(0,I) → G_θ(z) → x Diffusion: iterative denoising GANs sample without computing density
MLE = {any p_θ} + {KL divergence} + {gradient descent}. GAN = {implicit neural net} + {JS divergence} + {alternating gradient descent}. Every ML algorithm is a consistent set of answers to all four.
KL divergence and maximum likelihood

From information theory to the master equation

We start with a question from information theory — how much information does an event carry? — and six connected steps later, we arrive at the training objective used by virtually every ML algorithm ever built.

Step 1 — Information Content

Define I(A) = −log P(A). This formula is uniquely determined by three requirements: certain events carry zero information; rarer events carry more; information from two independent events adds. The negative log is the only function satisfying all three.

Three requirements uniquely determining I(A) = −log P(A)
P(A) = 1 → I = 0 "Sun rose today" Certain → zero information ✓ P(A) → 0 → I → ∞ "Earthquake today" Rare → high information ✓ I(A∩B) = I(A)+I(B) Independent events Information is additive ✓ I(A) = −log P(A) The negative log is the only function satisfying all three — a theorem, not a convention
Steps 2–4 — Entropy, Cross-Entropy, KL Divergence

Entropy H(P_x) = E_{P_x}[−log P(x)] = Σᵢ P(xᵢ)·(−log P(xᵢ)) is the average information content — the average surprise when drawing from P_x. A flat distribution has maximum entropy (all outcomes equally surprising). A peaked one has minimum entropy (one outcome dominates).

Entropy — average surprise. Low means predictable. High means uncertain.
Low Entropy — Peaked One outcome dominates — low uncertainty H is small — high confidence High Entropy — Flat All outcomes roughly equal — maximum uncertainty H is large — maximum uncertainty

Cross-entropy H(P, Q) = E_P[−log Q(x)] measures average information when data comes from P but surprise is measured using a different model Q. It always satisfies H(P,Q) ≥ H(P), with equality only when Q = P. Using the wrong model always increases average surprise.

KL divergence is the difference: D_KL(P ‖ Q) = H(P,Q) − H(P) = E_P[log P/Q] = ∫ P(x) log[P(x)/Q(x)] dx. It measures the excess surprise from using model Q when the truth is P. Three key properties: D_KL ≥ 0; D_KL = 0 iff P = Q; and D_KL(P‖Q) ≠ D_KL(Q‖P) — it is asymmetric, not a true metric distance.

Step 5 — The Weak Law of Large Numbers

We want to minimise D_KL(P_x ‖ P_θ) over θ. Expanding the KL gives D_KL = −H(P_x) − E_{P_x}[log p_θ(x)]. The first term is constant in θ and drops out. What remains is −E_{P_x}[log p_θ(x)] — an expectation under the unknown P_x. We cannot compute this integral directly.

The Weak Law of Large Numbers (WLLN) resolves this. Its role is precise: it does not solve the integral — it provides a substitution that makes the intractable tractable. If x₁,...,xₙ are drawn i.i.d. from P_x, then for any measurable function g with finite expectation:

WLLN: replacing an intractable expectation with a computable sample average
Intractable (P_x unknown) E_{P_x}[ g(x) ] = ∫ g(x) P_x(x) dx Requires knowing P_x — impossible One integral over an unknown distribution WLLN, N→∞ Computable (data only) (1/N) Σᵢ g(xᵢ) xᵢ ~ i.i.d. P_x, N large Requires only samples — the dataset D N simple additions — completely tractable
WLLN: (1/N) Σᵢ g(xᵢ) →ᵖ E_{P_x}[g(x)] as N→∞, when xᵢ ~ i.i.d. P_x. The IID assumption is exactly what makes this valid — it is the prerequisite, not a side condition.

Notice the essential role of IID: the WLLN requires samples drawn independently and identically from P_x. If samples are not independent, the average does not converge reliably. If not identically distributed, it converges to the wrong target. IID is not a convenience assumption — it is the prerequisite that enables this substitution.

Step 6 — The Derivation: From KL to MLE
The complete chain: KL divergence minimisation → Maximum Likelihood Estimation
STEP 1 · EXPAND KL DIVERGENCE D_KL(P_x ‖ P_θ) = ∫P_x log P_x dv − ∫P_x log P_θ dv −H(P_x) constant in θ −H(P_x, P_θ) depends on θ STEP 2 · DROP CONSTANT (−H(P_x) has no θ) θ* = argmin_θ −E_{Px}[log p_θ(x)] ↑ still contains P_x — unknown! STEP 3 · APPLY WEAK LAW OF LARGE NUMBERS WLLN: (1/N) Σᵢ g(xᵢ) → E_{Px}[g(x)] as N→∞, xᵢ ~ i.i.d. P_x E_{Px}[log p_θ(x)] ≈ (1/N) Σᵢ log p_θ(xᵢ) ↑ P_x gone — only data D and model remain RESULT · MAXIMUM LIKELIHOOD ESTIMATION θ* = argmax_θ (1/N) Σᵢ log p_θ(xᵢ) MLE is not an arbitrary heuristic — it IS minimising KL divergence, made tractable by WLLN
Joint Likelihood — Why IID Makes It a Sum
joint_likelihood_to_mle.math
// IID → independence → joint probability factorises into a product ℓ_θ(D) = P_θ(x₁, x₂, ..., xₙ) = P_θ(x₁) · P_θ(x₂) · ... · P_θ(xₙ) // because i.i.d. = ∏ᵢ₌₁ᴺ p_θ(xᵢ) // Problem: product of N numbers each < 1 causes numerical underflow // 0.9^1000 ≈ 10⁻⁴⁶ — computers round this to zero // Solution: take the log. Log is monotone → same argmax. Product → sum. l̃_θ(D) = Σᵢ₌₁ᴺ log p_θ(xᵢ) // log-likelihood — numerically stable θ* = argmax_θ (1/N) l̃_θ(D) // (1/N) makes scale dataset-size-independent = argmax_θ (1/N) Σᵢ log p_θ(xᵢ) ← THE MASTER EQUATION // ── Coin example: 7 heads, 3 tails, model: p_θ(heads) = θ ──────────── ℓ_θ(D) = θ⁷ · (1−θ)³ // joint likelihood (product) l̃_θ(D) = 7·log(θ) + 3·log(1−θ) // log-likelihood (sum) dl̃/dθ = 7/θ − 3/(1−θ) = 0 → θ* = 7/10 = 0.7 // fraction of heads ✓
The Complete Picture — Every Concept Connected
From abstract sample space to the master equation — every concept in one chain
Sample Space Ω RV X Real line ℝ, B, P_X sample Dataset D i.i.d. P_x KL+WLLN MLE Objective Σ log p_θ(xᵢ) argmax θ* — Trained p_θ* ≈ P_x Prob. triplet (Ω, F, P) IID assumption Entropy H(P_x) Cross-Entropy H(P_x, P_θ) KL Divergence H(P,Q)−H(P) WLLN — makes P_x disappear
Every concept connects into one chain ending at the MLE objective. The Probability Triplet, IID, information theory, and WLLN each contribute one essential piece.
"MLE is not an arbitrary recipe. It is what you get when you choose KL divergence as your distance metric and apply the Weak Law of Large Numbers to replace the intractable expectation with a sample average over your data."
Quick reference

All formulas in one place

ml_foundations_reference.math
// ── PROBABILITY TRIPLET ────────────────────────────────────────────── (Ω, F, P) P: F → [0,1] Axiom i: P(A) ≥ 0 for all A ∈ F Axiom ii: P(Ω) = 1 · P(∅) = 0 Axiom iii: A∩B=∅ → P(A∪B) = P(A) + P(B) // ── RANDOM VARIABLE ───────────────────────────────────────────────── X: Ω → ℝ (scalar) X: Ω → ℝᵈ (vector, X-ray: d=1,000,000) P_X(x) ≜ P[ X⁻¹(−∞, x] ] ← CDF via inverse image (Ω, F, P) →[RV X]→ (ℝ, B, P_X) ← work here in ML // ── DISTRIBUTIONS ─────────────────────────────────────────────────── Joint: P_{XY}(x,y) Marginals: P_X = ∫ P_{XY} dY · P_Y = ∫ P_{XY} dX Conditional: P_{Y|X}(y|x) = P_{XY}(x,y) / P_X(x) Chain rule: P_{XY} = P_{Y|X}·P_X = P_{X|Y}·P_Y (always exact) // ── CDF vs PDF ────────────────────────────────────────────────────── CDF: F_X(x) = P(X ≤ x) ∈ [0,1] IS a probability PDF: p_x(x) = dF_X/dx ≥ 0 NOT a probability at a point P(a ≤ X ≤ b) = ∫ₐᵇ p_x(t) dt integrate to get probability P(X = exact point) = 0 (continuous RV) Likelihood = p_θ(x) evaluated at observed x (can exceed 1) // ── INFORMATION THEORY ────────────────────────────────────────────── Information: I(x) = −log P(x) Entropy: H(P) = E_P[−log P(x)] = Σ P(xᵢ)·(−log P(xᵢ)) Cross-entropy: H(P,Q) = E_P[−log Q(x)] ≥ H(P) always KL divergence: D_KL(P‖Q) = H(P,Q) − H(P) = ∫ P(x) log[P(x)/Q(x)] dx D_KL ≥ 0 · D_KL = 0 iff P=Q · D_KL(P‖Q) ≠ D_KL(Q‖P) // ── WEAK LAW OF LARGE NUMBERS ──────────────────────────────────────── If x₁,...,xₙ ~ i.i.d. P_x: (1/N) Σᵢ g(xᵢ) →ᵖ E_{P_x}[g(x)] as N→∞ Replaces intractable E_{P_x}[·] with computable sample average over D // ── KL → MLE DERIVATION ───────────────────────────────────────────── D_KL(P_x ‖ P_θ) = −H(P_x) [constant in θ] − E_{Px}[log p_θ(x)] → argmin_θ −E_{Px}[log p_θ(x)] (drop constant) → argmin_θ −(1/N) Σᵢ log p_θ(xᵢ) (WLLN applied) → argmax_θ (1/N) Σᵢ log p_θ(xᵢ) ← MLE THE MASTER EQUATION // ── JOINT LIKELIHOOD (IID) ─────────────────────────────────────────── ℓ_θ(D) = ∏ᵢ p_θ(xᵢ) ← IID → independence → joint = product l̃_θ(D) = Σᵢ log p_θ(xᵢ) ← log-likelihood (numerically stable sum) θ* = argmax_θ (1/N) l̃_θ(D)