Ask the Wizard: |
Probabilities with cards |
Can you recommend a function to map any five cards from a 52-card deck to an integer from 0 to 2,598,959? — James from Worcester, MA
Yes. First assign each card a value from 0 to 51. Call the cards c1 to c5, ordering them with c1 as the lowest to c5 as the highest. Then call the following function:
int GetIndex(int c1, int c2, int c3, int c4, int c5)
{
return combin(c5,5) + combin(c4,4)+ combin(c3,3) + combin(c2,2) + combin(c1,1);
}
Where combin returns the traditional value, except if the first value is less than the second value, return 0, as follows:
int combin(int x, int y)
{
if (y>x)
return 0;
else
{
int i,n;
n=1;
for (i=x-y+1; i<=x; i++)
n*=i;
for (i=2; i<=y; i++)
n/=i;
return n;
}
}
If you are doing this to access an array element, load the array as follows.
count=0;
for (c5 = 4; c5 < 52; c5++)
{
for (c4 = 3; c4 < c5; c4++)
{
for (c3 = 2; c3 < c4; c3++)
{
for (c2 = 1; c2 < c3; c2++)
{
for (c1 = 0; c1 < c2; c1++)
{
index_array[count]=WhateverYouWish;
count++;
}
}
}
}
}
January 12, 2009
What is the probability that any two chosen ranks, for example queen and king, will appear consecutively in a random deck? Somebody challenged me to an even-money bet that it would happen. — Rob from Saratoga, CA
According to a random simulation, the probability is 48.64%. So, I would have taken that bet. August 29, 2008
If you pick five cards at random from a standard 52-card deck, what is the probability that all four suits will be represented?
— Carl Libis from Richmond
There would have to be one suit with two cards, and three with one card each. There are four possible suits for the one that is represented twice. For the suit represented twice, there are combin(13,2)=78 ways to choose 2 ranks out of the 13. For each of the other three suits, there are 13 possible ranks each. So, the total number of combinations is 4 × 78 × 13 × 13 × 13 = 685,464. There are combin(52,5)=2,598,960 ways to choose 5 cards out of 52. So the probability is 685,464/2,598,960 = 26.37%. April 21, 2008
What are the odds if you draw 3 cards out of a deck that exactly one of them will be a spade? – Bill from Tempe
The probability the first card is a spade, and the second two are not, is (13/52)×(39/51)×(38/50) = 14.53%. You should then multiply that by 3, because the spade could be any one of the three cards. So the answer is 3×14.53% = 43.59%. For those who prefer the combinatorial function, the answer is 13×combin(39,2)/ combin(52,3) = 9633/22100 = 43.59%. January 13, 2008
First, choose 5 cards from a single 52-card deck. Second, add their blackjack values (T,J,Q,K = 10, A = 1). What are the odds the sum is even/odd? I would think that with the over-abundance of even cards, the sum would be much more likely to be even. — Eliot from Santa Barbara
Surprise, an odd total is more likely at 50.03%, despite 30 of the 52 cards being even. The following table shows the probability of each even/odd split.
| Odd/Even Question |
| Evens |
Odds |
Combinations |
Probability |
Sum |
| 0 | 5 | 15504 | 0.005965 | Odd |
| 1 | 4 | 155040 | 0.059655 | Even |
| 2 | 3 | 565440 | 0.217564 | Odd |
| 3 | 2 | 942400 | 0.362607 | Even |
| 4 | 1 | 719200 | 0.276726 | Odd |
| 5 | 0 | 201376 | 0.077483 | Even |
| Total | | 2598960 | 1 | |
January 2, 2008
Suppose that 5 cards are dealt from a 52-card deck and the first
one is a king. What is the probability of at least one more king? I saw an Ace problem you were doing like this one but I couldn’t really follow it. Thank you for any help. — Brian from College Station
The way I prefer to answer probability questions is to use the combinatorial function. Doing it that way, there are combin(48,4) = 194,580 ways to choose four cards that are not kings out of the 48 non-kings in the deck. There are combin(51,4)=249,900 ways to choose any four cards out of the remaining 51 cards in the deck. So the probability of getting no kings in the next four cards are 194,580/249,900 = 77.86%. Thus, the probability of getting at least one kind is 100% - 77.86% = 22.14%.
Several people have said that the combinatorial function is probably over the heads of the type of people asking these kinds of simple probability questions. I don't disagree with that, but a major reason for this site is to try to teach my readers something about math. The combinatorial function is extremely useful in probability, and saves a lot of time. However, the question at hand can be easily answered without it.
The probability the second card is not a king is 48/51. That is because there are 48 non-kings left in the deck, and 51 total cards left. If the second card is not a king, the probability the third card is also not a king is 47/50 (47 non-kings divided by 50 cards left). Following this to the end, the probability that none of the other four cards are kings is (48/51)×(47/50)×(46/49)×(45/48) = 77.86%. The probability that this is not the case, in other words at least one king, is 100% - 77.86% = 22.14%.
January 2, 2007
Playing last night, one of the players, an old crafty scruffy aggressive player, was challenging the table to make even money side bets on the flop. This old curmudgeon was betting that one of the three cards on the flop would be either an ace, deuce, or jack (sometimes he would change the 3 identifiable cards). What are the odds of this bet? Your sage wisdom would be greatly appreciated.
Before any cards are seen, the probability of any three ranks not appearing on the flop are combin(40,3)/combin(52,3) = 9880/22100 = 44.71%. So this guy had a 10.59% advantage. September 20, 2007
I was at Foxwoods the other day, watching the final two tables of the Foxwoods Poker Classic. When Vince Van Patten (one of the World Poker Tour hosts) came in to watch, he started making all kinds of prop bets with some of the poker pros who were hanging around. He was offering anyone 20 to 1 if they could flip through an entire deck of cards cycling through the ranks and saying aloud while peeling each card Ace, 2, 3, 4, and so on up to King and starting again at Ace without ever having the card they're announcing come up. Nobody made it all the way through and Vince won a few hundred dollars in about 10 minutes before everybody gave up. I know this has to be possible, but I have a suspicion Vince has quite the hustle going offering only 20 to 1 on this. What are the odds of actually getting through the whole deck? – Matt from New Britain
A simple way to estimate the probabiity of winning is to assume that every card has a 12/13 probability of not matching the stated rank. To win this bet, the victim would have to do this successfully 52 times. The probability of 52 wins is (12/13)52 = 1.56%. A fair price to pay would be 63.2 to 1. At 20 to 1 Vince had a 67.3% advantage (ouch!).
Accoring to G.M., who is a better mathematician than I am, the actual probabiliy is 1.6232727%. The reason for the difference is the outcome of each pick is positively correlated to previous picks.July 17, 2007
I am a pit supervisor at a local casino and recently had a dealer deal two players two seven of clubs each and give himeself the last seven of clubs as his upcard on a five-deck shoe. What are the odds of five of the same card coming out of a five-deck shoe in order? – Jesse from Scottsdale
What are the odds of being the dealt 2-3-4-5-7 unsuited? Thanks a lot, the site's great! - Kevin from Massapequa
How many five-card combinations of a standard playing card deck have cards from exactly two suits? - Samantha from Belize
The two suits can be divided either 4 and 1 or 3 and 2. Let's look at the 4/1 split first. There are 4 suits to choose from for the one with 4 cards, and 3 left for the one with 1 card. There are combin(13,4)=715 ways to choose 4 ranks out of 13. There are 13 ways to choose a single rank. So there are 4×3×715×13=111,540 ways to have a 4/1 split between the two suits. By similar logic there are 4×3×combin(13,3)×combin(13,2)=267,696 ways to have a 3/2 split. So the overall probability is (111540+267696)/combin(52,5) = 14.59%.
December 26, 2006
What are the odds of being dealt the jack of diamonds
27 hands in a row in a six-card game?
The probability of getting it any one hand is
6/52. The probability of getting it 27 hands in a row is
(6/52)27 = 1 in
20,989,713,842,161,800,000,000,000.
Jan. 16, 2005
From a single deck if I deal 4 cards what are the odds
that at least 1 card is a spade?
The probability of zero spades is
(39/52)*(38/51)*(37/50)*(36/49) = 0.303818. So the
probability of at least one spade is 1-0.303818 =
0.696182. Jan. 2,
2005
Suppose you have two five-card poker hands dealt from
separate decks. You are told hand A contains at least one
ace. You are told hand B contains the ace of spades. Which
hand is more likely to contain at least one more
ace?
The following table shows the probability of 0
to 4 aces in a totally random hand.
|
Ace Probabilities - Random Hand
|
|
Aces
|
Formula
|
Combinations
|
Probability
|
|
0
|
combin(48,5)
|
1712304
|
0.658842
|
|
1
|
combin(4,1)*combin(48,4)
|
778320
|
0.299474
|
|
2
|
combin(4,2)*combin(48,3)
|
103776
|
0.03993
|
|
3
|
combin(4,3)*combin(48,2)
|
4512
|
0.001736
|
|
4
|
combin(4,4)*combin(48,1)
|
48
|
0.000018
|
|
Total
|
|
2598960
|
1
|
Take the sum for 1 to 4 aces we see the probability of
at least one ace is 0.341158. The probability of two or
more aces is 0.041684.
The probability of there being at least one more ace
given there is at least one can be restated per Bayes'
theorem as probability(two more aces given at least one
ace) = probability (two or more aces)/probability(at
least one ace) = 0.041684/ 0.341158 = 0.122185.
For those rusty on Bayes' Theorem it states the
probability of A given B equals the probability of A and
B divided by the probability of B, or Pr(A given B) =
Pr(A and B)/Pr(B).
The next table shows the combinations and probability
for each number of other aces given that the ace of
spades was removed from the deck.
|
Ace Probabilities - Ace Removed Hand
|
|
Aces
|
Formula
|
Combinations
|
Probability
|
|
0
|
combin(3,0)*combin(48,4)
|
194580
|
0.778631
|
|
1
|
combin(3,1)*combin(48,3)
|
51888
|
0.207635
|
|
2
|
combin(3,2)*combin(48,2)
|
3384
|
0.013541
|
|
3
|
combin(3,3)*combin(48,1)
|
48
|
0.000192
|
|
Total
|
|
249900
|
1
|
This shows the probability of at least one more ace is
0.221369.
However suppose you want to solve it the same way as
hand A, using Bayes' Theorem. The probability of at least
one additional ace, given the hand contains the ace of
spades, could be rewritten as probability(at least two
aces given ace of spades is in hand). According to Bayes'
theorem this equals Probability(hand contains ace of
spades and at least one more ace) / Pr(hand contains ace
of spades). We can break up the numerator as
Probability(2 aces including ace of spades) +
Probability(3 aces including ace of spades) +
Probability(4 aces). Using the first table this equals
0.039930*(2/4) + 0.001736*(3/4) + 0.000018 = 0.021285.
The probability of the ace of spades is 5/52 = 0.096154.
So the probability of at least two aces given the aces of
spades is 0.021285/0.096154 = 0.221369.
So the probability of two or more aces given at least
one ace is 12.22% and given the ace of spades is 22.14%.
Oct. 25, 2004
Okay, I believe your numbers but it still doesn't make
sense to me. I should think the probabilities would be
equal. What difference does the suit make of the one ace you
are given?
Let's look at another simpler situation. Suppose
woman A says "I have two kids and at least one is a boy."
Woman B says "I have two kids and the older one is named
John." We can assume nobody named John is a girl and no
woman gives the same name to more than one kid. Using
conditional probability the probability of both kids
being a boy of woman A is pr(both boys)/pr(at least one
boy) = pr(both boys)/(1-pr(both girls)) = (1/4)/(1-(1/4))
= (1/4)/(3/4) = 1/3. However the probability woman B's
younger kid is a boy, or both kids are boys, is ½,
because saying the older child is named John tells us
nothing about the younger child.
To make another example suppose you go to Jiffy Lube
and they offer two deals for the same price. Deal A is
they will check four parts and replace only the first
defective one found. Deal B is they will check only one
problem and fix it if found. Wouldn't you rather take
deal A? Your car came in with the same number of expected
bad parts but the probability of finding a problem is
greater under deal A, and thus you will leave with a
small number of expected defective parts under that plan.
Likewise a test for any ace will probably turn up the
only ace, while a test for the ace of spades does not
check for the other three suits, leaving them more likely
to be aces. Oct. 25,
2004
Dear Wiz, say a deck of 52 cards is shuffled, and we
draw 18 of the 52 cards at random, placing the 18 cards into
6 piles of 3 cards each. What is the probability that one of
the piles contains exactly 3 (of the 4) aces?
The easy way to solve the problem is that the
probability the first pile has three aces is
(4/52)*(3/51)*(2/50) = 1/5525. However each pile has an
equal probability of having three aces so we multiply by
6, yielding 6/5525 = 0.001086
April 4, 2004
What are the odds of passing out 13 cards each to four
players using a 52 card deck and all four player have a
straight from Ace to two? The cards don't have to be in the
same suit.
The answer is (413/COMBIN(52,13))*
(313/COMBIN(39,13))*
(213/COMBIN(26,13)) = 1 in 61,204,166,001.
Oct. 15, 2003
First I wanted to tell you how much I look at and love
your web site, and admire your math skills. I use 6 decks to
deal blackjack, and added 3 jokers for reasons I won't waste
your time with but, what are the odds of dealing all 3
jokers to a player right in a row. Thank you very much.
You're welcome, thanks for you compliments. The
probability of being dealt 3 jokers in a row from a six
deck shoe (plus the 3 jokers) is 1/combin(315,3) = 1 in
5,159,805. Another solution is (3/315)*(2/314)*(1/313).
Aug. 25, 2003
If ten people are each dealt two cards from a single
deck what is the probability that two players will get a
pair of aces?
First, there are 10*9/2=45 ways you can choose 2
players out of 10. The probability of two specific
players getting four aces is 1/combin(52,4)=1/270725. So
the probability of any two players getting a pair of aces
is 45/270725=0.0001662. Aug. 7,
2003
When you open a new deck of cards they Ace to King of
each suit. What are the odds of taking a shuffled deck of
cards and reshuffeling it to the Ace to King state it was
originally in? ~Reggie
1 in 52 factorial, or 1 in
80,658,175,170,943,900,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000,000.
April 17, 2003
You'll probably also like our
answers
to questions about poker
probabilities.
©1998-2009 Wizard Of Odds Consulting, Inc. All rights reserved.
Privacy/Terms
Contact
Advertise
About Us
Links
|