A topic in the Open Knowledge Graph — a free, open map of 15,495 topics and the order to learn them in.

Expectation-Maximization Algorithm

Graduate Depth 108 in the knowledge graph ☐ I know this ☆ Set as goal
1topic build on this
703prerequisites beneath it
See this on the map →
Probabilistic Graphical ModelsConditional Expectation+7 more→→Mixture Models and Gaussian Mixture Models
em expectation-maximization latent

Core Idea

The EM algorithm iteratively estimates parameters of models with latent (unobserved) variables. The E-step computes expected latent values given current parameters; the M-step optimizes parameters given expected latents. EM guarantees monotonic likelihood improvement and is widely used for clustering, mixture models, and HMM training.

Explainer

Many probabilistic models contain variables that we cannot observe. In a Gaussian mixture model, each data point was generated by one of K Gaussian components — but we do not know which one. In a hidden Markov model, each observation comes from a hidden state — but we cannot see the states. These unobserved quantities are called latent variables. If we could observe the latent variables, parameter estimation would be straightforward: just compute the maximum likelihood estimates for each component separately. Without them, the likelihood function becomes a sum over all possible latent assignments, and this sum makes direct optimization intractable.

EM sidesteps this by alternating between two steps. The E-step (Expectation) asks: given my current best guess for the parameters, what is the most probable explanation for each data point in terms of the latent variables? For a Gaussian mixture, this means computing the posterior probability that each data point belongs to each component — a soft, probabilistic assignment called the "responsibility." For a hidden Markov model, it means computing the probability of being in each hidden state at each time step using the forward-backward algorithm. Crucially, these are not hard assignments; every data point is fractionally assigned to every component according to the posterior.

The M-step (Maximization) asks: given these soft assignments, what parameter values best explain the data? Because the latent variables are now treated as known (in expectation), this becomes a weighted maximum likelihood problem that often has a closed-form solution. For a Gaussian mixture, the new mean of component k is just the weighted average of all data points, where the weights are the responsibilities computed in the E-step. Then you go back to the E-step with the new parameters and repeat.

The reason this works — and converges — is grounded in the mathematics of Jensen's inequality. The E-step constructs a lower bound on the log-likelihood (called the ELBO, or Evidence Lower Bound) that is tight at the current parameters. The M-step maximizes this lower bound. Because the bound was tight before the M-step, the log-likelihood at the new parameters is at least as high as at the old parameters. This guarantees monotonic non-decrease of the log-likelihood at every iteration — EM never makes things worse. However, it only guarantees ascent to a local maximum, not the global one. EM is sensitive to initialization, and running the algorithm multiple times from different starting points is standard practice.

EM is widely used wherever latent variables arise naturally: training Gaussian mixture models (soft clustering), fitting hidden Markov models (speech recognition, sequence labeling), computing the parameters of factor analysis, and handling missing data in statistics. Its appeal is that each step has a clean probabilistic interpretation and the M-step is often analytically solvable, making implementation straightforward even when the E-step requires dynamic programming or other inference algorithms internally.

Practice Questions 3 questions

Prerequisite Chain

Understanding Zero → The Number Zero → Counting to Five → Counting to 10 → Counting to 20 → Counting a Set of Objects Up to 20 → Cardinality: The Last Number Counted → Matching Numerals to Quantities → Subitizing Small Quantities → Combining Small Groups Within 5 → Number Bonds Within 5 → Number Bonds to 10 → Tens and Ones Place Value → Reading and Writing Three-Digit Numbers → Comparing Three-Digit Numbers → Comparing and Ordering Three-Digit Quantities → Comparing and Ordering Whole Numbers → Comparing Numbers 1 to 20 → Ordering Numbers to 20 → Number Line 0 to 20 → Addition Within 20 → Doubles and Near Doubles → Doubles Facts Within 10 → Near Doubles Facts Within 20 → Mental Math Strategies for Addition → Mental Math: Adding and Subtracting Tens → Addition Within 100 → Repeated Addition as Multiplication → Multiplication as Equal Groups → Multiplication: Arrays → Basic Multiplication Facts (0s, 1s, 2s, 5s, 10s) → Multiplication Facts Within 100 → Division as Equal Sharing → Division as Grouping (Measurement Division) → Division: Grouping (Repeated Subtraction) Model → Division: Fair Sharing Model → Division as Equal Sharing → Division as Grouping → Basic Division Facts → Division Facts Within 100 → Multiplication and Division Fact Families → Relationship Between Multiplication and Division → Division Facts as Inverse of Multiplication → Remainders and Quotients in Division → Division Word Problems → Multi-Step Word Problems → Solving Multi-Step Word Problems → Multiplication Word Problems → Division Word Problems → Introduction to Long Division → Factors and Multiples → Prime and Composite Numbers → Equivalent Fractions → Relating Fractions and Decimals → Decimal Place Value → Integers and the Number Line → Opposites and Additive Inverses → Absolute Value → Adding Integers → Subtracting Integers → Multiplying Integers → Introduction to Exponents → Order of Operations → Integer Order of Operations → Variable Expressions → The Distributive Property → Variables and Expressions Review → Introduction to Polynomials → Adding and Subtracting Polynomials → Multiplying Polynomials → Factorial → Permutations → Combinations → Counting Principles: Addition and Multiplication Rules → Introduction to Graph Theory → Propositional Logic Foundations → Logical Equivalences → Boolean Algebra → Boolean Type and Truth Values → Comparison Operators and Boolean Tests → Logical Operators and Boolean Algebra → Boolean Algebra and Fundamental Laws → Logic Gates Fundamentals → Implementing Boolean Functions with Gates → Karnaugh Map Simplification → Combinational Circuit Design → Flip-Flops and Latches → Finite State Machines (FSMs) → Deterministic Finite Automata (DFA) → Nondeterministic Finite Automata (NFA) → Regular Language Recognition Algorithms → DFA Properties and Minimization Algorithms → Regular Languages: Definition and Characterization → Context-Free Grammars (CFGs) → Context-Free Grammar Properties and Ambiguity → Parse Trees, Derivations, and Ambiguity in CFGs → Context-Free Grammars in Compiler Design → Abstract Syntax Trees (ASTs) → Symbol Tables and Scope Resolution → Semantic Analysis Phase → Scope and Binding Resolution → Scope, Shadowing, and Variable Lifetime → Parameter Passing: Value vs. Reference → Two-Dimensional Arrays → Graph Representations: Adjacency List vs. Adjacency Matrix → Semantic Networks → Bayesian Networks and Inference → Probabilistic Graphical Models → Expectation-Maximization Algorithm

Longest path: 109 steps · 703 total prerequisite topics

Prerequisites (9)

Leads To (1)