Buffon’s Needle

Buffon’s needle problem is as follows: “Suppose we have a floor made of parallel strips of wood, each the same width, and we drop a needle onto the floor. What is the probability that the needle will lie across a line between two strips?” (From Wikipedia)

Simulate Buffon’s needle experiment by drawing parallel lines with constant distance 200 between them and draw needles of length 100 (half the distance between lines) randomly between the top and bottom lines. The center of the needles are uniformly distributed between top and bottom lines. The angle of the needles are uniformly distributed between 0 and 360 degrees. When a needle touch one of the lines, draw the needle in red, otherwise draw the needle in blue.

Try dropping 100, 1000, 10000, 100000 needles. Display the number of red and blue needles and the ratio between the total number of needles and the number of red needles (what does this ratio converge to?)

100 needles dropped
1000 needles dropped
10,000 needles dropped
100,000 needles dropped

Related Post