Menaksir π (Monte Carlo)
You can estimate π by throwing darts. This simulation scatters random points over a square containing a quarter circle and counts how many land inside, converging on π as the sample grows.
Cara memakai simulasi ini
- Set how many random points to throw
- Run in steps or all at once
- Reset and re-run to see a different random outcome
Yang perlu diamati
- The estimate jumps around wildly at first, then settles
- Quadrupling the samples only halves the error
- Each run gives a slightly different answer, since the sampling is random
Fisika di baliknya
The quarter circle of radius r has area πr²/4 while the enclosing square has area r², so the fraction of uniformly random points landing inside is π/4. Multiplying the hit fraction by four estimates π. Accuracy improves as the square root of the number of samples, so ten thousand points give roughly one extra digit over a hundred.