7.3 - Simulating Probabilities7.3 - Simulating Probabilities
The behavior of probability models can also be investigated using computer simulation. For example, we can simply verify any of the probability calculations in sections 7.2 and 7.3 above by simulation. The method is straightforward:
- A probability model involves a chance process that delivers a number.
- Have the computer randomly generate many instances of this process until the pattern of interest emerges.
- The beauty of the simulation method is that the user has control over how many times the process is repeated. The Law of Large Numbers tells us that with enough repetitions the pattern will emerge.
Example 7.8: Reeses Pieces Simulation
Reeses Pieces candies come in brown, orange, and yellow colors. The Reese Pieces applet at the Rossman/Chance Applet Collection website lets you simulate draws from a hypothetical population of Reeses Pieces and take data on the orange candies in your sample(s). For example, suppose you wanted to draw 101 Reeses Pieces from a jar with 52% of the candies being orange. You would enter 0.52 as "Probability of Orange" and 101 as "Number of candies" then hit the "draw samples" button. The figure below shows an example result from the Reeses Pieces applet.
In this example, the applet chose 50 orange candies out of 101 - slightly less than a majority even though the true proportion in the population was 52%. Of course, that's what will happen with a random sample. Sometimes you will get a little more and sometimes a little less than the true percentage. If you asked the applet to take a thousand samples instead of just one, you would get a good feel for the randomness from sample-to-sample.
If we wanted to know the probability that our sample would get a majority of orange Reese's Pieces, we can just draw several thousands of samples and see what proportion of those samples found a majority of orange-colored candies. That's the essence of using simulation to estimate probabilities. Now try this on your own. Go to the link and enter 0.52 as the probability of orange, 101 as the number of candies, and say 10,000 as the number of samples then draw the samples and look at the histogram of the results. Now that you have the samples drawn, you can ask the applet to count how many times you had a majority of orange candies in your sample (e.g. ask for a number of orange candies as extreme as 51). You should get an answer to a proportion of around 65% or 66% (since the exact probability is about 65.7%).
President Obama received 52% of the popular vote in Pennsylvania in the 2012 election. If you took a simple random sample of 101 randomly chosen Pennsylvania 2012 voters, use simulation to find the chance that a majority of your sample would have voted for the President in the last election.