PhysSandbox
Classical MechanicsWaves & SoundElectricity & MagnetismOptics & LightGravity & OrbitsLabsLessons
🌙Astronomy & The Sky🌡️Thermodynamics🌍Biophysics, Fluids & Geoscience📐Math Visualization🔧Engineering🧪Chemistry📊Statistics & Probability
ENRUESPTFRDE

Related simulators

Continue with similar topics in this category — or all 10 in Statistics & Probability.

View category →
NewKids

Binomial Distribution

Launch Simulator

P(K = k) bars for n trials with success p; mean np, variance np(1−p); coin and rare-event presets; normal overlay at large n.

NewFeaturedKids

Central Limit Theorem

Launch Simulator

Pick a parent (uniform, exponential, binomial, die), draw samples of size n = 1, 5, 30; the histogram of means turns normal and its spread shrinks as σ/√n.

NewFeaturedKids

Galton Board (Bean Machine)

Launch Simulator

Balls bounce left/right through rows of pegs; the bins fill a binomial that turns into a bell curve. Few rows vs many rows.

NewKids

Normal Distribution & z-Scores

Launch Simulator

Bell curve with μ and σ; shaded tails, the 68–95–99.7 rule, and a built-in z-score converter x → z = (x − μ)/σ.

NewSchool

Confidence Interval Simulator

Launch Simulator

Draw a sample, build a 90/95/99 % interval for μ; repeat 100 times and count how many intervals catch the true mean.

NewSchool

p-Value Explained

Launch Simulator

Test statistic on the null density; shaded one- or two-sided tail is the p-value. Why it is not the probability that H₀ is true.

PhysSandbox

Interactive physics, chemistry, and engineering simulators for students, teachers, and curious minds.

Physics

  • Classical Mechanics
  • Waves & Sound
  • Electricity & Magnetism

Science

  • Optics & Light
  • Gravity & Orbits
  • Astronomy & The Sky

More

  • Thermodynamics
  • Biophysics, Fluids & Geoscience
  • Math Visualization
  • Engineering
  • Chemistry
  • Statistics & Probability

© 2026 PhysSandbox. Free interactive science simulators.

PrivacyTermsContact
Home/Statistics & Probability/Law of Large Numbers

Law of Large Numbers

Coin or die: running mean x̄ₙ for several runs converges to μ; the ±σ/√n envelope shows how slowly.

Experiment

Random experiment

5
48/100

Every run draws independent outcomes from a seeded random generator (Reset reseeds; changing the experiment keeps the seed). The running mean is updated incrementally, x̄ₙ = x̄ₙ₋₁ + (xₙ − x̄ₙ₋₁)/n, and μ, σ are exact: coin μ = p, σ = √(p(1−p)); die μ = 3.5, σ = √(35/12). The law of large numbers is about the mean converging to μ — the count difference Sₙ − nμ does not shrink; its typical size grows like σ√n.

Shortcuts

  • •Space / Enter — one trial for every run
  • •P — play / pause
  • •R — reset (new seed)

Measured values

μ (theory)0.5000
σ (one trial)0.5000
Trials n so far0
x̄ₙ (run 1)—
|x̄ₙ − μ| (run 1)—
σ/√n at current n—
Spread of runs (max − min)—
Runs inside μ ± σ/√n—
Count difference Sₙ − nμ (run 1)—

About this model

