AI Grounds

Open AI Grounds on a desktop

These interactive lessons need a larger screen. Please continue on a desktop or laptop computer.

Guided discovery

Law of Large Numbers Simulator

Extend one run and see what averaging changes.

Heads = 1, tails = 0. The fixed model’s probability of the next head is 0.5, regardless of previous outcomes. The ideal model assumes independent draws from this same fixed distribution. The seeded simulation makes the examples reproducible.

Reveal a longer or shorter prefix of this run; this does not resample it. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.

Reproduce another sequence while keeping the model probabilities fixed. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.

Showing the first 20 draws of Fair coin, seed 1309.

Running average

Solid line · observed averageDashed line · model expectation 0.5
00.5111020Number of drawsAverage

Each point is total / draws so far; the line joins discrete draw counts. A longer prefix need not be closer after every draw, and a finite run need not reach the expected value exactly.

Recent individual values, draws 13–20: 1, 0, 0, 0, 1, 1, 1, 1. Newest value: 1.

Observed average

Average of this shown prefix.

0.5500

11 / 20

Model expectation

Fixed probability-weighted mean.

0.5000

0 × 0.5 + 1 × 0.5

Absolute average gap

Distance from the model mean.

0.0500

|observed average − expectation|

Absolute total gap = |11 − 20 × 0.5| = 1.0000. Divide by 20 to get the average gap 0.0500.

Exact checkpoints

Selected prefixes of the same run. Changing only Number of draws retains every earlier value.
DrawsTotalAverageAverage gap
100.00000.5000
210.50000.0000
320.66670.1667
530.60000.1000
1050.50000.0000
20110.55000.0500
Model assumptions and what LLN says

The model holds the same probabilities for every draw and assumes independence: past results do not alter the next result’s distribution. All three examples have bounded values, hence a finite mean. For independent draws from a fixed distribution with a finite mean, the chance of the average differing from that mean by more than any fixed positive tolerance tends to zero as the draw count grows.

This is an asymptotic statement, not a finite guarantee, a claim of improvement at every step, or a demand that the next result balance earlier ones. It concerns the average rather than the sum or a single outcome. Dependent draws, changing distributions or a source without a finite mean require other analysis.

Current fixed distribution · Fair coin
ValueProbability
00.5
10.5
Berkeley SticiGui · The Long Run and the Expected Value
How reproducible simulation works

Run seed starts a deterministic 32-bit pseudorandom generator. Each generated uniform value maps to a coin result or an integer die face. Raising Number of draws extends the same prefix. Lowering it reveals an earlier prefix; it is not fresh sampling. Changing model keeps the underlying uniform stream but remaps outcomes, so displayed runs still use one fixed distribution.

Different seeds can produce different averages, and sometimes equal ones. These finite pseudorandom examples illustrate an ideal independent model; they do not prove randomness, independence, or the law of large numbers. They are not a game prediction tool.