Make a Coin-Flip Simulation |
How To... > Create Simulations > Simulation Examples > Make a Coin-Flip Simulation The section Have Fathom Randomly Generate Data showed how to flip a coin using a function for choosing at random. Here we’ll flip coins by sampling. Suppose we are interested in the question “On the average, how many times will we have to flip a coin before we get three heads in a row?”
The Until condition tells Fathom to keep sampling until the three most recent values for the attribute Face are all “H.”
The formula count(), when you don’t specify count of what, gives the number of cases in the collection, in this case, the number of flips it took to get three heads in a row.
You should see a new collection named Measures from Sample of Coin. Fathom collects five measures immediately. 10. Double-click the measures collection to show its inspector. 11. If necessary, go to the Collect Measures panel. 12. Change the 5 to 95. The panel should look similar to the one shown. 13. Click Collect More Measures. You can graph this data as you normally would. The plotted mean is the average number of flips, or “wait time,” it took to get three heads in a row. |