# General formula for probability of drawing certain hands of cards

I have a shuffled deck of $$d$$ cards containing $$g$$ “good” cards. I'm going to draw a hand of $$h$$ cards (without replacement) and I want it to contain exactly $$w$$ good cards. (Change the variables if there's a standard notation.) What is the probability of drawing a hand with the cards I want?

I feel like I knew a general solution to this in high school, but I can't find it now. (I can find some specific solutions, like this one.)

What I've got is this:

$$\frac{\binom{g}{w} \cdot \binom{d-g}{h-w}}{\binom{d}{h}} = \frac{\frac{g!}{w! \cdot (g-w)!} \cdot \frac{(d-g)!}{(h-w)! \cdot ((d-g)-(h-w))!}}{\frac{d!}{h! \cdot (d-h)!}} = \frac{g! \cdot (d-g)! \cdot h! \cdot (d-h)!}{w! \cdot (g-w)! \cdot (h-w)! \cdot (d-g-h+w)! \cdot d!}$$

which is way more complicated than I expected, but is giving the answers I expect.
E.g.: Draw 5 cards from a standard deck and want all 4 aces:

$$\frac{\binom{4}{4} \cdot \binom{52-4}{5-4}}{\binom{52}{5}} = 0.000018$$

Am I missing something? Is there an easier way? Is there at least a simpler simplification?

In case that's the end of that question, bonus question!
If I deal a hand like this to $$p$$ players, what is the probability that one (or at least one) of them gets a qualifying hand?

• This is called the Hypergeometric Distribution. And that is as simple as it gets. – Graham Kemp Feb 14 at 23:23
• Well, at least I know what to google now. – P1h3r1e3d13 Feb 14 at 23:36

$$w$$ is the count of favored items in a sample of size $$h$$ selected without bias from a population of size $$d$$ containing $$g$$ favoured items.   The disribution for this is known as the Hypergeometric Distribution.   It does not get any easier than this.
Well, the probability for selecting $$w$$ from $$g$$ cards when drawing $$h$$ from $$d$$ cards equals the probability for putting $$w$$ of the good cards into $$h$$ special places when sorting all $$g$$ good cards among $$d$$ positions.   But that other way of viewing the task is not any simpler to evaluate.
$$\dfrac{\dbinom gw\dbinom{d-g}{h-w}}{\dbinom dh}=\dfrac{\dbinom{h}{w}\dbinom{d-h}{g-w}}{\dbinom dg}$$