search
Search
Unlock 100+ guides
search toc
close
account_circle
Profile
exit_to_app
Sign out
What does this mean?
Why is this true?
Give me some examples!
search
keyboard_voice
close
Searching Tips
Search for a recipe:
"Creating a table in MySQL"
Search for an API documentation: "@append"
Search for code: "!dataframe"
Apply a tag filter: "#python"
Useful Shortcuts
/ to open search panel
Esc to close search panel
to navigate between search results
d to clear all current filters
Enter to expand content preview
Doc Search
Code Search Beta
SORRY NOTHING FOUND!
mic
Start speaking...
Voice search is only supported in Safari and Chrome.
Shrink
Navigate to
casino
Prob and Stats
38 guides
keyboard_arrow_down
check_circle
Mark as learned
thumb_up
1
thumb_down
0
chat_bubble_outline
0
Comment
auto_stories Bi-column layout
settings

# Comprehensive Guide on Hypergeometric Distribution

schedule Aug 11, 2023
Last updated
local_offer
Probability and Statistics
Tags
mode_heat
Master the mathematics behind data science with 100+ top-tier guides
Start your free 7-days trial now!

Let's go through a motivating example to derive the hypergeometric distribution!

# Motivating example

Suppose we draw $3$ balls from a bag containing $5$ red balls and $4$ green balls without replacement. What is the probability of drawing $2$ green balls?

Since we are drawing without replacement, the probability of drawing a green ball changes after each draw. Because the draws are not independent, we cannot use the binomial distribution here.

We can instead approach this problem using the idea of combinations. The probability of drawing $2$ green balls is:

$$$$\label{eq:zZfkFhwdzVg3yttG45N} \mathbb{P}(2{\color{green}\text{ green}}\text{ balls out of 3 balls})= \frac{\text{Number of outcomes with 2}{\color{green}\text{ green }}\text{balls}} {\text{Total possible outcomes of drawing 3 balls}}$$$$

Let's focus on the numerator first. Since we are drawing $3$ balls, drawing $2$ green balls means that the other ball we draw must be red. The number of ways of drawing $2$ green balls from $4$ green balls is:

$$4\choose{2}$$

The reason we use combinations here is to avoid double counting. For instance, if we label the $4$ green balls as $\{G_1, G_2, G_3,G_4\}$, then the pairs of green balls $\{G_1,G_2\}$ and $\{G_2,G_1\}$ should be treated as the same pair.

The number of ways of drawing $2$ red balls from $5$ red balls is:

$$5\choose{1}$$

Therefore, the number of outcomes with $2$ green balls and $1$ red ball is the product:

$$$$\label{eq:DFD8IJMAzjaHX3FiZOB} {4\choose{2}}{5\choose{1}}$$$$

Now, let's focus on the denominator of \eqref{eq:zZfkFhwdzVg3yttG45N}. The total possible outcomes of drawing $3$ balls from $9$ balls are:

$$$$\label{eq:BXb3bOoPAURpRj7tx4y} 9\choose{3}$$$$

Here, we use combinations again instead of permutations because we don't want to double-count, that is, $\color{green}\mathrm{G} \color{green}\mathrm{G} \color{red}\mathrm{R}$ is the same as $\color{green}\mathrm{G} \color{red}\mathrm{R} \color{green}\mathrm{G}$.

Substituting \eqref{eq:DFD8IJMAzjaHX3FiZOB} and \eqref{eq:BXb3bOoPAURpRj7tx4y} into \eqref{eq:zZfkFhwdzVg3yttG45N} gives:

$$$$\label{eq:nJVLT02keJzQSeO8TGH} \mathbb{P}(2{\color{green}\text{ green}}\text{ balls out of 3 balls})= \frac{\dbinom{4}{2}\dbinom{5}{1}} {\dbinom{9}{3}}= \frac{6\cdot{5}}{84}\approx0.36$$$$

