Monte Carlo Simulation
Estimate pi by sampling the unit square, with the standard error and a seed you can repeat.
What this page computes
Type how many points to sample and a seed. The page draws pairs (u, v) from a seeded mulberry32 generator, counts those with u² + v² ≤ 1, and estimates pi as four times the inside share. It prints the estimate, the signed error against pi, the standard error 4√(p(1 − p)/N), and the seed. Between 100 and 5,000,000 points, each costing two draws. Figures print to six significant figures.
The error falls like one over the square root of N, so ten times the points buys about three times the accuracy; the page prints that standard error rather than implying the estimate is exact. It is a seeded pseudo-random run, reproducible from the seed, and it is not a source of cryptographic randomness.
All sampling happens in this tab, so the same seed and count reproduce the same estimate on every reload.
The page estimates π by sampling random points in the unit square and counting how many fall inside the quarter circle, so π ≈ 4·inside/N. Ten thousand draws from seed 42 give 3.1576, an error of 0.0160073 and a standard error of 0.0163094. The generator is mulberry32, seeded from the box, so the same seed reproduces the same estimate exactly — this is a demonstration of convergence, not a source of randomness.
Estimate π by Monte Carlo with a seed you choose. The same seed always reproduces the same estimate.
How to use it
Type how many points to sample and the seed. The point count runs from 100 to 5,000,000, and each point costs two draws, which the result line reports. Change the seed and the estimate moves; keep it and the same digits come back, which is what makes the run checkable.
Why the estimate converges slowly
The estimate is 4 times the share of points inside the quarter circle, so its error falls like 1/√N — a hundredfold increase in points buys a tenfold reduction in the standard error, and the printed standard error shows exactly that. This is the same seeded generator the random number and sampling pages use, so a seed means the same thing across all three. Nothing here is cryptographically random and the page says so.
What to Expect
Best for
- Showing Monte Carlo convergence with a reproducible seed
What this tool keeps
- Nothing leaves this tab: the arithmetic runs in the page you are reading, and a reload discards both the input and the result.
Sample output
π ≈ 3.1576 (4 × 7894/10000) error against π = 0.0160073 standard error = 4√(p(1 − p)/N) = 0.0163094 seed = 42, 10000 points, about 20000 draws mulberry32: the same seed reproduces this estimate exactly
Frequently asked questions
Why is the estimate not exactly π?
Because it is a random estimate: its standard error falls like 1/√N, and 10,000 points give about 0.016. Raising the point count narrows the error, and the printed standard error says by how much.
Will I get the same answer twice?
Yes, with the same seed and the same point count — the generator is mulberry32 seeded from the box. A different seed gives a different estimate, which is the point of the demonstration.
Is this random enough for a password or a key?
No. The generator is a small seeded PRNG chosen for reproducibility, not for cryptographic strength, and the page says so on the result. Nothing here is uploaded or stored.
Build custom tools for your store
Join the SDK program to create useful ecommerce utilities for your store.