LessonThis is a lesson restated in new words. Any figure in it is an example from the source, not this desk's record.

A Monte Carlo simulation estimates a probability by acting the experiment out many times with random draws and averaging the outcomes. For a basketball player who makes 70 percent of free throws, one way to ask how often at least 70 of 100 shots go in is to simulate those 100 shots over and over. In the lesson, 10,000 rounds produce an estimate of 0.556, and a new run moves a little because each run is a fresh sample.

Why it matters

Some probabilities have a tidy formula, and some are awkward once the rule gets complicated. The free-throw question is simple enough to check by hand, which makes it a good test of the method. The same pattern, repeat a random trial and average a yes-or-no result, is what later lessons use when a contract payoff depends on a whole path of prices. If you can score one trial, you can estimate the rate at which trials succeed.

The idea in plain words

Imagine finding a real player with a 70 percent free-throw rate and asking that player to shoot 100 shots, many separate times. After each round you record whether the player reached 70 makes. The fraction of rounds that cleared the bar is the estimate. A computer does the shooting with random numbers. A make is a uniform draw on the unit interval that lands at or below 0.7. A miss is a draw above 0.7. Seventy percent of the draws should be makes on average, so a round of 100 shots has an average of 70 makes. The question is how often a round lands on the high side of that average, including a round that lands exactly on 70.

The lesson appeals to a normal shape around that average: about half the rounds should fall below the mean and about half above it. The printed run, 0.556, sits a little above one half. That is the sampling picture the lesson draws. More rounds pull the printed fraction toward the probability the experiment is estimating.

How to use it

Import NumPy. Set up 10,000 trials. For each trial, create an empty list of shot results and shoot 100 times. Each shot draws a uniform number from 0 through 1. If the draw sits at 0.7 or lower, append a one. Otherwise append a zero. After the 100 shots, test the sum. If the sum is at least 70, record a one on an outer list. If the sum is lower, record a zero. The estimate is the average of that outer list.

One execution in the lesson prints 0.556. Run the script again and the third digit moves. That movement is the margin of error of a finite sample. Raising the trial count shrinks it. The inner loop is the experiment. The outer average is the estimate. Nothing in the method requires the experiment to be free throws. Any trial you can score as a one or a zero can sit in the same two loops.

What usually goes wrong

A short outer loop looks decisive and is not. A few hundred trials can print a fraction that wanders well away from the value a huge sample would give. The lesson's own point is that repeats differ, and that the estimate settles as the trial count grows.

The threshold also has to match the question. The code counts a round as a success when the makes are greater than or equal to 70. Using a strict greater-than test would drop the rounds that land exactly on 70 and would answer a different question. The per-shot test has to match the 70 percent rate. Counting a make only when the draw is strictly below 0.7 drops the equal case and answers a slightly different model. This lesson counts a make when the draw does not exceed 0.7.

The normal-curve remark is an intuition about a mean of 70 makes, not a fitted table of probabilities. The number to trust as the lesson's result is the simulated average, 0.556 on that run, with the understanding that another seed prints a close neighbor.

Questions people ask

Why is the answer near one half?

One hundred shots at a 70 percent rate average 70 makes. Asking for at least 70 is asking to land on the mean or above it, which is near half the trials. The sample printed 0.556.

Why do two runs disagree?

Each run draws new random numbers. With 10,000 trials the disagreement is a sampling margin. A larger trial count pulls later runs closer together.

What would you replace to study something else?

Keep the two loops. Change the way one trial is scored. The estimate is still the average of the ones and zeros that mark successful trials.