# Probability of Getting a pair of cards

I was wondering what could be the probability of getting at least a pair of cards , when every time you draw 6 cards at random from a fresh deck of cards.

I calculated it as: 3/51 * 48/50 * 44/49 * 40/48 * 36/47 * 15(6C2) = 0.48

Let me know if it is correct?

-

## migrated from stackoverflow.comJul 25 '12 at 18:36

This question came from our site for professional and enthusiast programmers.

What's the probability of not getting a pair of cards after drawing n cards?

• n = 1: p = 1
• n = 2: p = 1 * (48/51)
• n = 3: p = 1 * (48/51) * (44/50)

etc...

You want 1 - p.

You could also verify that the result is roughly correct by running many simulations and using this to estimate the probability:

import random

got_pair = 0
n = 6
trials = 10000

deck = [value for suit in 'CDHS' for value in 'A23456789TJQK']
for i in range(trials):
random.shuffle(deck)
if len(set(deck[:n])) < n:
got_pair += 1

print(float(got_pair) / trials)


Result

0.6542


Note that the result is only an approximation, but it can be a useful aid to check that you didn't make an error with the mathematics.

-
it should be n=2: p=1*(48/51), n=3:p=1*(48/51)*(44/50) etc., right? –  Nishant Jul 25 '12 at 18:16
Yes, I forgot to remove the jokers. –  Mark Byers Jul 25 '12 at 18:20
Thanks for the quick answer. –  Nishant Jul 25 '12 at 18:28
I guess that edit with the program code is somewhat less relevant now that the question has been migrated.... –  Mark Byers Jul 25 '12 at 18:38

We are counting the probability of at least one pair, meaning that we are allowing "three of a kind" or "two pairs."

How many no pair hands are there? We must choose $6$ different denominations from the $13$ denominations available. There are $\binom{13}{6}$ ways to do this.

For every choice of denominations, there are $4^6$ ways to choose the actual cards.

So the number of no pair hands is $\binom{13}{6}4^{6}$.

To find the probability of a no pair hand, divide by $\binom{52}{6}$. So the probability of getting at least one pair is $$1-\frac{\binom{13}{6}4^6}{\binom{52}{6}}.$$

Remark: To count the number of hands that have exactly one pair, do this. The denomination can be chosen in $\binom{13}{1}$ ways. For each choice, the actual card can be chosen in $\binom{4}{2}$ ways. Now choose the denominations we will have singles in. This can be done in $\binom{12}{4}$ ways. And now the actual singletons can be chosen in $4^4$ ways, for a total of $$\binom{13}{1}\binom{4}{2}\binom{12}{4}4^4.$$ For the probability we have precisely one pair, divide by $\binom{52}{6}$.

-