COMPUTING SCIENCE

# Quasirandom Ramblings

Random numbers have a peculiar power, even when they are only pseudo- or quasirandom

# Integration by Darts

Here’s a toy problem to help pin down the distinctions between the *pseudo* and *quasi* varieties of randomness. Suppose you want to estimate the area of an object with a complicated shape, such as a maple leaf. There’s a well-known trick for solving this problem with the help of a little randomness. Put the leaf on a board of known area, then throw darts at it randomly—trying *not* to aim. If a total of *N* darts hit the board, and *n* of them land within the leaf, then the ratio *n:N* approximates the ratio of the leaf area to the board area. For convenience we can define the board area as 1, and so the estimated leaf area is simply *n/N*.

Tossing darts at random can be difficult and dangerous. But if you’re willing to accept dots in lieu of darts, and if you let the computer take care of sprinkling them at random, the leaf-measuring experiment is easy, and it works remarkably well.

I collected a leaf from a nearby sugar maple, photographed it, and placed the green shape within a square field of 1,024×1,024 blank pixels. Then I wrote a program that tosses random dots (actually pseudorandom dots) at the digitized image. The first time I ran the program, 429 of 1,024 dots fell on the leaf, for an area estimate of 0.4189. The actual area, as defined by a count of colored pixels, is 0.4185. The random-dots approximation was somewhat better than I expected—a case of random good luck, though nothing out of the ordinary. When I repeated the experiment 1,000 times, the mean estimate of the leaf’s area was 0.4183, with a standard deviation of 0.0153.

The basic idea in Monte Carlo studies is to reformulate a mathematical problem—such as calculating the area of a leaf—as a game of chance, where a player’s expected winnings are the answer to the problem. In simple games, one can calculate the exact probability of every outcome, and so the expected winnings can also be determined exactly. Where such calculations are infeasible, the alternative is to go ahead and play the game, and see how it comes out. This is the strategy of a Monte Carlo simulation. The computer plays the game many times, and takes the average result as an estimate of the true expected value.

For the leaf-in-a-square problem, the expected value is the ratio of the leaf area to that of the square. Choosing *N* random points and counting the number of “hits” approximates the area ratio, and the approximation gets better as *N* increases. When *N* approaches infinity, the measurement becomes exact. This last point is not just an empirical observation but a promise made by a mathematical theorem, namely the law of large numbers. This is the same principle that guarantees a fair coin will come up heads half the time when the sample is large enough.

**IN THIS SECTION**

EMAIL TO A FRIEND :

# Comments

Brian Hayes writes: "But note that the effective reduction in dimension works even when we don’t know which of the 360 dimensions can safely be ignored. That’s almost magical.
How commonplace is this...

posted by Michael Korkin

July 5, 2011 @ 4:34 PM

**Of Possible Interest**

**Feature Article**: Twisted Math and Beautiful Geometry

**Engineering**: Impossible Points, Erroneous Walks

**Feature Article**: Simulating Star Formation on a Galactic Scale