# Card probability

## Main Question or Discussion Point

I am trying to understand a general algorithm for calculating the probability of a hand of n cards drawn from a deck containing a given set of cards. Where the given set of cards is n in size it is easy. I am struggling when the number of cards specified is less than n.

To make it easier to udnerstand I am working with a deck of 12 cards. A,2 and 3 of each suit only.

For example. From my 12 card deck I draw 4 cards.

What is the probability at least 1 is a club and at least 1 is a spade.

The probability that only 1 is a club and only 1 is spade is easy 3c1*3c1*6c2 = 135/12c4

The missing 123 are CCCS (3), SSSC (3), CCSS (9), CCSx (54) and SSCx (54) where x is not a C or S.

Is there a clever formula to count these 123 or do I need to work them out individually as I have above.

Related Set Theory, Logic, Probability, Statistics News on Phys.org
jav
P(At least one spade and at least club) = 1 - P(no spades U no clubs)

= 1 - [P(no spades) + P(no clubs) - P(no spades n no clubs) :n represents an intersection]

In general if you are trying to calculate a probability that involves a large number of events, it is often simpler to evaluate the probability of the complement. Then, using the fact that the probability of the total sample space is equal to 1, the calculation of the original probability becomes equally simple.

Last edited:
tiny-tim
Homework Helper
P(At least one spade and at least club) = 1 - P(no spades U no clubs)

= 1 - [P(no spades) + P(no clubs) - P(no spades n no clubs) :n represents an intersection]
Hi jav! (can you edit it?)

jav

How do you calc the intersection ?

tiny-tim
Homework Helper
How do you calc the intersection ?
uhh?? P(no spades n no clubs) = P(no black cards)

The problem this and all other card probability answers I can find on the web have is they approach each problem as if they are unique problems to solve. In this example you took my example and turned it around to take advantage of a particular aspect of the example without addressing the more fundamental question.

I am after an algorithm not just an answer.

As it happens I have managed to work it out. It is elegant quick and reliably calculates the probability of any demand for n cards of a particular suit combinations from a deck in any state. No tricks required.

I will post some pseudocode tomorrow that shows the algorithm I came up with.

P(At least one spade and at least club) = 1 - P(no spades U no clubs)

= 1 - [P(no spades) + P(no clubs) - P(no spades n no clubs) :n represents an intersection]

In general if you are trying to calculate a probability that involves a large number of events, it is often simpler to evaluate the probability of the complement. Then, using the fact that the probability of the total sample space is equal to 1, the calculation of the original probability becomes equally simple.

I will post some pseudocode tomorrow that shows the algorithm I came up with.
The following code is psudocode is based loosely on Java/C#. It would never compile as it assumes some functions that the coder would need to supply but it should give you an idea of the algorithm

// list_of_desired_suits is an order independent list of the suits we want the drawn cards to have. For example if we want the probability 1 or more clubs then we pass in a list with 1 club. If we want the probability of 2 or more clubs then we pass in a list with 2 clubs. If we want the probability of 5 clubs in 5 drawn cards then we pass in 5 clubs in the list. If we want at least 2 clubs and at least 2 hearts then we pass in 2 clubs and 2 hearts in the list.
// known_cards is a list of cards we know cant be in the drawn cards. Typically this might be because they are already in our hand or have already been played.
// drawn_cards is the number of cards being drawn without replacement. If must be at least as large as there are cards in the list_of_desired_suits otherwise the result is 0.0 ... impossible.
Function GetProbability(list_of_desired_suits, known_cards, drawn_cards)
{

if (count(list_of_desired_suits) > drawn_cards)
{
return 0.0; // impossible
}

// reduce the desired suits to just the unique ones
list_of_unique_desired_suits = remove_duplicates(list_of_desired_suits);

// work out how many cards are in my deck but not one of the desired suits.
not_in_desired_suits = countcardsindecknotin(list_of_unique_desired_suits);

// multiply the numerator by the number of combinations of cards in each of the desired suits
foreach(suit s in list_of_unique_suits)
{
numerator = numerator * BinomialCoefficent(countcardsindeckinsuit(s), drawn);
}

// multiple the numerator by the number of combinations of cards not in any of the desired suits where the number of cards in list_of_desired_suits is less than the cards drawn.
` numerator = numerator * BinomialCoefficient(not_in_desired_suits, drawn - count(list_of_desired_suits));

// probability of exactly the number of cards of the desired suits being in the drawn cards
result = numerator / BinomialCoefficient(undealtcards, drawn);

// now we need to add in the probability that one of the unknown cards is the same suit as our desired cards
if (count(list_of_desired_suits) < drawn_cards)
{
// we need to add the probability of each of the desired suits being in the unknown cards
foreach(suit s in list_of_unique_desired_suits)
{
// create a working copy
new_list = list_of_desired_suits;

// add a demand for an extra copy of one of our desired suits

// recursively call this function to calculate the probability of this more specific desired suits list
result = result + GetProbability(new_list, known_cards, drawn_cards);
}
}

return result;
}

finf probabilty of following event:
A king,ace,queen of diamond or jack of clubs appears in drwaing a single card from a well-shuffeled deck of 52 cards.
i checked it in many guides n books ,,its solve like thz
King, 4/52+ace 4/52+queen 1/52+ jack 1/52 +10/52 so my question iz that y v have taken 4 king n 4 ace wen itz not given in question???..plzz replyyyyyy

tiny-tim
Homework Helper
Welcome to PF!

Hi ceena bibi! Welcome to PF! Please always start a new thread when asking about a new problem. (and the forum rules forbid the use of abbreviations and slang such as "y v" and "itz")

finf probabilty of following event:
A king,ace,queen of diamond or jack of clubs appears in drwaing a single card from a well-shuffeled deck of 52 cards.
i checked it in many guides n books ,,its solve like thz
King, 4/52+ace 4/52+queen 1/52+ jack 1/52 +10/52 so my question iz that y v have taken 4 king n 4 ace wen itz not given in question???..plzz replyyyyyy
The reason you take 4 kings and 4 aces is because the question does not require them to be of a particular suit. As there are 4 kings in the pack and any of them are good enough the probability of getting a king is 4/52. If you only wanted say the king of clubs then the probability would be 1/52 as there is only one king of clubs in the 52 card pack.