Monte Carlo Integration by Rejection

Throw N points into the box [-1, 1]², keep the ones inside Ω, and average f over them. The estimate is (box area) × (fraction inside) × (average f inside). Press Run and watch the error follow 1/√N. Then switch the sampler to a grid and compare.

 | 

Samples in the bounding box

Colored: inside Ω (accepted). Gray: outside (rejected).

Error vs. number of samples

Log-log. Dashed: the predicted Monte Carlo error σ/√N. Faint curves: earlier runs (use New run to keep them).