Randomly break a stick (or a piece of dry spaghetti, etc.) in two places, forming three pieces. The probability that these three pieces can form a triangle is 1/4 (coordinatize the stick form 0 to 1, call the breaking points x and y, consider the unit square of the coordinate plane, shade the areas that satisfy the triangle inequality edit: see comments on the question, below, for a better explanation of this).
The other day in class*, my professor was demonstrating how to do a Monte Carlo simulation of this problem on a calculator and wrote a program that, for each trial did the following:
- Pick a random number x between 0 and 1. This is the first side length.
- Pick a random number y between 0 and 1 - x (the remaning part of the stick). This is the second side length.
- The third side length is 1 - x - y.
- Test if the three side lengths satisfy the triangle inequality (in all three permutations).
He ran around 1000 trials and was getting 0.19, which he said was probably just random-chance error off 0.25, but every time the program was run, no matter who's calculator we used, the result was around 0.19.
What's wrong with the simulation method? What is the theoretical answer to the problem actually being simulated?
(* the other day was more than 10 years ago)
