# Urn with balls of two colours with a priori probability of each ball

If we have a urn with $N$ balls of two colours ($D$ red and $N-D$ black balls respectively), then probability of having $k$ red out of $n$ balls drawn at once without replacement follows the Hypergeometric distribution:

$Pr(X = k) = \dfrac{\binom{D}{k} \binom{N - D}{n-k}}{\binom{N}{n}}$

Now assume we have some a priori distribution of the balls: $p_i$ – probability of drawing ball $i$, $i \in \{1, \ldots, N \}$. (Note that it's unrelated to colours.)

Let's make an experiment with drawing balls again. As a result of the experiment we have the following:

$P_n = \{p_{i_1}, \ldots, p_{i_n}\}$ – probabilities of $n$ drawn balls

$P_k = \{p_{j_1}, \ldots, p_{j_k}\}$ – probabilities of $k$ red drawn balls, $P_k \subset P_n$

Let $\mathrm{Pr}(P_k \mid P_n)$ probability of having this result, i.e. having $k$ balls out of $n$ drawn balls which probabilities turned out to be exactly $P_k$ and $P_n$ respectively.

Exact form of $\mathrm{Pr}(P_k \mid P_n)$ can be written basing on probability of drawing $m$ balls with certain probabilities out of urn with $M$ balls:

$$\mathrm{Pr}(\text{pull k balls with certain probabilities out of M balls}) = \frac{\prod_{i \in \text{drawn}} p_i \times \prod_{i \notin \text{drawn}} (1 - p_i)}{\sum_{\text{all subsets S of size m from M}} \prod_{i \in S} p_i \times \prod_{i \notin S} (1 - p_i)}$$

But this formula will have exponential computation time, so it doesn't fit the problem with settings (more likely settings we will work with):

$$N \sim 6000, D \sim 1000, n \sim 2000$$

Since that, we're interesting in finding such function $f$, that:

$$\mathrm{Pr}(P_{k_1} \mid P_{n_1}) > \mathrm{Pr}(P_{k_2} \mid P_{n_2}) \Rightarrow f(\mathbf{k_1}, \mathbf{n_1}) > f(\mathbf{k_2}, \mathbf{n_2})$$

and vice versa, where $\mathbf{k_i}, \mathbf{n_i}$ – corresponding sets of balls.

In other words, we're trying to reduce that scaring formula to other (more simple) remaining this «comparator» property. Note that absolute value doesn't matter: comparing only is required.

Do you have any idea of how to reach our goal? Appreciate any thoughts about the solution.

• Please tell us what you intend to happen to the probabilities after some balls are withdrawn. After all, if you remove $k$ balls sequentially, then after the first ball is removed the remaining probabilities no longer sum to unity. Exactly how, then, are we to determine the chances for each of the $n-1$ remaining balls? If you don't remove the $k$ balls sequentially but take them out as a group, how are we supposed to determine the chances of each of the $\binom{n}{k}$ distinct possible groups? – whuber Feb 5 '16 at 19:41
• We draw balls at once. Thanks for the notice, I'll fix the statement. If we draw $n$ balls out of $N$ having some probabilities on balls, then probability of certain set of $n$ drawn balls is: $$\frac{\prod_{i \in \text{drawn}} p_i \times \prod_{i \notin \text{drawn}} (1 - p_i)}{\sum_{\text{all subsets S of size n from N}} \prod_{i \in S} p_i \times \prod_{i \notin S} (1 - p_i)}$$ – Ivan Arbuzov Feb 5 '16 at 20:24
• And that, more or less, is the full answer to your question: you just have to sum those probabilities over all subsets corresponding to any event of interest (such as having exactly $D$ red balls). Except in extreme cases (such as samples of $1$ or $N$) the sum doesn't simplify. – whuber Feb 5 '16 at 21:04
• Okay, I understand it. But finally we don't need exact probability. Instead, we need just to compare results by their significance (or by proportional value). So maybe it's possible to reduce the problem to something else saving comparator property? Like to find function $f$ of set of balls, such that $$Pr(\mathbf{S_1}) > Pr(\mathbf{S_2}) \Rightarrow f(\mathbf{S_1}) > f(\mathbf{S_2})$$ and vice versa. – Ivan Arbuzov Feb 5 '16 at 21:36
• This is getting hard to follow, because you haven't described a setting in which statistical significance has any meaning: so far, you're only asking about computing probabilities. There's no null hypothesis in evidence, for instance. If you are seeking approximations of these probabilities, it will be important to describe the likely sizes of $n$, $k$, $N$, and $D$, as well as the distributions of the $p_i$, because those things determine which approximation methods will work best. – whuber Feb 5 '16 at 21:39