4.9.25 · D1Probability Theory & Statistics

Foundations — Monte Carlo simulation — law of large numbers basis

2,316 words11 min readBack to topic

This page assumes nothing. Every squiggle in the parent note — , , , , , , — is built here, from a picture, before you are allowed to use it. Read top to bottom; each block earns the next.


0. What is a "random variable" ?

Plain words. A random variable is just a number you don't know yet because it depends on the outcome of some random experiment. Roll a die → the number on top is a random variable. Throw a dart at a square → whether it lands in a circle (yes/no, written 1/0) is a random variable.

The picture. Think of a machine with a lever. Pull the lever and out drops a number. You can't predict which — but you can predict the pattern if you pull many times.

Figure — Monte Carlo simulation — law of large numbers basis

Why the topic needs it. Everything Monte Carlo estimates (, an integral) gets rewritten as "the typical value that drops out of some machine." We call the letter for that value (or when we feed through a function first).


1. The Uniform machine and the indicator

Two special machines appear constantly in the parent note.

The picture. The indicator is a light switch tied to a rule. Land inside the region → light ON (1). Land outside → light OFF (0). Its average is exactly the fraction of time the light is on — which is a probability. That single fact is the engine behind estimating .

Figure — Monte Carlo simulation — law of large numbers basis

2. The summation sign and the sample mean

Why the topic needs it. is the Monte Carlo estimator. Everything else on the page is about how close gets to the truth and how fast.


3. Expectation and the mean — the "true average"

Now the crucial distinction that the whole subject turns on.

The picture. Imagine the histogram of a million pulls. It has a balance point — the spot where a ruler under it would perfectly balance. That balance point is .

Figure — Monte Carlo simulation — law of large numbers basis

4. Variance — how much the machine wobbles

Why squared? We square the distance so that being below the mean (negative gap) and above it (positive gap) both count as spread instead of cancelling. Deep dive: Variance and Covariance.

The picture. Small = a tall thin pile hugging (consistent machine). Large = a wide flat pile (erratic machine). This "width" is exactly what shrinks as you average more samples — the secret of why Monte Carlo works.


5. "i.i.d." — the independence you keep hearing about

The picture. identical machines, each pulled once by a different blindfolded person in a different room. Same design (identical), no communication (independent).

Why the topic needs it. Identical gives every the same so their average targets . Independent is what lets variance simply add (§4). Break independence — use correlated samples — and the clean formula collapses. See Chebyshev's Inequality for the bound that turns this spread into a guarantee.


6. The convergence arrow and the limit

The picture. Draw a narrow band of half-width around the horizontal line . As climbs, the wobbling path of dives into that band and (almost) never leaves. A stronger version of this promise is the Strong Law of Large Numbers.


7. , and — dressing up any target as an average


8. The standard error — why "root-n"

Once variance of the sample mean is (§4), its standard deviation is the square root:

Why the ? Variance is in squared units (§4); to get a spread in the same units as the answer you take the square root, which drags the under a root too. That is the origin of the famous "": to shrink error you need to grow . The precise shape of the error's bell curve — and hence confidence intervals — comes from the Central Limit Theorem.


Prerequisite map

Random variable X

Uniform machine and indicator

Expectation E and mean mu

Sum sign and sample mean Xbar

Variance sigma squared

i.i.d. samples

Var of sample mean = sigma sq over n

Convergence in probability

Law of Large Numbers

Standard error sigma over root n

Monte Carlo simulation


Equipment checklist

Cover the right side and see if you can state each before revealing.

What does the symbol (a random variable) mean?
A number you don't know yet because it comes out of a random experiment — the output of a "machine" you pull a lever on.
What is ?
A random number equally likely to be anywhere between 0 and 1 — a perfectly balanced spinner on the line from 0 to 1.
What does the indicator output, and why is its average special?
1 if event happens, 0 if not; its average is the fraction of 1s = the probability of .
Expand .
— add them all from to .
Define the sample mean .
— the ordinary "add up and divide by how many" average of the samples.
Difference between and ?
is the fixed true average (infinite pulls); is your random guess from pulls that wobbles toward .
State linearity of expectation.
— expectation passes through sums and constants slide out.
What does variance measure?
The average squared distance of the output from its mean — how spread out / wobbly the machine is.
Why do we square the deviation in variance?
So above-mean and below-mean gaps both count as spread instead of cancelling out.
What are the two variance rules used in Monte Carlo?
(scaling squares) and when independent (variances add).
What does i.i.d. stand for and require?
Independent (no pull affects another) and identically distributed (all from the same machine, same and ).
What does mean in words?
For any tiny , the probability that is more than away from goes to 0 as .
What do , , and the hat in denote?
= target you want; = a rule applied to ; the hat marks as an estimate of from samples.
Where does the in the standard error come from?
; taking the square root to return to original units gives spread .