# Hypergeometric distribution- problem with derivation

A random variable $$K$$ has hypergeometric distribution with parameters $$N, m, n$$, with probability mass function: $$p_K(k)=\frac{\binom{m}{k}\binom{N-m}{n-k}}{\binom{N}{n}},\quad k\in\{\max(0,n+m-N),\ldots,\min(n,m)\}\quad,$$ $$N$$ is a population size, $$m$$ and $$N-m$$- sizes of two disjoint subsets of population (name them $$A$$ and $$B$$). The numerator indicates the number of $$n$$-element subsets, which contain $$k$$ elements choosen from $$A$$, and $$n-k$$ elements from $$B$$. I know the deriviation of this formula, however, i tried to do it in another way, and result is not correct. I would like to find out, where my reasoning fails. Suppose we firstly count a number of $$n$$-element sequences, in which we have on first $$k$$ places elements from $$A$$, and on the rest $$n-k$$ places elements of $$B$$. Then we divide this amount by a count of permutation to achieve figure of $$n$$-element subsets of population, with exactly $$k$$ elements from $$A$$ and $$n-k$$ elements of $$B$$: $$\frac{\underbrace{m\times(m-1)\times\ldots\times(m-k+1)}_{k\ elements}\underbrace{(N-m)\times(N-m-1)\times\ldots\times(N-m-(n-k)+1)}_{n-k\ elements}}{n!}\\=\frac{m!}{(m-k)!}\frac{(N-m)!}{(N-m-(n-k))!}\frac{1}{n!}=\frac{\binom{m}{k}k!\binom{N-m}{n-k}(n-k)!}{n!}\ne \binom{m}{k}\binom{N-m}{n-k}\quad.$$ What is wrong with my derivation?

Your numerator $$\frac{m!}{(m-k)!}\frac{(N-m)!}{(N-m-(n-k))!}$$ is the number of $$n$$-element sequences, in which we have on first $$k$$ places elements from $$A$$, and on the rest $$n−k$$ places elements of $$B$$. And in which the order matters, i.e. $$(a_1,a_2,a_3,b_1,b_2)$$ and $$(a_1,a_3,a_2,b_2,b_1)$$ are distinct $$k+(n-k)$$-element sequences.

You can't divide by $$n!$$ "to achieve figure of n-element subsets of population, with exactly k elements from A and n−k elements of B", because your sequence is splitted into two distinct subsequences, and you have $$k!$$ permutations in the first subsequence and $$(n-k)!$$ permutations in the second one. To count the $$n$$-element subsets with exactly $$k$$ elements from $$A$$, followed by $$(n-k)$$ elements from $$B$$, you must divide by $$k!(n-k)!$$.

A simple example. Let's say that $$n=4$$ and $$k=2$$. A single sequence may be: $$a_1,a_2,b_1,b_2$$ There are $$n!=4!=24$$ permutations, e.g. $$a_1,a_2,b_1,b_2;\quad a_2,a_1,b_1,b_2;\quad a_1,a_2,b_2,b_1\quad a_2,a_1,b_2,b_1\tag{1}$$ but also: $$b_1,a_2,b_2,a_1;\quad b_1,b_2,a_1,a_2;\quad etc.\tag{2}$$ In (2) you do not have $$k=2$$ elements of $$A$$ followed by $$n-k=2$$ elements of B, as you have in (1), and the number of permutations in (1) is just $$k!(n-k)!=2\times 2=4$$: the number of permutations of $$k$$ elements of $$A$$, multiplied by the number of permutations of the following $$n-k$$ elements of $$B$$.

When you divide by $$k!(n-k)!$$ you get the number of $$n$$-elements subsets where the order does not matter: $$\frac{m!}{(m-k)!k!}\frac{(N-m)!}{(N-m-(n-k))!(n-k)!}=\binom{m}{k}\binom{N-m}{n-k}$$

But this is still the "number of favorable cases", where $$k$$ is fixed. To get its probability you have to divide it by the "number of all cases possibile", which is $$\binom{N}{n}$$.

• Some problems with your answer, e.g., ${m\choose k}\ne m(m-1)\cdots (m-k+1)$. Jul 19, 2020 at 15:57
• Ops! I was a bit hasty :) Jul 19, 2020 at 16:19
• @DedekindCuts Thanks! Jul 19, 2020 at 17:06
• @Mentossinho Ok. I'll edit my answer. Jul 19, 2020 at 17:49
• Sorry: the amount of all kind of $n$-sequences is $N!/(N-n)!$ if the order matters. Jul 19, 2020 at 20:07