Calculating Probability of Hand of n Cards from a Given Set

  • Thread starter keithsw1111
  • Start date
  • Tags
    Probability
In summary: List of desired suitsList<String> list_of_desired_suits = new ArrayList<>();// Known cardsList<Card> known_cards = new ArrayList<>();// Drawn cardsint drawn_cards = 0;// Get the probability of just one of the desired suitsfloat numerator = 1;float result = 0.0;if (count(list_of_
  • #1
keithsw1111
4
0
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

But the answer is 258/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.
 
Physics news on Phys.org
  • #2
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:
  • #3
jav said:
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! :smile:

Please don't give out full answers on this forum …

your answer would have been good if it had stopped as above.

(can you edit it?)
 
  • #4
Sorry about that tim. Done
 
  • #5
How do you calc the intersection ?
 
  • #6
Bartleby50 said:
How do you calc the intersection ?

uhh?? :confused: P(no spades n no clubs) = P(no black cards)
 
  • #7
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.


jav said:
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.
 
  • #8
keithsw1111 said:
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 can't 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)
{
numerator = 1; // start with a numerator of 1
result = 0.0; // start with a probability of 0

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
new_list.Add(s);

// 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;
}
 
  • #9
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?..pleasez replyyyyyy
 
  • #10
Welcome to PF!

Hi ceena bibi! Welcome to PF! :smile:

Please always start a new thread when asking about a new problem. :wink:

(and the forum rules forbid the use of abbreviations and slang such as "y v" and "itz")
 
  • #11
ceena bibi said:
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?..pleasez 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.
 

What is the formula for calculating the probability of a hand of n cards from a given set?

The formula for calculating the probability of a hand of n cards from a given set is: P(hand of n cards) = (number of possible hands of n cards) / (total number of possible hands).

How do you determine the number of possible hands of n cards from a given set?

The number of possible hands of n cards from a given set can be determined by using the combination formula: nCr = n! / (r!(n-r)!), where n is the total number of cards in the set and r is the number of cards in the hand.

What is the total number of possible hands from a standard deck of 52 cards?

The total number of possible hands from a standard deck of 52 cards is 2,598,960, which can be calculated using the combination formula (nCr) with n = 52 and r = 5 (for a hand of 5 cards).

How does the number of cards in the hand affect the probability of getting a specific hand from a given set?

The number of cards in the hand does not affect the probability of getting a specific hand from a given set. The probability remains the same regardless of the number of cards in the hand, as long as the total number of cards in the set remains the same.

What is the difference between theoretical probability and experimental probability?

Theoretical probability is based on mathematical calculations and assumes that all outcomes are equally likely. Experimental probability is based on actual observed outcomes and can vary from the theoretical probability due to chance or other factors.

Similar threads

  • Set Theory, Logic, Probability, Statistics
Replies
9
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
1K
  • Calculus and Beyond Homework Help
Replies
31
Views
3K
  • Set Theory, Logic, Probability, Statistics
Replies
6
Views
1K
  • Precalculus Mathematics Homework Help
Replies
2
Views
843
  • Set Theory, Logic, Probability, Statistics
Replies
7
Views
2K
  • Precalculus Mathematics Homework Help
Replies
5
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
2
Views
1K
  • Set Theory, Logic, Probability, Statistics
Replies
1
Views
2K
Back
Top