From charlesreid1

Line 27: Line 27:
</math>
</math>


Now, you may be wondering why we use the binomial distribution, if we are trying to model a process with replacement? Isn't the hypergeometric distribution more appropriate? You would almost be correct - except that we are analyzing a single event.
If we want a probability, we can compute the number of hands with aces over the number of total hands:


In other words, in this process, success is not defined as "the next card being dealt comes up an ace", with many trials and many outcomes. Success is defined as "one of five cards, pulled at random from the deck, will be an ace." That means that pulling five cards is a single event, a single independent trial, with a single outcome.
<math>
\dfrac{\binom{52}{5} - \binom{48}{5}}{\binom{52}{5}} = \dfrac{18,472}{54,145} \approx 0.3411\dots
</math>
 
We can empirically verify this by writing up a simple computer program: it creates a deck of cards, shuffles it, picks 5 cards at random, and determines if there is an ace in the hand. It repeats this procedure millions of times. Here are the results of several runs of the program, showing good agreement with theory:
 
<pre>
$ javac CountAces.java && java CountAces
N_aces / N_cards = 341129 / 1000000 = 0.3411
N_aces / N_cards = 341178 / 1000000 = 0.3412
N_aces / N_cards = 341416 / 1000000 = 0.3414
</pre>
 
Now, you may be wondering why we use the binomial distribution, if we are trying to model a process with replacement? Isn't the hypergeometric distribution more appropriate? (Maybe not after seeing the numbers presented above.) Well, you would ''almost'' be correct - except for the fact that we are only analyzing a single event, so it doesn't matter whether we replace or not.
 
In other words, in this process, success is not defined as "the next card being dealt comes up an ace", with many trials and many outcomes. Success is defined as "one of five cards, pulled at random from the deck, will be an ace." That means that pulling five cards is a single event, a single independent trial, with a single outcome. The program above shuffles the deck between each hand, so each hand is a single, independent trial.


Another way to think about it is, our success criteria applies to all of the cards at once, and is only met or not when all five cards have been dealt.
Another way to think about it is, our success criteria applies to all of the cards at once, and is only met or not when all five cards have been dealt.

Revision as of 10:15, 23 July 2017

Mathematics related to cards.

Notes

Combinatorics and Counting

Probability of 5-Card Hands

Here, we give two examples that illustrate the care that is needed when setting up the problem and deciding how to model the process. In the first procedure, we are looking for five-card hands with at least one particular face value - which we model as a single event. In the second procedure, we are looking for five-card hands with exactly one occurrence of a particular face value, which requires us to think about each card being dealt as separate events.

Note that the total number of 5-card hands is given by $ \binom{52}{5} = 2,598,960 $.

Hand with at least one X

Suppose we wish to know the probability that a given 5-card hand will contain at least once ace.

In this case, it is slightly easier to enumerate the number of hands that do not contain any aces. We re-pose the problem as counting the number of ways we can form 5-card hands from 48 cards (the 52 total minus the 4 aces). This probability is given by:

$ \binom{48}{5} = 1,712,304 $

This gives the total number of 5-card hands that contain at least one ace as the total number of possible hands minus the number of hands without aces:

$ \binom{52}{5} - \binom{48}{5} = 886, 656 $

If we want a probability, we can compute the number of hands with aces over the number of total hands:

$ \dfrac{\binom{52}{5} - \binom{48}{5}}{\binom{52}{5}} = \dfrac{18,472}{54,145} \approx 0.3411\dots $

We can empirically verify this by writing up a simple computer program: it creates a deck of cards, shuffles it, picks 5 cards at random, and determines if there is an ace in the hand. It repeats this procedure millions of times. Here are the results of several runs of the program, showing good agreement with theory:

$ javac CountAces.java && java CountAces
N_aces / N_cards = 341129 / 1000000 = 0.3411
N_aces / N_cards = 341178 / 1000000 = 0.3412
N_aces / N_cards = 341416 / 1000000 = 0.3414

Now, you may be wondering why we use the binomial distribution, if we are trying to model a process with replacement? Isn't the hypergeometric distribution more appropriate? (Maybe not after seeing the numbers presented above.) Well, you would almost be correct - except for the fact that we are only analyzing a single event, so it doesn't matter whether we replace or not.

In other words, in this process, success is not defined as "the next card being dealt comes up an ace", with many trials and many outcomes. Success is defined as "one of five cards, pulled at random from the deck, will be an ace." That means that pulling five cards is a single event, a single independent trial, with a single outcome. The program above shuffles the deck between each hand, so each hand is a single, independent trial.

Another way to think about it is, our success criteria applies to all of the cards at once, and is only met or not when all five cards have been dealt.

We will see in the next section that if we are concerned with the actual process of dealing the hand (i.e., we check criteria as the deal is happening), then we must treat each card as a separate event - and then we no longer have independent sampling with replacement, and we cannot use the binomial distribution. Instead, we have sampling without replacement, and we must use the hypergeometric distribution.

Hand with exactly one X

Now suppose we wish to know the probability that a given 5-card hand contains exactly one ace.

Combinatoric Solitaire

Knuth mentions an anecdote about runs/sequences of increasing integers - there was a mathematician/scientist who would play a form of solitaire in which he would place cards on an existing pile as their face value increased, and start a new pile as their face values decreased. The question is, how many piles will result, and playing this form of solitaire is a form of "empirical" sampling.

Related