Playing Card Probability
This example intends to answer the following question - what is the probability of getting 3 cards with red hearts and two other cards when 5 cards are drawn from a deck?

The trick is to assign a "1" to the 13 cards with red hearts and a "0" to the rest of the cards. On each iteration, 5 cards are drawn without replacement (please refer to the Lotto number generator example for this technique) and the numbers (0 and 1) associated with the 5 cards are summed up together. If the summed number is 3 then the program will add one to the counter. The probability would be the percentage between the numbers of counts and the number of iterations ran. The set of steps described above is a simulation process which can be applied to other scenarios as well. Please note that the probability of this particular scenario can be derived using the hypergeometric distribution which is shown below. The probability for this scenario should be 8.15%. The number of iterations should be at least 100,000 in order to obtain a comparable result. Figure 1, below, shows the result (7.19%) from a run of 500 iterations. The user can change the number of iterations on line 4 of the program.

x = the number of successes in the sample. (3 red heart cards drawn)
n = the size of the sample. (5 cards drawn)
M = the number of successes in the population. (13 red cards)
N = the population size. (52 cards in a deck)
Copyright ©   XL Modeling.
Contact Us