All Labs

Monte Carlo Simulation Lab

Use random sampling to estimate probabilities and mathematical constants. Run five classic Monte Carlo simulations, track convergence over thousands of trials, and discover the Law of Large Numbers in action.

Guided Experiment: How Many Trials Does It Take?

How does increasing the number of trials affect the accuracy of a Monte Carlo estimate? Predict how error changes as N grows from 100 to 10,000.

Write your hypothesis in the Lab Report panel, then click Next.

Dart Throwing Visualization

Controls

Throw random darts at a unit square. Count how many land inside the inscribed quarter-circle. The ratio approximates π/4.

Results

Run a simulation to see results

Data Table

(0 rows)
#Trial BatchSimulationN TrialsEstimateTrue ValueError %Converged?
0 / 500
0 / 500
0 / 500

Reference Guide

Monte Carlo Method

Monte Carlo methods use repeated random sampling to obtain numerical results. Instead of solving a problem analytically, you simulate the process many times and observe the statistical outcome.

The accuracy improves with more trials. The standard error decreases at a rate proportional to the inverse square root of N.

Error1N\text{Error} \propto \frac{1}{\sqrt{N}}

Estimating π

Throw random darts at a unit square with an inscribed quarter-circle. The fraction that land inside estimates π/4.

π4×points inside circletotal points\pi \approx 4 \times \frac{\text{points inside circle}}{\text{total points}}

A point (x, y) is inside if x² + y² ≤ 1, where both x and y are uniform random values in [0, 1].

Law of Large Numbers

As the number of trials increases, the sample average converges to the expected value. This is why Monte Carlo estimates improve with more simulations.

Xˉnnμ\bar{X}_n \xrightarrow{n \to \infty} \mu

To halve the error, you need four times as many trials. This 1/√N relationship is fundamental to all Monte Carlo methods.

Convergence Rate

The Central Limit Theorem tells us that Monte Carlo estimates follow a normal distribution centered on the true value, with standard deviation decreasing as 1/√N.

σθ^=σN\sigma_{\hat{\theta}} = \frac{\sigma}{\sqrt{N}}

This convergence rate is the same regardless of the problem dimension, which makes Monte Carlo especially valuable for high-dimensional problems.