I use the following terms to define the different events:
- A = draw at least 1 ace
- B = draw at least 1 king
- C = draw at least 1 queen
I use the following expression to define the problem:
- P(A∩B∩C) = P(A)P(B|A)P(C|A∩B)
Using Google spreadsheet's HYPGEOMDIST formula:
- HYPGEOMDIST(num_successes, num_draws, successes_in_pop, pop_size)
I represent the expression above with the following HYPGEOMDIST formulas:
- P(A) = 1 - HYPGEOMDIST(0, 5, 4, 52) ≈ 34.1%
- P(B|A) = 1 - HYPGEOMDIST(0, 4, 4, 51) ≈ 28.6%
- P(C|A&B) = 1 - HYPGEOMDIST(0, 3, 4, 50) ≈ 22.6%
P(A∩B∩C) = P(A)P(B|A)P(C|A∩B) ≈ 2.2%
I'm using https://deckulator.appspot.com/ to double check my output and it uses a multivariate hypergeometric approach for this problem. This is the website output for the presented scenario: Deck-u-lator Output.
I believe my mistake should be in the P(B|A) or P(C|A&B) terms but I'm not sure what it might be. Can anybody help me with this?
My goal is to eventually be able to apply the formula to a deck of cards with a variable number of cards. E.g. Instead of 4 of each card, a deck might have 5 Aces, 3 Kings, 2 Queens, etc. and I could just change the numbers in the HYPGEOMDIST formula to get the desired probability.
You seek the probability for drawing at least one ace, at least one king, and at least one queen when selecting five cards from fifty-two in a standard deck.
Your error is that $\mathsf P(B\mid A)$ is not $1-\operatorname{HYPERGEODIST}(0,4,4,51)$ . You need to use the principle of inclusion and exclusion, along with the definition for conditional probability.
$\mathsf P(B\mid A)=\dfrac{\mathsf P(A,B)}{\mathsf P(A)}=\dfrac{1-2\,HGD(0,5,4,52)+HGD(0,5,8,52)}{1-HGD(0,5,4,52)}$
And similarly for $P(C\mid B,A)$, but this is more effort than it is worth. Notice that when multiplying out each denominator will be the numerator of the previous term, and thus cancel much of the work. So you just need the last numerator.
It will be much less hassle to calculate $\mathsf P(A,B,C)$ directly.
Rather, let us use $A,K,Q$ to be the count for aces, kings, and queens, and use the principle of Inclusion and Exclusion.
$${\mathsf P(A{>}0,B{>}0,C{>}0)=}~{1{-~\mathsf P(A{=}0)-\mathsf P(K{=}0)-\mathsf P(Q{=}0)}\\{+~\mathsf P(A{=}0,K{=}0)+\mathsf P(A{=}0,Q{=}0)+\mathsf P(K{=}0,Q{=}0)}\\{-~\mathsf P(A{=}0,K{=}0,Q{=}0)}}$$
Where: $~~~~\mathsf P(A{=}0)~{=\mathsf P(K{=}0)\\=\mathsf P(Q{=}0)\\=\left.\tbinom 40\tbinom{52-4}5\middle/\tbinom{52}{5}\right.\\=\operatorname{HYPERGEOMDIST}(0,5,4,52)}$
Similarly: $\mathsf P(A{=}0,K{=}0)~{=\mathsf P(A{=}0,Q{=}0)\\=\mathsf P(K{=}0,Q{=}0)\\=\left.\tbinom 80\tbinom{52-8}5\middle/\tbinom{52}{5}\right.\\=\operatorname{HYPERGEOMDIST}(0,5,8,52)}$
Finally: $~~~~\mathsf P(A{=}0,K{=}0,Q{=}0)~{=\left.\tbinom{12}{0}\tbinom{52-12}{5}\middle/\tbinom{52}{5}\right.\\=\operatorname{HYPERGEOMDIST}(0,5,12,52)}$