Loading...
Loading...
Mathematical Modeling · Axiom Academy
Worked examples demonstrating Monte Carlo simulation for estimation and risk analysis Goal: Estimate the value of pi using random sampling. Geometric Insight: Consider a unit square [0,1] x [0,1] and a quarter circle of radius 1 inscribed within it. The area of the quarter circle is pi/4, while the area of the square is 1. Therefore, if we randomly scatter points uniformly in the square, the probability that a point lands inside the quarter circle equals pi/4. Random Variable Identification X ~ Uniform(0, 1): x-coordinate of a random point Y ~ Uniform(0, 1): y-coordinate of a random point Indicator variable: I = 1 if X^2 + Y^2 <= 1 (point inside quarter circle), I = 0 otherwise Expected value: E[I] = P(X^2 + Y^2 <= 1) = pi/4 Set N = number of samples (e.g., 10,000) For i = 1 to N: - Generate X ~ Uniform(0,1) and Y ~ Uniform(0,1) - If X^2 + Y^2 <= 1, increment hits Estimate: pi_hat = 4 * (hits / N) By the Law of Large Numbers, as N approaches infinity, our estimate converges to the true value: The standard error of our estimate decreases as: Sample Results: With N = 10,000 samples, typical estimates range from 3.12 to 3.16. With N = 1,000,000, estimates typically fall within 3.140 to 3.143. The true value is pi = 3.14159... This method, while not the most efficient way to compute pi, beautifully illustrates how randomness can solve deterministic problems. If you run the simulation with N = 40,000 samples instead of N = 10,000, how does the expected error change?
This is the written version of the interactive lesson above. See the full Mathematical Modeling course.