Ⅵ Counting, Probability & Statistics · Stage 33 — Probability · 33.5 Estimating Probability by SimulationAll lessons →
Stage 33 · Probability

Estimating Probability by Simulation

When the count is too hard, let a thousand random trials do the talking — and watch the frequency close in on the truth.

Ages 14–18 · Reasoning, one step at a time
One random number stands in for one coin flip; a square full of random points stands in for a whole region. Run enough of them and the success rate settles near the real P.

Some probabilities you can simply count: P(sum = 7) on two dice is 6/36, no contest. But many real questions resist a clean count — the geometry is awkward, the trial has a dozen stages, or "favorable" is genuinely hard to pin down. When the formula stalls, you can still act it out. Build a machine that imitates one trial using random numbers, press the button thousands of times, and record how often the thing you care about happens. That long-run share is exactly the frequency from Lesson 33.1 — and it steadies near the true P. This lesson turns that idea into a tool sharp enough to estimate even π.

33.5.1 Random numbers: the dice of the machine

Every simulation starts from one humble ingredient: a random number drawn uniformly from the interval [0, 1). "Uniform" means no stretch of the interval is favored — a value near 0.03 is exactly as likely as one near 0.91. A calculator's RAND key, a spinner, or a line of code all produce the same thing: an unpredictable decimal between 0 and 1.

That single uniform number is enough to imitate almost any simple trial. To flip a fair coin, draw u and call it heads when u < 0.5. To imitate a biased coin that lands heads with probability 0.7, just move the cutoff: heads when u < 0.7. To roll a fair die, slice [0, 1) into six equal strips and read off which strip u lands in.

Key idea

A uniform random number on [0, 1) is a universal trial-maker. Compare it to a cutoff p: the chance it falls below p is exactly p, because the favorable strip [0, p) takes up the fraction p of the whole interval. That is geometric probability on a line.

The interval [0, 1) split at the cutoff p. Drag the cutoff: the blue strip [0, p) is the "success" zone, and its length is the probability a single uniform draw counts as a success.
Try it Slide the cutoff and read the success zone
The blue strip's length is the probability a single uniform random number lands inside it.
cutoff p

Conclusion. One uniform draw on [0, 1), compared against a cutoff, reproduces any single yes/no trial with the probability you choose.

33.5.2 The idea of simulation: imitate, repeat, count

Here is the whole method in one breath. (1) Describe one trial in terms of random numbers. (2) Run that trial a large number n of times. (3) Count the m runs in which your event happened. The estimate is the frequency mn. By the law of large numbers — the very heart of Lesson 33.1 — that frequency wobbles less and less as n grows, closing in on the true P.

Watch it happen. Below, a fair coin (p = 0.5) is flipped over and over, and we plot the running frequency of heads after each flip. The first few flips are jumpy — a couple of heads in a row sends the curve high. But the dashed line at 0.5 is a magnet: the more flips, the tighter the curve hugs it.

Running frequency of heads for a fair coin, plotted against the trial number. Early swings are large; the curve relaxes toward the true probability 0.5.
Try it A coin simulator that converges
Pick the coin's true probability, then flip more and more — the amber frequency curve is pulled toward the green line.
true p
Worked example

Suppose we do not know a thumbtack lands point-up with what probability. We toss it 1000 times and it lands point-up 372 times. Our estimate is 3721000 = 0.372. Toss it 1000 more and we might get 0.361 — a slightly different estimate. Neither is "the" answer; both are honest readings of the same hidden P, and averaging more tosses narrows the spread.

Conclusion. Simulation converts a hard probability into a tally: imitate one trial, repeat it many times, and the success frequency mn estimates P, sharpening as n grows.

33.5.3 Simulating a real question: at least one girl

Now a question with a story. A family has three children; assume each child is independently a girl or boy with probability 0.5. What is the chance of at least one girl? We can answer this exactly with the complement shortcut from Lesson 33.3: the only way to fail is three boys, and

P(at least one girl) = 1 − P(all boys) = 1 − (0.5)3 = 1 − 18 = 7/8 = 0.875.

But pretend we did not see that trick. We can still simulate: each family is three coin flips, "at least one girl" means at least one of the three is a head, and we tally the share of families that qualify. The simulator below does exactly this. Watch the green estimate creep toward the dashed exact 7/8 as you run more families — and notice it lands a little differently each time.

Try it Three coins per family, thousands of families
Each trial flips three fair coins; a family "succeeds" if at least one flip is heads. The estimate chases the exact 7/8.
Watch out

A simulation estimates — it never proves an exact value. More trials make the estimate tighter, but a run of 7/8 ≈ 0.875 might read 0.862 today and 0.889 tomorrow. If you need the exact number and a count is available, count; use simulation when the count is out of reach, or to check a count you are unsure of.

Conclusion. A real, multi-stage question becomes a sequence of random draws; the simulated frequency approaches the exact 7/8, confirming a count we could also do by hand.

33.5.4 Estimating π by scattering points

The crown jewel of simulation is estimating a number that has nothing obviously to do with chance: π. Picture the unit square 0 ≤ x ≤ 1, 0 ≤ y ≤ 1 with the quarter-circle x² + y² ≤ 1 tucked in one corner. The square has area 1; the quarter-circle has area π4. So if we drop a point at random into the square, by the geometric-probability idea of Lesson 33.2,

P(point lands inside the quarter-circle) = area insidearea of square = π/4.

Turn that around. Scatter n random points; count the inside ones (where x² + y² ≤ 1). The fraction insiden estimates π/4, so