The simulator repeats one random experiment many times and follows the running mean x̄ₙ = (x₁ + … + xₙ)/n as the number of trials n grows from 1 to 10 000. Four experiments are available, each with its expected value μ and standard deviation σ of a single outcome written in closed form: a fair coin scored heads = 1 (μ = 1/2, σ = 1/2), a fair six-sided die (μ = 3.5, σ = √(35/12) ≈ 1.708), a biased coin with P(heads) = 0.3 (μ = 0.3, σ = √(0.3·0.7) ≈ 0.458) and a bet on red at single-zero roulette, 18 red pockets out of 37 (μ = 18/37 ≈ 0.486, σ = √(μ(1−μ)) ≈ 0.500). Up to eight independent runs are drawn in parallel from a seeded pseudo-random generator (mulberry32), so a session is reproducible until Reset draws a new seed; the running mean is updated incrementally, x̄ₙ = x̄ₙ₋₁ + (xₙ − x̄ₙ₋₁)/n, which is numerically stable and needs no stored sample list. The chart uses a logarithmic n-axis so that the large early fluctuations and the slow late convergence appear on the same picture. The yellow horizontal line is μ; the shaded envelope μ ± σ/√n is the exact standard deviation of x̄ₙ for independent trials, Var(x̄ₙ) = σ²/n, and the optional second band is μ ± 2σ/√n. For n of a few dozen or more the central limit theorem makes x̄ₙ approximately normal, so about 68 % of runs should lie inside the first band and about 95 % inside the second; the readout counts how many of the current runs do. The checkbox 'Show count difference' redraws the same data as Sₙ − nμ (for the fair coin exactly #heads − n/2). Its standard deviation is σ√n: the count difference does not shrink but grows, even though the mean converges — the law of large numbers is a statement about averages, not about counts, and it never 'compensates' past outcomes. Simplifications: outcomes are independent and identically distributed with a finite variance (the assumptions of the weak and strong laws), the generator is pseudo-random, and the picture stops at n = 10⁴. Related simulators on this site: statistics/galton-board and statistics/binomial-distribution (the distribution of Sₙ itself), statistics/central-limit-theorem (why x̄ₙ becomes normal), statistics/confidence-interval (using σ/√n to build an interval for μ) and math/monte-carlo-pi and math/monte-carlo-integration-variance-reduction (the same 1/√n error law in Monte Carlo estimation).

Who it's for: Upper secondary (grades 10–12) and first-year introductory probability and statistics courses.

Key terms

  • law of large numbers
  • running mean
  • expected value μ
  • standard deviation σ
  • standard error σ/√n
  • independent trials
  • gambler's fallacy
  • convergence in probability

How it works

Every run repeats the same random experiment — a fair coin (heads = 1), a fair die, a biased coin with p = 0.3 or a roulette bet on red (18 of 37 pockets) — and plots the running mean x̄ₙ against the number of trials n on a logarithmic axis, so the wild early swings and the slow late convergence are visible together. The law of large numbers says x̄ₙ converges to the expected value μ; the yellow envelope μ ± σ/√n is the standard deviation of x̄ₙ, so about 68 % of runs sit inside it at any n, and it shrinks only like 1/√n — a hundred times more trials buy one more decimal place. The law is about the mean, not the count: tick "Show count difference" and the same data are drawn as Sₙ − nμ (#heads − n/2 for the coin), which does not return to zero but wanders with typical size σ√n — there is no "law of averages" that owes you tails after a run of heads. Outcomes come from a seeded generator, so a run is reproducible until you press Reset.

Key equations

x̄ₙ = (x₁ + … + xₙ)/n → μ as n → ∞ (P(|x̄ₙ − μ| > ε) → 0 for every ε > 0)
SD(x̄ₙ) = σ/√n — shrinks; SD(Sₙ − nμ) = σ√n — grows
x̄ₙ = x̄ₙ₋₁ + (xₙ − x̄ₙ₋₁)/n (incremental update)
coin: μ = p, σ = √(p(1−p)); die: μ = 3.5, σ = √(35/12) ≈ 1.708; red: p = 18/37

Frequently asked questions

After ten heads in a row, isn't the coin 'due' for tails?
No. Each toss of a fair coin is independent, so the probability of heads stays 1/2 whatever happened before. The law of large numbers does not work by compensation: it says the fraction of heads approaches 1/2, not that the number of heads approaches the number of tails. In fact the count difference #heads − #tails typically grows like √n. The excess of heads is not cancelled; it is diluted, because it is divided by an ever larger n.
How many tosses do I need before the running mean is within 0.01 of 1/2?
The standard deviation of the running mean is σ/√n with σ = 1/2 for a fair coin. Setting σ/√n = 0.01 gives n = 2500 for a typical error of one standard deviation; to be inside ±0.01 in about 95 % of runs you need 2σ/√n = 0.01, i.e. n = 10 000. Because of the square root, one more decimal place of accuracy always costs a hundred times more trials, which is why the convergence looks so slow on the chart.
Why do roughly 68 % of the runs sit inside the μ ± σ/√n band, and why not exactly?
For independent trials the variance of x̄ₙ is exactly σ²/n, so σ/√n is its exact standard deviation. By the central limit theorem x̄ₙ is approximately normal once n is a few dozen or more, and a normal variable lies within one standard deviation of its mean with probability 0.683. The value is only approximate for small n, when the distribution of x̄ₙ is still discrete and skewed (especially for the biased coin), and with only 5 or 8 runs the observed fraction can only take a few values, so it fluctuates around 68 % rather than equalling it.
Does the law of large numbers hold for the biased coin and the roulette wheel too?
Yes. The law only needs independent, identically distributed outcomes with a finite mean; for the rate of convergence a finite variance is enough. The running mean of the biased coin converges to p = 0.3 and that of the roulette bet to 18/37 ≈ 0.486, not to 1/2. For a gambler this is the bad news: the mean of winnings per spin converges to a negative number (−1/37 of the stake for an even-money bet), so playing longer makes the loss more certain, not less.