← ~/visualizations

law-of-large-numbers

Streams iid samples X_i from a fixed distribution (a fair die), computes the running sample mean X̄_n, and shows how X̄_n stabilizes near the expected value E[X] as n grows. A shrinking green band around E[X] visually suggests convergence in probability.

canvasclick to interact
t=0s

practical uses

  • 01.Estimating an unknown mean from repeated measurements (A/B tests, surveys)
  • 02.Monte Carlo estimation (approximating expectations with simulated samples)
  • 03.Quality control and process monitoring (averages stabilize with more observations)

technical notes

Uses a closure to maintain state (n, sum, recent samples, mean history). Sampling rate ramps within a ~4.2s cycle to emphasize behavior as n increases; state softly resets after large n. Rendering is grid-snapped for a blocky aesthetic; expectation line and a ~1/√n band illustrate tightening concentration around E[X].