The interactive film is in the book's Companion

Play it, pause it, turn it and drag it with Mathematics for AI and Machine Learning.

Get the book

Monte Carlo: Averages That Close In Like a Funnel

Chapter 16 · Mathematics for AI and Machine Learning · Beginner · 1:27

An interactive live film: sixteen runs estimate E[z²] = 1 by running means; they scatter at first and close in like the funnel 1 ± σ/√S, so halving the error costs four times the samples. Roll the dice for fresh runs.

Narration

We want the average of z squared, where z is a standard Gaussian. The exact answer is one, the dark line along the back.

Monte Carlo replaces that average by an average over random samples. Draw z, square it, and keep a running mean. That is one path, and it moves from left to right as the number of samples grows.

The rest of the narration is in the book's Companion.

More from Chapter 16

Interactive1:46The Reparameterization Trick: Differentiable SamplingChapter 16Preview1:42Mean Field: Independent Factors for a Correlated PosteriorChapter 16Preview1:45Posterior Collapse: When Latents Vanish into the PriorChapter 16Preview1:36Expectation Maximization: Coordinate Ascent on the Lower BoundChapter 16Preview1:55Importance-Weighted BoundsChapter 16