Let's now generalize the fraction containing the three combinations in \eqref{eq:nJVLT02keJzQSeO8TGH}. Recall that \eqref{eq:nJVLT02keJzQSeO8TGH} answers the following specific question:

• we draw $3$ balls from a bag containing $5$ red balls and $4$ green balls without replacement. What is the probability of drawing $2$ green balls?

We only care whether a ball is green or not, so the color red is irrelevant. Therefore, without losing any information, we can rephrase this question as:

• we draw without replacement $3$ balls from a bag containing $9$ balls, of which $4$ are green. What is the probability of drawing $2$ green balls?

Again, the answer to this question is still \eqref{eq:nJVLT02keJzQSeO8TGH}. Now, let's replace all these numbers with variables:

• we draw without replacement $n$ balls from a bag containing $N$ balls, of which $m$ are green. What is the probability of drawing $x$ green balls?

The answer to this question is:

$$\mathbb{P}(X=x)=\frac{\dbinom{m}{x}\dbinom{N-m}{n-x}}{\dbinom{N}{n}}, \;\;\;\;\;\;\; \text{for }\;x=0,1,2,...,n$$

What we have just derived is the probability mass function of the so-called hypergeometric random variable! Compared to other special discrete probability distributions, the hypergeometric distribution has the most parameters $(N,m,n)$. Let's now take a moment to understand the relationship between the parameters and the input $x$, specifically what values they are allowed to take.

Instead of discussing in abstract terms, let's go back to our example once more:

• we draw without replacement $n$ balls from a bag containing $N$ balls, of which $m$ are green. What is the probability of drawing $x$ green balls?

Clearly, the possible values that $x$ can take are $0,1,2...,n$ because the sample size is $n$. Since there are only $m$ green balls in the bag, $x$ can never be greater than $m$, that is, $x\le{m}$. Moreover, the number of non-green balls in the bag $N-m$ must not be greater than the number of non-green balls in our sample $n-x$, that is, $N-m\le{n-x}$.

Definition.

# Hypergeometric distribution

A random variable $X$ is said to have a hypergeometric probability distribution with parameters $(N,m,n)$ if and only if $X$ has the following probability mass function:

$$p(x)=\frac{\dbinom{m}{x}\dbinom{N-m}{n-x}}{\dbinom{N}{n}}$$

Where:

• $x$ is an integer $0, 1, 2, \cdots, n$.

• $x\le{m}$ and $n-x\ge{N-m}$.

If $X$ follows a hypergeometric distribution with parameters $(N,m,n)$, then we can write $X\sim\text{HypG eom}(N,m,n)$.

Example.

## Finding the number of males in a group

Suppose we wanted to form a group by selecting $3$ out of $10$ people of which $4$ are male and $6$ are female. What is the probability that we have $2$ males in the formed group?

Solution. The key here is to notice that we are sampling without replacement, that is, we cannot select the same person twice. If we let random variable $X$ represent the number of males in our group, then $X$ follows a hypergeometric distribution with parameters $N=10$, $m=4$ and $n=3$. This means that the probability mass function of $X$ is:

$$$$\label{eq:vwTQCr5dqSWjIfMi1w1} p(x)=\frac{\dbinom{4}{x}\dbinom{10-4}{3-x}}{\dbinom{10}{3}}, \;\;\;\;\;\;\;\; \text{for }\;x=1,2,\cdots,n$$$$

The probability that we have $x=2$ males in the formed group is:

\begin{align*} p(2) &=\frac{\binom{4}{2}\binom{10-4}{3-2}}{\binom{10}{3}}\\ &=\frac{\binom{4}{2}\binom{6}{1}}{\binom{10}{3}}\\ &=\frac{\frac{4!}{(4-2)!2!}\frac{6!}{(6-1)!1!}}{\frac{10!}{(10-3)!3!}}\\ &=\frac{(6)(6)}{120}\\ &=\frac{3}{10}\\ &=0.3 \end{align*}

