There's $M_i$ balls of color $i=1,..,N$. $n$ balls are drawn without replacement. Find: probability that each of the colors is represented

An urn contains $M_i$ balls of color $i$ for $i = 1, 2 . . . , N$. A random sample of size $n$ is drawn from the urn without replacement. Find the probability that each of the colors is represented.

My thought were counting the wanted draws and dividing them by all possible permutations of choosing $n$ balls without replacement. Let $M=\sum_{i=1}^N M_i$ be the total amount of balls in the urn. So the probability would be: $$\frac{\prod_{i=1}^N M_i \cdot\prod_{i=1}^{n-1} M-i}{\binom{M}{n}}$$ Would you consider this solution correct? Is there a better one?

We will calculate the complimentary probability $q$ that at least one color is not represented. Let $C_i$ be the event that color $i$ is not represented in the draw. Then:

$$q=\mathbb{P}\left(\bigcup_{i=1}^NC_i\right)$$

Let $\mathcal{N}=\{1,\dots,N\}$. Using inclusion-exclusion, we can rewrite that as

$$q=\sum_{k=1}^N\left({(-1)}^{k-1}\sum_{\substack{I\subset\mathcal{N}\\|I|=k}}\mathbb{P}(C_I)\right),$$

where $C_I=\cap_{i \in I}C_i$.

Now we need only calculate the $\mathbb{P}(C_I)$; this is much easier. At the $k$-th step in the draw (there are $n$ steps), $k-1$ balls have already been drawn. The probability that, at the $k$-th step, we don't draw from one of the colors in $I$ given that we have not drawn from any of the colors in $I$ is

$$p(k,I)=\frac{\big(M-(k-1)\big)-\sum_{i\in I}M_i}{M-(k-1)}=\frac{\left(\sum_{j \in \mathcal{N}\setminus I}M_j\right)-(k-1)}{M-(k-1)}$$

It follows that

$$\mathbb{P}(C_I)=\prod_{k=1}^np(k,I)=\frac{{\left(\sum_{j \in \mathcal{N}\setminus I}M_j\right)}_n}{{(M)}_n}$$

where $(x)_k=\prod_{i=1}^{k}\big(x-(i-1)\big)$ is the falling factorial.

Plugging into the formula for $q$ above, this yields a nasty, but (seemingly) correct answer to the value of $q$, and $p=1-q$.

• You are only using $n$ and $N$ in your formula; what about the OP's variable $M$? An urn with 1 white ball and 1 black ball with two balls being chosen has a much different probability that an urn with 1 white ball and 1000 black balls with two balls being chosen. Dec 7 '16 at 1:20
• @ChasBrown Oh, you are absolutely correct. Will try and rework the answer. Dec 7 '16 at 1:43
• @ChasBrown I have edited the answer and I believe it is correct now. Dec 7 '16 at 2:16
• This looks to be correct and you were the first to post hence (+1). Dec 7 '16 at 2:44

Suppose we have $M_q$ balls of color $A_q$ where $1\le q\le N$ and $k$ balls are drawn without replacement and we ask about the probability that each color is represented. We put $M=\sum_q M_q.$

Using the same concept as in this MSE link we introduce the generating function

$$[z^k] \prod_{q=1}^N (1+zA_q)^{M_q}.$$

Now when we set a subset of the $A_q$ to zero we are left with those terms that are missing these $A_q$ and possibly additional terms. Therefore we can apply inclusion-exclusion to compute the terms where none of the $A_q$ is missing. We subtract those where one or more $A_q$ is missing, then add those where two or more are missing and so on. Finally we set the remaining $A_q$ to one to obtain the count. Putting $A=[N]$ we get

$$[z^k] \sum_{S\subseteq A} (-1)^{|S|} (1+z)^{M-\sum_{q\in S} M_q} \\ = \sum_{S\subseteq A} (-1)^{|S|} {M-\sum_{q\in S} M_q\choose k}.$$

We then get for the probability

$${M\choose k}^{-1} \sum_{S\subseteq A} (-1)^{|S|} {M-\sum_{q\in S} M_q\choose k}.$$

We have the following Maple program to verify these numbers. The total enumeration routine implements the problem before optimization -- this was done deliberately in order to adhere to the problem definition.

with(combinat);

CHOOSE :=
proc(Ml, k)
local choice, src, Mq, tp, count, res, cols;

src := []; count := 0;

for tp to nops(Ml) do
Mq := Ml[tp];

src :=
[op(src), seq([tp, q+count], q=1..Mq)];
count := count + Mq;
od;

res := [];

for choice in choose(src, k) do
cols := [seq(choice[q][1], q=1..k)];
res := [op(res), cols];
od;

res;
end;

PROB :=
proc(Ml, k)
option remember;
local choice, count, N, M;

count := 0; N := nops(Ml);

for choice in CHOOSE(Ml, k) do
if nops(convert(choice, multiset)) = N then
count := count + 1;
fi;
od;

M := add(q, q in Ml);
count/binomial(M, k);
end;

X :=
proc(Ml, k)
local res, S, N, rest, M;

N := nops(Ml); M := add(q, q in Ml);

res := 0;

for S in powerset([seq(q, q=1..N)]) do
rest := M - add(Ml[q], q in S);
res := res + (-1)^nops(S)*binomial(rest, k);
od;

res/binomial(M,k);
end;

X2 :=
proc(Ml, k)
local res, S, N, rest, M, FF;

FF := (n, q) -> mul(n-p, p=0..q-1);

N := nops(Ml); M := add(q, q in Ml);

res := 0;

for S in powerset([seq(q, q=1..N)]) do
rest := M - add(Ml[q], q in S);
res := res + (-1)^nops(S)*FF(rest, k);
od;

res/FF(M, k);
end;


Following an idea by @Fimpellizieri we can re-write the formula as

$$\frac{1}{M^{\underline{k}}} \sum_{S\subseteq A} (-1)^{|S|} \left(M-\sum_{q\in S} M_q\right)^{\underline{k}}.$$

Total number of ways to draw the balls, $$A = \binom{M}{n}$$

(Note each of the above case is equally likely - And that is very important in this question)

Now we need how many ways can we draw $n$ balls so that there is at least $1$ of each of the $N$ colors.

$b_1 + b_2 + ... + b_N = n$ where $1<=b_i<=M_i$

This can be solved trivially (Hint: it the coefficient of $x^n$). Let there be $k$ unique solutions to the above equation. Please note not all solutions are equally likely.

For each such solution a distribution can be achieved in $$\prod_{i=1}^N \binom{M_i}{b_i}$$

(Note carefully all the above are equally likely now. This is important - we need to treat the balls as different even if they are of same color)

So, total possible favorable cases is $$B = \sum_{1}^k (\prod_{i=1}^N \binom{M_i}{b_i})$$

Probability should be $$A / B$$

----- My old response -----------

@OP - Doesn't look correct. for n = N numerator should be 1. Isn't it.

I agree with ur denominator

Good question though!

• @Fimepellizieri - i still dont hv rights to post on ur ans hence posting comment here. ur ans looks wrong to me. an implcit assumption u hv made is tht all distributions r equally likely. Dec 7 '16 at 1:25
• @OP - numerator should be (Mi, bi) summed across all i. Here bi is from Fimepellizieri solution. You will have to sum across all possible solutions. Not sure if there is a closed form solution. Thanks Dec 7 '16 at 1:43