06Probabilistic Intelligence
Monte Carlo Simulation
Stochastic Estimation
Averaging over many random samples.
Applications
- Risk modeling
- Physics simulation
- Integration in high dimensions
Reasoning Trace
Estimate π by sampling random points in the unit square. Fraction inside the quarter-circle × 4 → π.
inside0
total0
pi_estimate?
Principle in Pseudocode
- 1inside ← 0, total ← 0
- 2repeat N times:
- 3 (x,y) ← uniform in [0,1]²
- 4 if x² + y² ≤ 1: inside++
- 5 total++
- 6π ≈ 4·inside / total
Reference implementation · pseudo
// Monte Carlo estimation of π
// See pseudocode →