The hypergeometric probability mass function \eqref{eq:vwTQCr5dqSWjIfMi1w1} looks as follows:

Indeed, we can see that the probability of $X=2$ is $0.3$.

# Properties of hypergeometric distribution

Theorem.

## Expected value of hypergeometric random variable

If $X$ is a hypergeometric random variable with parameters $(N,m,n)$, then the expected value or the mean of $X$ is:

$$\mathbb{E}(X)=\frac{mn}{N}$$

Proof. Let's first derive a useful identity that we will use later:

\begin{align*} x\binom{m}{x} &=x\cdot\frac{m!}{x!\cdot(m-x)!}\\ &=\frac{m!}{(x-1)!\cdot(m-x)!}\\ &=\frac{m(m-1)!}{(x-1)!\cdot(m-x-1+1)!}\\ &=m\cdot\frac{(m-1)!}{(x-1)!\cdot\big[(m-1)-(x-1)\big]!}\\ &=m\binom{m-1}{x-1} \end{align*}

Let's now derive $\mathbb{E}(X)$. By definitionlink of expected value, we have that:

\begin{align*} \mathbb{E}(X) &=\sum_{x}x\cdot{\frac{\binom{m}{x}\binom{N-m}{n-x}}{\binom{N}{n}}}\\ &=\sum_{x}{\frac{x\binom{m}{x}\binom{N-m}{n-x}}{\binom{N}{n}}}\\ &=\sum_{x}{\frac{m\binom{m-1}{x-1}\binom{N-m}{n-x}}{\binom{N}{n}}}\\ &=\sum_{x}{\frac{m\binom{m-1}{x-1}\binom{(N-1)-(m-1)}{(n-1)-(x-1)}}{\frac{1}{n}\cdot{n\binom{N}{n}}}}\\ &=\sum_{x}{\frac{m\binom{m-1}{x-1}\binom{(N-1)-(m-1)}{(n-1)-(x-1)}}{\frac{1}{n}\cdot{N\binom{N-1}{n-1}}}}\\ &=\frac{mn}{N}\sum_{x}{\frac{\binom{m-1}{x-1}\binom{(N-1)-(m-1)}{(n-1)-(x-1)}}{\binom{N-1}{n-1}}} \end{align*}

Now, notice that the term in the summation is the probability mass function of the hypergeometric distribution with parameters $N-1$, $m-1$ and $n-1$. By definition of probability mass functions, the sum of probabilities across all possible values of $X$ should equal one, which means:

$$\mathbb{E}(X)=\frac{mn}{N}$$

This completes the proof.

Theorem.

## Variance of hypergeometric random variable

If $X$ is a hypergeometric random variable with parameters $(N,m,n)$, then the variance of $X$ is:

$$\mathbb{V}(X) =n\Big(\frac{m}{N}\Big) \Big(\frac{N-m}{N}\Big) \Big(\frac{N-n}{N-1}\Big)$$

Proof. To derive the variance, let's first prove another useful identity. Suppose we draw $n$ balls from a bag containing $N$ balls, of which $m$ are red. Let random variable $X$ denote the number of red balls drawn. The identity we want to prove is:

$$\mathbb{E}\Big[\binom{X}2\Big] = \binom{n}{2} \frac{\binom{m}{2}}{\binom{N}{2}}$$

Firstly, the number of pairs of red balls drawn is:

$$\text{Number of }{\color{red}\text{red}}\text{ ball pairs drawn}=\binom{X}{2}$$

The expected number of red ball pairs drawn is therefore:

