Example
Discovering Pi With Monte Carlo
The number of points randomly dropped in a circle of radius R will converge to π times the number of points randomly dropped in a square of side length R.
geometric.pointInPolygon tests whether each point landed inside the square, while geometric.lineLength measures the distance from each point to the circle center; points closer than the radius count as circle hits.
The chart tracks the ratio of circle hits to square hits as the sample grows.
Code