Skip to content
StackDecode
AI & ML Atlas
Machine LearningalgorithmInteractive simulation

Expectation-Maximisation (EM)

Fits models with hidden variables by alternating guess and update steps.

The idea

When some variables are unobserved (such as which cluster a point came from), EM alternates: the E-step uses the current parameters to compute the expected values of the hidden variables, and the M-step finds the parameters that best explain the data given those expectations. Each round never lowers the likelihood.

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

  • cluster 1
  • cluster 2
  • cluster 3

Start with 3 broad bell curves (rings show two standard deviations).

1/29

Rings are the fitted Gaussians; point opacity shows membership confidence.

Step by step

  1. 1Start with initial parameters.
  2. 2E-step: compute the expected hidden values (responsibilities).
  3. 3M-step: maximise the likelihood using those expectations.
  4. 4Repeat until convergence.

Where it is used

Gaussian mixtures, hidden Markov models, missing-data problems.

Watch out for

Converges to a local optimum that depends on the starting point.

Related