Quantcast
Channel: Algorithm Soup
Viewing all articles
Browse latest Browse all 10

What Linearity of Expectation Has to Do with Needles and Pi

$
0
0

Take a needle of length {\ell} and drop it in a random position on a hardwood floor whose boards have the same width {\ell}:

 

stick_drop

 

There’s some probability {p} that the needle crosses between two adjacent floorboards. It turns out that {p} has a surprisingly simple formula,

\displaystyle p = \frac{2}{\pi}.

Does this mean we can drop thousands of needles (or, for safety-sake, popsicle sticks) to accurately estimate {\pi}? A few years ago, my friend Jake Hillard and I put this to the test. Jake measured out the width between floorboards in the Stanford History Department and 3D-printed a few dozen popsicle sticks of the same length. Here’s one I kept as a momento:

stick

(Since the sticks weren’t infinitesimally thin, the rule was to count a crossing only if the center of the stick crossed.)

With the help of Stanford Splash, we then recruited about a hundred middle- and high- school students to perform the experiment. In total, we recorded roughly {4,000} popsicle-stick drops, and ended up estimating {\pi} to about…. {2.95}. That’s actually not too far from what we expected, since even with no experimental error at all, the standard deviation that we would expect with {4,000} data points is roughly {0.07}.

Ok, so dropping popsicle sticks clearly isn’t the best way to estimate {\pi}. But I’m hoping I can convince you that it is one of the combinatorially coolest. And that’s because the formula for {p} is actually just an extraordinarily slick (although slightly informal) application of linearity of expectation.

Anything Can be Solved with Enough Glue. For simplicity, I’ll assume for the rest of the post that $\ell = 1$. Imagine that, instead of dropping a single needle, we drop {n} needles, glued together to form a regular {n}-gon. Here’s an example for {n = 8}:

 

polygon_drop

Each needle individually crosses between two floorboards with probability {p}. By linearity of expectation, the expected total number of crossings by our {n}-gon is {n \cdot p}. That is, the {n}-gon as a whole should, on average, induce {n} times as many crossings as would a single needle.

But now let’s think about what this picture looks like when {n} is large.

circle_drop

When {n} is very large, our {n}-gon starts to closely resemble a circle with circumference {n}. The height of the {n}-gon corresponds with the diameter of the circle, and is therefore roughly {n / \pi} (This step of the argument isn’t actually as obvious as it sounds, and requires a bit more work to be formal). But no matter how we drop our circle-like {n}-gon on the hardwood floor, the total number of crossings will always be almost exactly the same (up to {\pm 1})! In particular, the total number of crossings by needles in the {n}-gon is just twice the height of the {n}-gon, i.e., 2  \cdot n / \pi. Since the expected number of crossings can be expressed as {n \cdot p}, it follows that, as {n} grows large, {n \cdot p} approaches {2 \cdot n / \pi}. Hence the formula {p = 2 / \pi}.


Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles



Latest Images