Example 2.3 Suppose that we take a card table and draw across the top surface a set of parallel lines a unit distance apart. We then drop a common needle of unit length at random on this surface and observe whether or not the needle lies across one of the lines. We can describe the possible outcomes of this experiment by coordinates as follows: Letdbe the distance from the center of the needle to the nearest line. Next, letL be the line determined by the needle, and defineθ as the acute angle that the lineLmakes with the set of parallel lines. (The reader should certainly be wary of this description of the sample space. We are attempting to coordinatize a set of line segments. To see why one must be careful in the choice of coordinates, see Example 2.6.) Using this description, we have 0≤d≤1/2, and 0 ≤θ ≤π/2. Moreover, we see that the needle lies across the nearest line if and only if the hypotenuse of the triangle (see Figure 2.4) is less than half the length of the needle, that is,

d sinθ <

1 2 .

Now we assume that when the needle drops, the pair (θ, d) is chosen at random from the rectangle 0≤θ≤π/2, 0≤d≤1/2. We observe whether the needle lies across the nearest line (i.e., whetherd≤(1/2) sinθ). The probability of this event E is the fraction of the area of the rectangle which lies insideE (see Figure 2.5).

2.1. SIMULATION OF CONTINUOUS PROBABILITIES 45

d

1/2 θ

Figure 2.4: Buffon’s experiment.

θ 0 1/2 0 d π/2 E

Figure 2.5: SetE of pairs (θ, d) withd <1_{2}sinθ.

Now the area of the rectangle isπ/4, while the area ofE is

Area = Z π/2 0 1 2sinθ dθ= 1 2 . Hence, we get P(E) = 1/2 π/4 = 2 π .

The programBuffonsNeedlesimulates this experiment. In Figure 2.6, we show the position of every 100th needle in a run of the program in which 10,000 needles were “dropped.” Our final estimate for π is 3.139. While this was within 0.003 of the true value for πwe had no right to expect such accuracy. The reason for this is that our simulation estimatesP(E). While we can expect this estimate to be in error by at most 0.01, a small error in P(E) gets magnified when we use this to computeπ= 2/P(E). Perlman and Wichura, in their article “Sharpening Buffon’s

46 CHAPTER 2. CONTINUOUS PROBABILITY DENSITIES 0.00 5.00 0.50 1.00 1.50 2.00 2.50 3.00 3.50 4.00 4.50 5.00 10000 3.139

Figure 2.6: Simulation of Buffon’s needle experiment.

Needle,”2 _{show that we can expect to have an error of not more than 5}_{/}√_{n}_{about}
95 percent of the time. Herenis the number of needles dropped. Thus for 10,000
needles we should expect an error of no more than 0.05, and that was the case here.
We see that a large number of experiments is necessary to get a decent estimate for

π. 2

In each of our examples so far, events of the same size are equally likely. Here is an example where they are not. We will see many other such examples later. Example 2.4 Suppose that we choose two random real numbers in [0,1] and add them together. LetX be the sum. How isX distributed?

To help understand the answer to this question, we can use the programAre- abargraph. This program produces a bar graph with the property that on each interval, thearea, rather than the height, of the bar is equal to the fraction of out- comes that fell in the corresponding interval. We have carried out this experiment 1000 times; the data is shown in Figure 2.7. It appears that the function defined by

f(x) =

x, if 0≤x≤1,

2−x, if 1< x≤2

fits the data very well. (It is shown in the figure.) In the next section, we will see that this function is the “right” function. By this we mean that ifaandb are any two real numbers between 0 and 2, witha≤b, then we can use this function to calculate the probability that a ≤X ≤b. To understand how this calculation might be performed, we again consider Figure 2.7. Because of the way the bars were constructed, the sum of the areas of the bars corresponding to the interval

2_{M. D. Perlman and M. J. Wichura, “Sharpening Buffon’s Needle,”}_{The American Statistician,}

2.1. SIMULATION OF CONTINUOUS PROBABILITIES 47 0 0.5 1 1.5 2 0 0.2 0.4 0.6 0.8 1

Figure 2.7: Sum of two random numbers.

[a, b] approximates the probability that a ≤X ≤ b. But the sum of the areas of these bars also approximates the integral

Z b a

f(x)dx .

This suggests that for an experiment with a continuum of possible outcomes, if we find a function with the above property, then we will be able to use it to calculate probabilities. In the next section, we will show how to determine the function

f(x). 2

Example 2.5 Suppose that we choose 100 random numbers in [0,1], and let X represent their sum. How is X distributed? We have carried out this experiment 10000 times; the results are shown in Figure 2.8. It is not so clear what function fits the bars in this case. It turns out that the type of function which does the job is called anormal density function. This type of function is sometimes referred to as a “bell-shaped” curve. It is among the most important functions in the subject of probability, and will be formally defined in Section 5.2 of Chapter 4.3. 2 Our last example explores the fundamental question of how probabilities are assigned.