# 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 }}$$

-
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9080652594566345, "perplexity": 181.40979483916098}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2016-18/segments/1461861743914.17/warc/CC-MAIN-20160428164223-00144-ip-10-239-7-51.ec2.internal.warc.gz"}