$$$$\label{eq:PegLhsaiqreqf23VjUs} \mathbb{E}(\text{# of }{\color{red}\text{red }} \text{ball pairs drawn}) =\mathbb{E}\Big[\binom{X}2\Big]$$$$

Another equivalent expression for the expected number of red ball pairs is:

$$$$\label{eq:OUlUMJOScf9fPm3VZTe} \mathbb{E}(\text{# of }{\color{red}\text{red}}\text{ ball pairs drawn}) =\text{# of ball pairs drawn}\cdot \frac{\text{# of }{\color{red}\text{red}}\text{ ball pairs}}{\text{Total # of pairs in the bag}}$$$$

This might look complicated, so let's slightly rephrase it by ignoring the word "pairs" like so:

$$$$\label{eq:JtFedLwopARRCNG0T1x} \mathbb{E}(\text{# of }{\color{red}\text{red}}\text{ balls drawn}) =\text{# of balls drawn}\cdot \frac{\text{# of }{\color{red}\text{red}}\text{ balls}}{\text{Total # of balls in the bag}}$$$$

The fraction on the right represents the proportion of the red balls in the bag. If we drew $n$ balls, then we should expect the number of red balls drawn to be $n$ times this proportion. For instance, suppose there were $100$ balls in the bag, of which $50$ are red. If we draw $10$ balls, we should expect $10\times(50/100)=5$ balls to be red.

Now, instead of single balls, we focus on pairs of balls. The same idea must hold for pairs of balls - this is why \eqref{eq:OUlUMJOScf9fPm3VZTe} is true. Our goal now is to find the three terms in \eqref{eq:JtFedLwopARRCNG0T1x}.

The number of pairs in $n$ drawn balls is:

$$$$\label{eq:eEMnoTJTToZDRHgUuur} \text{Number of ball pairs in our sample}=\binom{n}{2}$$$$

The proportion of red balls can be calculated as:

$$$$\label{eq:wo8vkktEEZFTtJ4yjEt} \frac{\text{Number of }{\color{red}\text{red}}\text{ ball pairs}}{\text{Total number of pairs in the bag}} = \frac{\binom{m}{2}}{\binom{N}{2}}$$$$

Substituting \eqref{eq:eEMnoTJTToZDRHgUuur} and \eqref{eq:wo8vkktEEZFTtJ4yjEt} into \eqref{eq:OUlUMJOScf9fPm3VZTe} gives:

$$$$\label{eq:DIb4h2uqwL5HX030Mvh} \mathbb{E}(\text{# of }{\color{red}\text{red}}\text{ ball pairs drawn})= \binom{n}{2} \frac{\binom{m}{2}}{\binom{N}{2}}$$$$

Finally, equating \eqref{eq:PegLhsaiqreqf23VjUs} and \eqref{eq:DIb4h2uqwL5HX030Mvh} gives us the desired identity:

$$$$\label{eq:uvkUlb1aYOANyavpT8L} \mathbb{E}\Big[\binom{X}2\Big] = \binom{n}{2} \frac{\binom{m}{2}}{\binom{N}{2}}$$$$

Let's simplify \eqref{eq:uvkUlb1aYOANyavpT8L} to derive $\mathbb{E}[X(X-1)]$:

\label{eq:OAR7VgWFEPk3EsPK0JC} \begin{aligned}[b] \mathbb{E}\Big[\frac{X!}{2!(X-2)!}\Big] &= \frac{n!}{2!(n-2)!} \frac{\frac{m!}{2!(m-2)!}}{\frac{N!}{2!(N-2)!}}\\ \mathbb{E}\Big[\frac{X!}{(X-2)!}\Big] &= \frac{n!}{(n-2)!} \frac{\frac{m!}{(m-2)!}}{\frac{N!}{(N-2)!}}\\ \mathbb{E}\Big[X(X-1)\Big] &= (n)(n-1) \frac{m(m-1)}{N(N-1)}\\ \end{aligned}

Now, recalllink that the variance can be computed as:

$$\mathbb{V}(X)=\mathbb{E}(X^2)-\big[\mathbb{E}(X)\big]^2$$

This can also be written as:

\label{eq:FRleloliiG0A42mkRb8} \begin{aligned}[b] \mathbb{V}(X) &=\mathbb{E}(X^2-X+X)-\big[\mathbb{E}(X)\big]^2\\ &=\mathbb{E}(X^2-X)+\mathbb{E}(X)-\big[\mathbb{E}(X)\big]^2\\ &=\mathbb{E}\big[X(X-1)\big]+\mathbb{E}(X)-\big[\mathbb{E}(X)\big]^2 \end{aligned}

Substituting $\mathbb{E}\big[X(X-1)\big]$ from \eqref{eq:OAR7VgWFEPk3EsPK0JC} and $\mathbb{E}(X)$ into \eqref{eq:FRleloliiG0A42mkRb8} gives:

\begin{align*} \mathbb{V}(X)&= (n)(n-1) \frac{m(m-1)}{N(N-1)}+ \frac{mn}{N}-\frac{m^2n^2}{N^2}\\ &= \Big(\frac{m}{N}\Big) \Big(\frac{n(n-1)(m-1)}{N-1}+n-\frac{mn^2}{N}\Big)\\ &= n\Big(\frac{m}{N}\Big) \Big(\frac{(n-1)(m-1)}{N-1}+1-\frac{mn}{N}\Big)\\ &= n\Big(\frac{m}{N}\Big) \Big(\frac{N(n-1)(m-1)}{N(N-1)}+\frac{N(N-1)}{N(N-1)}-\frac{mn(N-1)}{N(N-1)}\Big)\\ &=n\Big(\frac{m}{N}\Big) \Big(\frac{Nnm-Nn-Nm+N+N^2-N-Nmn+mn}{N(N-1)}\Big)\\ &=n\Big(\frac{m}{N}\Big) \Big(\frac{-Nn-Nm+N^2+mn}{N(N-1)}\Big)\\ &=n\Big(\frac{m}{N}\Big) \Big(\frac{(N-m)(N-n)}{N(N-1)}\Big)\\ &=n\Big(\frac{m}{N}\Big) \Big(\frac{N-m}{N}\Big) \Big(\frac{N-n}{N-1}\Big)\\ \end{align*}

This completes the proof.

Theorem.

## The binomial distribution as a special case of the hypergeometric distribution

The hypergeometric distribution with parameters $(N,m,n)$ converges to a binomial distribution with parameters $(n,m/N)$ when $N$ tends to infinity.

Intuition. Recall that the key difference between the hypergeometric distribution and the binomial distribution is that the hypergeometric distribution is concerned with sampling without replacement whereas the binomial distribution deals with sampling with replacement. In other words, the trials of the hypergeometric distribution are not independent whereas the trials of the binomial distribution are.

To understand why the binomial distribution provides a good approximation to the hypergeometric distribution when parameters $N$ and $m$ are both large, consider the following question:

• Suppose we draw without replacement $2$ balls from a bag containing $1000$ balls, of which $300$ are green. What is the probability of drawing $2$ green balls?

The probability of initially drawing a green ball is:

$$\frac{300}{1000}=0.3$$

Suppose we draw a green ball first. The probability of drawing a green ball again is:

$$\frac{299}{999}\approx0.3$$

What if we had drawn a non-green ball first? The probability of drawing a green ball next is:

$$\frac{300}{999}\approx0.3$$

Notice how the probabilities are approximately the same, just as if the trials are performed with replacement! This only happens when $N$ is large and the sample size $n$ is not too large.

When $N$ is small, say $N=10$ and $m=5$, then the above probabilities would be:

$$\frac{5}{10}=0.50,\;\;\;\;\; \frac{4}{9}\approx0.44,\;\;\;\;\; \frac{5}{9}\approx0.56$$

Notice how the probabilities vary in this case, which means that there is a clear difference between sampling with and without replacement.

Moreover, the sample size $n$ should ideally be quite small for the approximation to work well. For example, suppose we have a large number of balls in the bag, say $N=1000$. If the sample size is large, say $n=999$, then the denominator of the probabilities will get smaller and smaller as we keep sampling, thereby amplifying the effects of sampling without replacement.

As a rule of thumb, if the following condition is met, then the binomial approximation performs well:

$$N\gt20n$$

The binomial approximation can sometimes be useful because the probability mass function of the binomial distribution is much easier to compute compared to that of the hypergeometric distribution.

Proof. The proof involves some tedious algebraic manipulation, so we will color-code some terms to clarify how they are being manipulated. The hypergeometric probability mass function $p_H(x)$ is:

\label{eq:T4YBAJzVJMBuTcipJKa} \begin{aligned}[b] p_H(x)&=\frac{\dbinom{m}{x}\dbinom{N-m}{n-x}}{\dbinom{N}{n}}\\ &=\frac{\color{red}m!}{{\color{red}(m-x)!}\color{green}x!} \cdot\frac{\color{blue}(N-m)!}{\color{blue}(N-m-n+x)!\color{green}(n-x)!}\cdot\frac{(N-n)!\color{green}n!}{N!}\\ &={\color{green}\frac{n!}{(n-x)!n!}}\cdot{\color{red}\frac{m!}{(m-x)!}}\cdot{\color{blue}\frac{(N-m)!}{(N-m-n+x)!}}\cdot{\frac{1}{N(N-1)\cdots{(N-n+1)}}}\\ &={\color{green}\binom{n}{x}}\cdot\frac{{\color{red}m(m-1)\cdots(m-x+1)}\cdot{\color{blue}(N-m)(N-m-1)\cdots(N-m-n+x+1)}}{N(N-1)\cdots{(N-x+1-n+x)}}\\ &={\color{green}\binom{n}{x}}\cdot\frac{{\color{red}m(m-1)\cdots(m-x+1)}\cdot{\color{blue}(N-m)(N-m-1)\cdots(N-m-n+x+1)}}{N(N-1)\cdots{(N-x+1)}\cdot{(N-x)(N-x-1)}\cdots{(N-x+1-n+x)}}\\ &={\color{green}\binom{n}{x}}\cdot\frac{{\color{red}m(m-1)\cdots(m-x+1)}}{N(N-1)\cdots{(N-x+1)}}\cdot{\frac{\color{blue}(N-m)(N-m-1)\cdots(N-m-n+x+1)}{(N-x)(N-x-1)\cdots{(N+1-n)}}}\\ \end{aligned}

Let's focus on the fraction with the red numerator:

$$\frac{{\color{red}m(m-1)\cdots(m-x+1)}}{N(N-1)\cdots{(N-x+1)}}\\$$

Let's check how many terms we are taking the product of on the numerator and the denominator. This is easy to do because each term should decrease by one, so counting the number of terms is as easy as subtracting the rightmost term (smallest) from the leftmost term (largest) and adding one. The number of terms on the numerator is:

$$m-(m-x+1)+1=x$$

The number of terms on the denominator is:

$$N-(N-x+1)+1=x$$

Therefore, the number of terms on the numerator and the denominator is the same! This means that we can express the fraction like so:

\label{eq:NVrU0WmaY15TOL2T3dQ} \begin{aligned}[b] &\;\;\;\;\;\frac{{\color{red}m(m-1)\cdots(m-x+1)}}{N(N-1)\cdots{(N-x+1)}}\\ &=\frac{{\color{red}m}}{N}\cdot \frac{\color{red}m-1}{N-1}\cdot \frac{\color{red}m-2}{N-2}\cdot\;\cdots\;\cdot \frac{\color{red}m-x+1}{N-x+1}\\ &=\frac{{\color{red}m}}{N}\cdot \Big(\frac{\color{red}m}{N-1}{\color{red}-}\frac{\color{red}1}{N-1}\Big)\cdot \Big(\frac{\color{red}m}{N-2}{\color{red}-}\frac{\color{red}2}{N-2}\Big)\cdots \Big(\frac{\color{red}m}{N-x+1}{\color{red}-}\frac{\color{red}x+1}{N-x+1}\Big) \end{aligned}

As $N$ tends to infinity, all the fractions that we subtract will be zero:

$$\lim_{N\to\infty}\frac{\color{red}1}{N-1}=0, \;\;\; \lim_{N\to\infty}\frac{\color{red}1}{N-2}=0, \;\;\;\cdots\;\;, \;\;\; \lim_{N\to\infty}\frac{\color{red}1}{N-x+1}=0$$

If we define $p=m/N$, then $p$ can be interpreted as a probability because $N$ is always equal to or greater than $m$. For instance, if we had a bag containing $N$ balls of which $m$ are green balls, then $p=m/N$ represents the probability of randomly drawing a green ball. Since $p$ is to be treated as a fixed constant (e.g. $p=0.3$) and $m=pN$, we know that $m$ must also tend to infinity as $N$ tends to infinity.

Now going back to our equation \eqref{eq:NVrU0WmaY15TOL2T3dQ}, as $N$ and $m$ both tend to infinity, all the remaining fractions will tend to $m/N$, that is:

$$\lim_{N,m\to\infty}\frac{m}{N},\;\;\; \lim_{N,m\to\infty}\frac{\color{red}m}{N-1}=\frac{m}{N},\;\;\; \cdots\;\;, \;\;\; \lim_{N,m\to\infty}\frac{\color{red}m}{N-x+1}=\frac{m}{N}$$

Therefore, \eqref{eq:NVrU0WmaY15TOL2T3dQ} becomes:

\label{eq:YC73YRSjCI63yUA92pn} \begin{aligned}[b] \lim_{N,m\to\infty}\frac{{\color{red}m(m-1)\cdots(m-x+1)}}{N(N-1)\cdots{(N-x+1)}} &=\underbrace{\Big(\frac{m}{N}\Big)\cdot\Big(\frac{m}{N}\Big)\cdots\Big(\frac{m}{N}\Big)}_{x}\\ &=\Big(\frac{m}{N}\Big)^x\\ &=p^x\\ \end{aligned}

Let's now perform the same steps on the fraction with the blue numerator in \eqref{eq:T4YBAJzVJMBuTcipJKa} shown below:

$$\frac{\color{blue}(N-m)(N-m-1)\cdots(N-m-n+x+1)}{(N-x)(N-x-1)\cdots{(N-n+1)}}\\$$

Once again, let's check how many terms we are taking the product of on the numerator and the denominator. The number of terms in the numerator is:

$$(N-m)-(N-m-n+x+1)+1=n-x$$

The number of terms in the denominator is:

$$(N-x)-(N-n+1)+1=n-x$$

Since the number of terms on the numerator and the denominator is the same, we can express the fraction as:

\begin{align*} &\;\;\;\;\frac{\color{blue}(N-m)(N-m-1)\cdots(N-m-n+x+1)}{(N-x)(N-x-1)\cdots{(N-n+1)}}\\ &=\frac{\color{blue}N-m}{N-x}\cdot\frac{\color{blue}N-m-1}{N-x-1} \cdots\frac{\color{blue}N-m-n+x+1}{N-n+1}\\ &= \frac{\color{blue}N-m}{N-x} \cdot\Big(\frac{\color{blue}N-m}{N-x-1}{\color{blue}-}\frac{\color{blue}1}{N-x-1}\Big) \cdots \Big(\frac{\color{blue}N-m}{N-n+1}{\color{blue}-}\frac{\color{blue}n-x+1}{N-n+1}\Big)\\ \end{align*}

Since $n$ and $x$ are finite, all the fractions that we are subtracting become $0$ as $N$ tends to infinity:

$$\lim_{N\to\infty}\frac{\color{blue}1}{N-x-1}=0, \;\;\; \lim_{N\to\infty}\frac{\color{blue}1}{N-x-2}=0, \;\;\;\cdots\;\;\;,\;\;\; \lim_{N\to\infty}\frac{\color{blue}n-x-1}{N-n+1}=0$$

Note that this is true only when $n$ does not tend to infinity. This is why $n$, which represents the sample size, should be small!

On the other hand, as $N$ and $m$ both tend to infinity, all the remaining fractions become:

$$\lim_{N\to\infty}\frac{\color{blue}N-m}{N-x}= \frac{N-m}{N}, \;\;\; \lim_{N\to\infty}\frac{\color{blue}N-m}{N-x-1}= \frac{N-m}{N}, \;\;\; \cdots\;\;, \;\;\; \lim_{N\to\infty} \frac{\color{blue}N-m}{N-n+1}=\frac{N-m}{N}$$

Therefore, we have that:

\label{eq:nk3iF6FRxPkkVJnPb0Z} \begin{aligned}[b] \lim_{N,m\to\infty}\frac{\color{blue}(N-m)(N-m-1)\cdots(N-m-n+x+1)}{(N-x)(N-x-1)\cdots{(N-n+1)}} &=\underbrace{\Big(\frac{N-m}{N}\Big)\cdots\Big(\frac{N-m}{N}\Big)}_{n-x}\\ &=\Big(\frac{N-m}{N}\Big)^{n-x}\\ &=\Big(1-\frac{m}{N}\Big)^{n-x}\\ &=(1-p)^{n-x} \end{aligned}

Substituting \eqref{eq:YC73YRSjCI63yUA92pn} and \eqref{eq:nk3iF6FRxPkkVJnPb0Z} into \eqref{eq:T4YBAJzVJMBuTcipJKa} gives:

$$\lim_{N,m\to\infty}p_H(x)=\binom{n}{x}p^x(1-p)^{n-x}$$

The right-hand side is the binomial probability mass function! Therefore, the binomial distribution is the limit of the hypergeometric distribution when $N$ tends to infinity. This completes the proof.

# Working with hypergeometric distribution using Python

## Computing probabilities

Recall the examplelink from earlier:

Suppose we wanted to form a group by selecting $3$ out of $10$ people of which $4$ are male and $6$ are female. What is the probability that we have $2$ males in the formed group?

If we let random variable $X$ denote the number of males in the formed group, then we have that:

$$X\sim\text{HypGeom}(N=10,m=4,n=3)$$

The probability mass function of $X$ is therefore:

$$$$\label{eq:DNnrBI0U4IuzCtLRKD6} p(x)=\frac{\dbinom{4}{x}\dbinom{10-4}{3-x}}{\dbinom{10}{3}}$$$$

The probability that we get $2$ males in the formed group is:

\begin{align*} p(2) &=\frac{\binom{4}{2}\binom{10-4}{3-2}}{\binom{10}{3}}\\ &=0.3 \end{align*}

Instead of manually calculating the probability, we can use Python's SciPy library instead:

 from scipy.stats import hypergeomx = 2N = 10m = 4n = 3hypergeom.pmf(x,N,m,n) 0.30000000000000016 

## Plotting probability mass function

To draw the hypergeometric probability mass function, use the hypergeom.pmf(~) function on a list of integers instead:

 import matplotlib.pyplot as pltfrom scipy.stats import hypergeomN = 10m = 4n = 3xs = list(range(n+1)) # [0,1,2,3]pmfs = hypergeom.pmf(xs,N,m,n)plt.bar(xs, pmfs)plt.xlabel('$x$')plt.ylabel('$p(x)$')plt.show() 

This generates the following diagram:

Edited by 0 others
thumb_up
thumb_down
Comment
Citation
Ask a question or leave a feedback...
thumb_up
1
thumb_down
0
chat_bubble_outline
0
settings
Enjoy our search
Hit / to insta-search docs and recipes!