Calculating Odds/Probability with Overlapping Type

120 Views Asked by At

Calculating Odds/Probability with Overlapping Type

I'm making a game where cards can have 1-2 types. Think pokemon types, where a 1-type pokemon is "normal" type and a two type pokemon is "normal/flying".

I'm trying to calculate odds of achieving certain hands given specific types. Something like: what are the odds of pulling 1 normal type in a draw of 5 cards, with a deck size of 50 and 4 normal types? Is relatively easy.

Where I'm running into trouble is where the types overlap. I'm trying to calculate something like:

What are the odds of pulling 2 normal types and 2 flying types in a draw of 5 cards with a deck size of 50, given 4 normal types, 3 flying types, and 4 normal/flying types (where normal/flying can count as a draw toward EITHER, but not BOTH, in other words, 1 normal/flying = 1 normal OR 1 flying, not 1 normal AND 1 flying).

Does anyone know where I could look for formulas or calculators that take into account the above scenario? Thank you.

2

There are 2 best solutions below

3
On

I know you are looking for a more general approach but you could do a case analysis for your stated example, and then perhaps use it to solve similar ones.

There are $\binom{50}{5}$ possible hands you can have. For the specific hand you're trying to create (two normal cards, two flying cards, and a fifth card that can be anything), we can enumerate the type selections. Let "P" stand for pure, "M" for mixed, "N" for normal, and "F" for flying. We then have for the four specific cards, the following ways they can be drawn from the normal or mixed sets along with the number of ways of occurrence.

  • $\{$PN, PN, PF, PF $\}$: $\binom{4}{2} \times \binom{3}{2} = 18$

  • $\{$PN, MN, PF, PF$\}$: $\binom{4}{1} \times \binom{4}{1} \times \binom{3}{2} = 48$

  • $\{$PN, MN, PF, MF$\}$: $\binom{4}{1} \times \binom{4}{2} \times \binom{3}{1} = 72$

  • $\{$PN, PN, PF, MF$\}$: $\binom{4}{2} \times \binom{3}{1} \times \binom{4}{1} = 72$

  • $\{$PN, MN, MF, MF$\}$: $\binom{4}{1} \times \binom{4}{3} = 16$

  • $\{$PN, PN, MF, MF$\}$: $\binom{4}{2} \times \binom{4}{2} = 36$

  • $\{$MN, MN, PF, PF$\}$: $\binom{4}{2} \times \binom{3}{2} = 18$

  • $\{$MN, MN, MF, PF$\}$: $\binom{4}{3} \times \binom{3}{1} = 12$

  • $\{$MN, MN, MF, MF$\}$: $\binom{4}{4} = 1$

After choosing four cards we have 46 cards to choose from for our final card. Thus the probability of getting two normal cards and two flying cards in a hand with five cards (given the type breakdown you gave) is \begin{align} \text{Prob} & = \frac{1}{\binom{50}{5}}\left[\cdots \text{sum of terms}\cdots\right]\times 46\\ & = \frac{293}{46 060} \simeq 0.0064. \end{align}

0
On

I believe motherboard's answer to contain a slight error. They list 5 possible types of compliant hands, but they should list 9, since there are 3 ways each type can be satisfied (with 0, 1, or 2 pure cards).

I reckon the following categories and quantities (following motherboard's notation):

  • $\{PN,PN,PF,PF\}: {4 \text{ PN } \choose 2} \times {3 \text{ PF } \choose 2} \times {4 \text{ M } \choose 0} = 18$
  • $\{PN,PN,PF,MF\}: {4 \text{ PN } \choose 2} \times {3 \text{ PF } \choose 1} \times {4 \text{ M } \choose 1} = 72$
  • $\{PN,PN,MF,MF\}: {4 \text{ PN } \choose 2} \times {3 \text{ PF } \choose 0} \times {4 \text{ M } \choose 2} = 36$
  • $\{PN,MN,PF,PF\}: {4 \text{ PN } \choose 1} \times {3 \text{ PF } \choose 2} \times {4 \text{ M } \choose 1} = 48$
  • $\{PN,MN,PF,MF\}: {4 \text{ PN } \choose 1} \times {3 \text{ PF } \choose 1} \times {4 \text{ M } \choose 2} = 72$
  • $\{PN,MN,MF,MF\}: {4 \text{ PN } \choose 1} \times {3 \text{ PF } \choose 0} \times {4 \text{ M } \choose 3} = 16$
  • $\{MN,MN,PF,PF\}: {4 \text{ PN } \choose 0} \times {3 \text{ PF } \choose 2} \times {4 \text{ M } \choose 2} = 18$
  • $\{MN,MN,PF,MF\}: {4 \text{ PN } \choose 0} \times {3 \text{ PF } \choose 1} \times {4 \text{ M } \choose 3} = 12$
  • $\{MN,MN,MF,MF\}: {4 \text{ PN } \choose 0} \times {3 \text{ PF } \choose 0} \times {4 \text{ M } \choose 4} = 1$

This would yield a total of 293 possible 4-card combinations which satisify the (2 normal, 2 flying) constraint and a resultant probability that a randomly selected, 5-card hand will have at least 2 normal and at least two flying of $$\frac{293\times 46}{{50 \choose 5}}=\frac{293}{46060}\simeq0.0064.$$

For exactly 2 normal and exactly 2 flying, you would need to multiply by 39 instead of 46 (thus excluding the extra normal and flying cards from the fifth slot). This would yield a probability of $$\frac{293\times 39}{{50 \choose 5}}=\frac{11427}{2118760}\simeq0.0054.$$

In general, when you are looking to determine how many ways a set of $n$ elements can be partitioned into $k$ groups of $n_k$ size, here is the formula: $$P_{n_{1},...,n_{k}}=\frac{n!}{(\Pi_{i=1}^k n_i!)(n-\Sigma_{i=1}^k n_i)!}$$

Further reading here.