Probability of a Pair |
How To... > Create Simulations > Simulation Examples > Probability of a Pair A deck of cards is made of spades only. The cards are shuffled, and the first card is drawn. The value is written down, the card put back in the deck, and the deck shuffled again. A second card is drawn. What is the probability that the two cards were the same? Theoretically, the probability is 1/13, because it doesn’t matter what card is drawn first and the probability is 1/13 that the second card will match the first. Let’s see how to construct a simulation of the situation. We’ll start with a collection of just two cases, one for each drawn card. (A sampling simulation would be more faithful to the scenario but slightly more complicated to construct.)
Now we need a measure that detects when the two cards are equal. We’ll use this opportunity to introduce the extremely useful uniqueValues function.
Convince yourself that this measure does the right thing by rerandomizing a bunch of times (Collection | Rerandomize). You could, of course, record the results of rerandomization by hand, but the beauty of using a computer is that you can automate the process. In Fathom, that’s done by collecting measures.
You should see five gold balls fly from the collection to the newly named Measures from Two Cards collection. This measures collection now has five cases with a single attribute named IsAPair whose values are “true” or “false.”
We want Fathom to collect many more measures so that we can get a reasonable estimate of the probability of a pair.
As the measures are collected, you’ll see the bar chart respond. How does the observed probability in this simulation compare with the theoretical value? See also |