Unit 8: Simulating Probabilities

Home | Contact us   
  Main Concepts | Demonstration | Teaching Tips | Data Analysis & Activity | Practice Questions | Connections | Fathom Tutorial | Milestone 
 

   

Data Analysis & Activity

Activity

This activity will help you use Fathom to do simulations.

1. How to simulate random data from Fathom

a) Create a new Collection
Pull down the "collection" tool onto the desktop.

b) Create new cases
After selecting the collection (by clicking on it once), choose "New Cases" under the Data menu item at the top. This will ask you to choose the number of cases you want.

c) Open the inspector and name the attribute.
For example, type "normalrandom".

d) Add a formula
Double click on the "Formula" column so that the formula editor appears. Click on the triangle beside the word "Functions", to see a list of all functions available. scroll down until you see "Random Numbers." Click on the triangle next to this to see examples of distributions from which you can generate random numbers. For example, to simulate drawing a sample of 100 men's heights from a normal distribution, type "randomNormal(70,3)".

2. Simulating Roulette.

Problem: we spin the roullette wheel. If we bet on black, what's the approximate probability we win? We bet on 15 and 16. What's the probability we win?

Note: For the sake of this problem, a roulette wheel looks like this: It has two green numbers: 0 and 00. The numbers 1 through 36 alternate colors so that the odd colors are black and the even numbers are red.

Before doing this in Fathom, let's think about what we want to do.

a) Define a "trial". A trial consists of spinning the wheel and noting whether the color is black (for the first problem) or whether the number is a 15 or 16.

b) Define the statistic we're interested studying. We're interested in the frequency with which black appears (or 15 and 16's). So essentially, at the end of a trial, we record a "1" if the outcome was black.

c) Define a repetition: We repeat steps (a) and (b) N times.

e) Result: Add up the number of "1"s and divide by N to get an approximate probability that the outcome will be black..

How to implement in Fathom?

1) Create the "wheel". Each outcome has two attributes: color and number. So we need to create a new collection and then, by selecting "Add new cases" from the "Data" menu, add 38 new cases.

Open the inspector and create two new attributes: Color and Number.

The color value for the first case is green and the number value is 00. (Fathom will change this to a "0". That's okay for now.)

Create the second case: its color value is green and number value is 0. After that, create a case for each outcome: Black 1, Red 2, Black 3, etc.

2) Take an initial sample. Click once on the collection, and then select "Sample Cases" from the Analyze menu. A new collection, called Sample of Collection 1 will appear. Double-click on this to open its Inspector.
* Turn off animation
*Make sure you're sampling with replacement
* Sample just 1 case (since we spin the wheel only once in a trial.)
*click on Empty this Collection First box so that there is an "X" in the box.
*Click on "Sample more cases"

Click on the "cases" tab of the inspector. You should see a single outcome (at the bottom of the inspector, next to the right and left arrows, you should see "1/1".

Click on the "Sample" tab and turn off the "Empty this Collection First". (There should no longer be an "X" here.)

Click on Sample more cases. Youv'e just spun the wheel again.

Change the number of cases to be the number of trials you want to perform (what we're calling N.) For example, try putting 100 here. Click on sample more cases.

3) We don't necessarily care about the color unless its black. Click on the Cases tab of the sample's Inspector. Create a new attribute called "isblack". Open up the formula editor and type in a new formula: "if (color) = "black" At this point, the editor will take over and reformat what you've typed, adding a closing parenthesis and brackets with two question marks. Hit the tab key, and the cursor will jump to one of the question marks. Type "1". Hit tab again to highlight the other question mark. Type "2". Click on "OK"

4) What we really want is to know the frequency of 1's. So click on the "measure" tab. This new window gives us a place to define summar stats. Name the new measure "PercentBlack". Open up the formula editor and type "sum(isblack)/count()" The result is the percent black.

The theoretical probability is 18/38 = .47368

You can continue to collect more "data" i.e. more trials of your simulation (in batches of 100), by selecting "Sample More Cases" from the Analyze menu.


* Click on the Sample button.