π ≈ 4 · insidetotal.

Each point is green inside or red outside, decided by the honest test x² + y² ≤ 1 — never by the eye. Crank up n and the estimate tightens around the true π = 3.1416…, but it never sits exactly on it.

A square sprinkled with random points; green ones fall inside the quarter-circle, red ones outside. The green share, times 4, estimates π.
Try it The Monte-Carlo π machine
Step the number of darts up; 4 · inside / total creeps toward the true π. Press "Throw again" for a fresh random run.
points n 500
Worked example

One scatter of 500 darts lands 382 inside. Then the estimate is π ≈ 4 · 382500 = 4 · 0.764 = 3.056 — close to 3.1416, off by about 3%. With 5000 darts the wobble typically shrinks to about a percent. The error falls roughly like 1/√n: to halve the typical error you need about four times as many points.

Conclusion. Counting darts inside a quarter-circle estimates π/4, so π ≈ 4 · inside / total — a geometric probability harvested by pure randomness, sharper with every extra point yet never exact.

33.5.5 How good is the estimate?

Every simulated answer comes with a built-in disclaimer: it is a sample, not a certainty. Two ideas keep you honest.

More trials, tighter answer. Doubling n does not double your accuracy — the typical error shrinks like 1/√n, so you need roughly four times the trials to halve the error. That is why simulations run thousands or millions of times, not dozens.

Different runs, different answers. Two honest simulations of the same question will disagree slightly. Neither is wrong; both are unbiased glimpses of the same hidden P. Reporting a single decimal as if it were exact is the trap — a simulation gives you a neighborhood of the truth, and a bigger n shrinks that neighborhood.

Try it Watch the spread close as n grows
For each trial size, four independent runs estimate P(at least one head in 3 flips) = 7/8. The amber band of results narrows toward the green line.
trials per run 50

Conclusion. A simulation reports a value near P with a spread that shrinks like 1/√n; trust the size of n, never a single lucky run.

What to carry forward

The simulation toolkit — every estimate is a frequency from honest random trials
IdeaHow it worksWhat you read off
Random numbera uniform draw on [0, 1); success when it is below the cutoff pimitates any single yes/no trial
Simulationimitate one trial, run it n times, count the m successesPmn
Geometric estimatescatter points; share inside the target estimates the area ratioπ ≈ 4 · insidetotal
Accuracytypical error shrinks like 1/√n4× the trials → half the error
Honestyit is an estimate, never an exact valuecount when you can; simulate when you can't

Exercises

  1. You want one uniform random number u on [0, 1) to imitate a single die roll showing a 5 or a 6. Which strip of [0, 1) should count as "success," and what is its length?
    Show answer

    Two of the six faces are favorable, so success should take up 26 = 1/3 of the interval. Let "success" be u < 1/3 (the strip [0, 1/3), of length 1/3 ≈ 0.333). Any strip of length 1/3 works equally well.

  2. A simulation of a coin tosses it 800 times and records 328 heads. Estimate the probability of heads. Is this proof the coin is biased?
    Show answer

    Estimate = 328800 = 0.41. This is below 0.5, but a single run of 800 can wander; it is evidence, not proof. More flips would tell us whether 0.41 holds up or drifts back toward 0.5.

  3. In a Monte-Carlo π run with 2000 darts, 1526 land inside the quarter-circle. What is the π estimate? How far is it from the true value?
    Show answer

    π ≈ 4 · 15262000 = 4 · 0.763 = 3.052. The true π is 3.1416, so the estimate is low by about 0.090 — roughly a 2.8% error, typical for a couple thousand darts.

  4. A family has four children, each independently a girl or boy with probability 0.5. Describe a simulation for "at least three girls," and find the exact probability to compare against.
    Show answer

    Simulate each family as four fair coin flips; "success" = at least three heads. Tally the share over many families. Exactly: P(exactly 3) + P(exactly 4) = 416 + 116 = 516 = 0.3125. The simulated frequency should settle near 0.3125.

  5. Your friend says, "I ran the π simulation and got exactly 3.14159, so simulation is exact." What is wrong with this conclusion?
    Show answer

    A simulation always estimates; matching π to five digits would be an extraordinary fluke, and the very next run would disagree. The estimate is 4 · inside / total — a ratio of whole numbers — so it can only hit certain rational values, almost never π itself. Tight, yes; exact, never.

  6. A simulation with 1000 trials gives a typical error of about 0.03. Roughly how many trials would you need to cut that typical error to about 0.01?
    Show answer

    Error shrinks like 1/√n, so cutting the error to one-third needs about 3² = 9 times the trials: roughly 9000 trials. (To merely halve an error you need about 4× the trials.)

🎯 Quick check

Six questions to lock it in. Tap the answer you think is right.

§ For teachers and parents

This lesson develops simulation as a way to estimate probabilities when an exact count is hard, and to check theoretical answers empirically — touching CCSS HSS-IC.A.2 (decide if a model is consistent with data, e.g. using a simulation) and CCSS HSS-MD.A.3 (compare an empirical frequency to a theoretical probability). The Monte-Carlo π widget and the "at least one girl" simulator both end at a known exact value (π/4 and 7/8), so the running frequency can be seen converging on the truth. The honest throughline: every quoted probability comes from a counted ratio of random trials, and the estimate tightens like 1/√n — it is never exact. A good follow-up discussion: when is it smarter to count than to simulate?

eastmath.com · Stage 33 · 33.5 Estimating Probability by Simulation · Reasoning, one step at a time