# Combinatorics problem: probability density function for picking up element experiment

Suppose to have $n$ elements of $2$ different types. Let $n_1$ and $n_2$ be the numbers of elements of each type respectively (with $n=n_1+n_2$).

I have to pick $k$ elements from this set. Every time I pick an element, I will not put it back to the original set.

What it is the probability that $h$ of the $k$ picked elements are of type "1"? I would like to evaluate the probability density function $p_{k, n_1, n_2}(h)$ which is the probability that I have picked exactly $h$ element in the case that parameters $k$, $n_1$ and $n_2$ are fixed.

I started by enumerating all the possibilities but that's a dirty job. I was wondering if there is a formula for this kind of problem.

-
I googled around a little bit more and I found that the hypergeometric distribution is the thing I was looking for! – the_candyman Feb 2 '13 at 12:15

$$p=\frac{k!}{h!(k-h)!}*\frac{(n_1+n_2-k)!}{(n_1-h)!(n_2-k+h)!}*\frac{n_2!n_1!}{(n_1+n_2)!}$$

see if this works for you. note that is breaks down if $k>h+n_2$ but that makes sense

$\frac{k!}{h!(k-h)!}$ is the number of ways to organize the first k such that there are h from category 1

$\frac{(n_1+n_2-k)!}{(n_1-h)!(n_2-k+h)!}$ is the number of ways to organize the last $n-k$ such that there are $n1-h$ from category 1

multiplying the two parts together yields the number of arrangements such that there are h from n1 in the first k portions and n1 from category 1 and n2 from category 2 in the entire arrangement

The last part is dividing the number of these arrangments by the total number of possible arrangements of n1 from 1 and n2 from 2.

All of these parts take advantage of the fact that $\frac{a!}{b!(a-b)!} = {n \choose k }$ which is the number of ways to arrange b objects of category 1 and (a-b) objects from category 2 in a line. See http://en.wikipedia.org/wiki/Binomial_coefficient

using the latter answer's notation my equation is: $$p=\frac{{k \choose h}*{n-k \choose n_1-h}}{n \choose n_1}$$

-
thank you for the answer! I tried it for the case $h=0$ and it works. Can you explain how I you build up this formula? – the_candyman Feb 1 '13 at 16:59
It is a simular methodology to the answer that came after mine. I will edit and explanation into the answer. – kaine Feb 1 '13 at 18:09

The total number of possible extractions (counting the elements as distinguishable) is $${n \choose k }$$ The total number of successful extractions is $${n_1 \choose h } {n_2 \choose k-h }$$

Hence the desired probability is

$$\displaystyle P(h) = \frac{\displaystyle {n_1 \choose h } {n_2 \choose k-h }}{\displaystyle {n \choose k }}$$

-