This simulator demonstrates two cornerstones of probability. In LLN mode it draws repeated independent samples from a chosen distribution and plots the running mean X̄ against the number of trials N, showing it converge to the true expectation μ. In CLT mode it repeatedly draws sets of n values, averages each set, and builds a histogram of those sample means, which approaches the Normal curve N(μ, σ²/n) regardless of the parent shape.
The Mode buttons switch between convergence and distribution-of-means views. The Experiment selector chooses the parent distribution (fair d6, d4, fair or biased coin, exponential λ=1, bimodal, uniform), each with a known μ and σ. The CLT sample size slider n (2–100) controls how many draws form each mean, and the Speed buttons (×1 to ×1k) set how many trials are generated per frame. This underpins polling, quality control and any inference from sample averages.
What is the Law of Large Numbers?
The Law of Large Numbers states that as you take more independent samples from a distribution, the average of those samples converges to the true expected value μ. In LLN mode you watch the running mean line settle onto the dashed μ line as the number of trials N grows.
What is the Central Limit Theorem?
The Central Limit Theorem says that the average of n independent, identically distributed values from any distribution with finite mean and variance is itself approximately Normally distributed, with mean μ and variance σ²/n. In CLT mode the histogram of sample means becomes a bell curve even when the parent distribution is skewed or bimodal.
What do the controls do?
The Mode buttons toggle between LLN convergence and the CLT distribution of means. The Experiment menu selects the parent distribution, the n slider (2 to 100, CLT only) sets how many draws make up each sample mean, and the Speed buttons control how many trials run per animation frame.
You can choose a fair six-sided die (μ=3.5), a four-sided die (μ=2.5), a fair coin (μ=0.5), a biased coin with p=0.3 (μ=0.3), an exponential distribution with λ=1 (μ=1), a bimodal mixture at ±3 (μ=0) and a uniform distribution on [0,1] (μ=0.5). Each has a known mean and standard deviation used to draw the theoretical overlays.
The standard error of the sample mean is σ/√n, where σ is the parent standard deviation and n is the sample size. The panel displays this value live, and it explains why the CLT histogram becomes narrower as n increases and why the LLN ±σ/√N band shrinks as more trials accumulate.
The shaded band around μ in LLN mode is the ±σ/√N confidence region, with a fainter ±2σ/√N band outside it. Because the width shrinks in proportion to one over the square root of N, quadrupling the number of trials only halves the band, which is why precision improves slowly with more data.
Yes. Each draw uses JavaScript pseudo-random numbers transformed to match the selected distribution, for example inverse-transform sampling for the exponential and a Box–Muller Gaussian for the bimodal noise. The plotted μ, σ and Normal overlays use the exact theoretical values, so the empirical histograms and running means track genuine probability theory.
Yes, and that is the striking part. Try the exponential or bimodal experiment: the individual values are strongly non-Normal, yet the histogram of their sample means still approaches a bell shape as n grows. The CLT only requires a finite mean and variance, not a Normal parent distribution.
For roughly symmetric parents, sample means look Normal even at n around 10. For heavily skewed distributions such as the exponential, larger n (30 or more) is usually needed before the histogram looks convincingly Normal. Increase the n slider and compare how quickly the bell shape forms for different experiments.
LLN concerns a single growing average: it tells you the running mean converges to μ. CLT concerns the distribution of many separate averages: it tells you how those averages are spread around μ. LLN explains why a big sample is accurate; CLT explains the shape and width of the error around that estimate.
Together these results justify most statistical inference. Opinion polling, A/B testing, manufacturing quality control, insurance risk pooling and Monte Carlo simulation all rely on sample means converging to the truth and on the Normal approximation to build confidence intervals and significance tests from finite data.