Monte Carlo Pi Estimation
Approximate π by randomly throwing darts at a circle. Watch the estimate converge as samples increase.
Vue.js 3
Canvas API
Statistics
About This Experiment
The Monte Carlo method is a statistical technique that uses random sampling to solve problems that might be deterministic in principle. In this demonstration, we estimate the value of π by randomly throwing "darts" at a square and counting how many land inside a circle.
The Method
We inscribe a circle inside a square. The ratio of their areas is π/4. By randomly throwing points at the square and counting how many fall inside the circle, we can estimate π:
π ≈ 4 × (points inside circle / total points)
How to Use
- Click "Start" to begin throwing darts randomly
- Watch as the estimate converges toward π (approximately 3.14159...)
- Green dots represent darts that landed inside the circle
- Red dots represent darts that landed outside the circle but inside the square
- The more samples, the more accurate the estimate becomes
Key Insights
- This demonstrates the Law of Large Numbers in statistics
- Random processes can solve deterministic problems
- More samples = better accuracy (but diminishing returns)