# How to compute hypergeometric distribution probabilities for complex events?

How would I calculate the sums of two (or more) hypergeometric distributions. If, using a standard deck of cards, I want to determine the probability of draw 2 red cards and one Black Queen. I cannot just change my "good card" size and use one formula cause that wouldn't tell me what I need.

So, given 52 cards, 26 of which are red and given a draw of 4 cards, the hypergeometric probability of drawing 2 red cards is 0.32. With Black Queens, there are 2 "successes" in the population and I want to draw 1, the probability is 0.17.

In Python using Scipy I can use the hypergeom function

[M,n,N] = [52,26,5] # M=Population,n=Successes,N=drawn
rv = hypergeom(M,n,N)
pR = rv.pmf(2) # probability of two reds in a hand of 5

n1 = 2
rv = hypergeom(M,n1,N)
pBQ = rv.pmf(1) # probability of 1 Black Queen in a hand a 5


How do I then calculate the probability that out of a 5 card draw I get 2 reds and 1 black Queen?

• If you use the whole deck, eventually you're certain to draw two red cards and one black queen. Please tell us, then, exactly what experiment you are contemplating, for otherwise it will be impossible to produce a definite answer.
– whuber
Commented Jun 8, 2018 at 16:49
• And the remaining two cards need to be black non-Queens? Since this is not really a "sum", the title should be edited to something more informative Commented Jun 8, 2018 at 19:12

Since drawing more red cards implies you have drawn fewer black cards, the red card count and black queen count are not independent. That makes it difficult to combine the probabilities of each event in any simple way to obtain the answer.

Instead, do it the old-fashioned way: count every hand having two red cards, one black queen, and (presumably) two other black cards. Divide that by the count of all possible five-card hands, because each such hand has the same probability (under a fair draw, anyway).

The number of such hands is counted by taking the number of two-card subsets of all $26$ cards, written $\binom{26}{2}$, multiplying that by the number of one-card subsets of the two black queens, written $\binom{2}{1},$ and multiplying the result by the number of two-card subsets of the remaining $24$ black cards, written $\binom{24}{2}.$ This will be divided by $\binom{52}{5}$ to obtain the probability.

Applying the formula

$$\binom{n}{k} = \frac{n!}{(n-k)!k!} = \frac{n(n-1)\cdots(n-k+1)}{k(k-1)\cdots(1)}$$

$$\frac{\binom{26}{2}\binom{2}{1}\binom{24}{2}}{\binom{52}{5}} = \frac{5\times 23}{2\times 7^2 \times 17}=\frac{115}{1666}\approx 6.9\%.$$

This reasoning applies, mutatis mutandis, to any event that specifies how many elements of each non-overlapping subset of a population must appear in a sample (without replacement) of a given size.

• Quick question, in the formula, nPk, the k's in the numerator (2, 1 & 2) equal the k (5) in the denominator. If I were to use your formula to derive probabilities for other hand combinations, is it required that each formula that the sums of the k(s) are equal. Thanks Commented Jun 19, 2018 at 14:36
• @Wraith Since I don't use any terminology like "nPk," and terms like this usually do not denote the binomial coefficients in my answer, I'm unsure what you're asking. I would hope that the general formula is clear from the text description that immediately precedes it, so I refer you to that for more information.
– whuber
Commented Jun 19, 2018 at 14:47
• @whuber he's following the logic of other combinatorics, and wondering why the 'denominator' of the individual binomial expressions on the top (2+1+2) don't sum to the binomial denomination on the bottom (5). Commented Oct 24, 2018 at 23:30
• @Pureferret That is problematic for several reasons. One is that both of you seem to have confused the meanings of "numerator" (the value on top of a fraction) and "denominator." Another is that it is indeed the case that $2+1+2=5.$ Finally, the meaning of that "logic of other combinatorics" depends on what "other combinatorics" you are referring to. It seems to reflect a study of a very limited type of problem, but which type is unclear.
– whuber
Commented Oct 25, 2018 at 12:10
• I'm only trying to express what @WraithWireless was trying to get across. Don't shoot the messenger. Commented Oct 25, 2018 at 14:51