Multivariate Hypergeometric Distribution With Wildcard

In the wikipedia link http://en.wikipedia.org/wiki/Hypergeometric_distribution it is obvious you can do things like "I draw 5 cards from a deck of 50 cards where there are 10 cards that equate to success, 40 that fail, and I want to know the probability of drawing 2 success cards", but in the multivariate version at http://en.wikipedia.org/wiki/Hypergeometric_distribution#Multivariate_hypergeometric_distribution it seems you have to pick the exact amount of things you want to draw, and draw exactly that many. i.e.

I draw 10 cards from a deck with 10 red cards, 15 blue cards, and 5 blank cards, and want to draw exactly 3 blank cards, 6 red cards, and 1 blue card.

How do I use the multivariate distribution method, to allow for wildcards or unsure draws, i.e. I want to draw at least 3 blank cards given the same example above, but don't care about what else I draw?

I tried using the binomial coefficient "X choose Y" given that X is the total number of marbles/cards/whatever in the pile, and Y is the number of wildcards, but it didn't work. It gave me wildly incorrect results.

Help! D:

EDIT: Probability without replacement question The top answer seems good, and it solves one of my problems (for example now I can put a deck of cards that has three types of unique cards in it, 3 of each kind of card, pick one card and figure out the probability of drawing it if I draw 1, 2, 3, etc. cards from the deck) but now I can't pick more than one type of card that I want to draw from the deck. So... Is there a way to use the technique in section "A" in the above question's answer, to do this if I want to grab multiple different types of cards?

• Do you need an exact solution? – papirrin Sep 5 '13 at 21:59
• If you mean an exact solution to the examples I provided, not so much, I need a general technique I can use; I'm trying to build a C# calculator to do this, so the more general the approach, the better I can understand how to apply it in my code. – Codefun64 Sep 5 '13 at 22:01

Hypergeometric Probability Distribution.

1.) What is the probability of making a flush in Poker given you are holding four cards of the same suit ?

(hypergeometric 1 47 1 9) = 9/47 ~ 19.148...%

2.) what is the probability of making a flush in Poker given you are holding three cards of the same suit ?

(hypergeometric 2 47 2 10) = 45/1081 ~ 4.1628... % Similiar to your problem but not exactly so.

A Sceme program that can be modified to extend the hypergeometric probability distribution.

(define (factorial-iter-aux product counter max-count) (if (> counter max-count) product (factorial-iter-aux (* counter product) (+ counter 1) max-count)))

(define (factorial-iter n) (factorial-iter-aux 1 1 n))

(define (choose j k) (/ (factorial-iter j) (* (factorial-iter k) (factorial-iter (- j k)))))

(define (hypergeometric x N n k) (/ (* (choose k x) (choose (- N k) (- n x))) (choose N n)))

• I don't know any Scheme (or Common Lisp for that matter), so that doesn't help much; also, the problem isn't that I can't calculate single variate hypergeometric probability distributions (which the example you gave is), the problem is with multiple variables (i.e. multiple unique types of cards that the user wants to draw), I can only calculate the probabilities for drawing the exact hand the user lists - not the probability of drawing a hand that still contains all the cards the user wants. If you draw 6 cards but want a combination of 4 different cards, I don't know how to calculate that. – Codefun64 Sep 5 '13 at 22:05

Codefun, I'm honestly not sure if this is a useful idea, but you could try summing over all the possible outcomes you don't care about.

Say you only want to know "What is the probability that with 10 draws I draw at least 3 blank cards." Well, there are many ways you could do that: $3+B$ blank, $R$ red, and $U$ blue, where $B+R+U = 7$. To figure out the total probability of drawing at least 3 blank cards, not caring about what the others are, we just have to add up the probabilities for each configuration where we happen to draw 3 blank cards. I will use the notation $P(D,B,R,U)$ to denote the probability of drawing $B$ blank cards, $R$ red cards, and $U$ blue cards in $D$ draws.

I claim that the probability to draw at least $B_1$ blank cards is: $$\sum_{B=B_1}^{D}\sum_{R=0}^{D-B} P(D,\ B,\ R,\ D-B-R)$$

The nested sum can be difficult to unpack, but just remember what we are doing : summing the probabilities of all configurations that match our condition. Notice also that once we have specified the number of blank cards and the number of red cards, the number of blue cards is fixed (hence why $U = D-B-R$ in my expression).

• Sorry, but I have a silly question - what's B1? – Codefun64 Sep 5 '13 at 21:13
• Also, edited my question; using a technique from another question on math.stackexchange, I was able to -kind of- fix the problem... But it doesn't work for more than one unique type of card, i.e. more than one success/fail state, in the deck of cards I draw from. – Codefun64 Sep 5 '13 at 21:20
• @Codefun64 $B_1$ is the smallest number of blank cards that you would like to draw. So if you want to know the probability of drawing at least 6 blank cards, $B_1$ is 6. The method I gave is a framework that will work for any number of different types of cards. Just extend what I did for 3 types of cards to $N$ types. The idea is the same. To find the total probability of something happening you add up the individual probabilities of each complete configuration that has the desired property. – Kevin Driscoll Sep 5 '13 at 22:28
• @Codefun64 The same idea can be applied to drawing at least $B_1$ blank cards and $R_1$ red cards. All that changes are the limits on the sums. I apologize but I honestly don't understand what your edit is asking/asking for. – Kevin Driscoll Sep 5 '13 at 22:31
• I'm going to try and write a much more detailed and complete article for my question - your method might work, but I can't program it because if I had, say, 10 different types of cards, I'd have to have 9-10 nested sums (which are "for" loops in C# coding). I can't just generate new loops automatically to my knowledge, I have to use the same loops somehow. – Codefun64 Sep 5 '13 at 22:43