# Hypergeometric Probability Calculator

An online calculator to calculate the hypergeometric probability distribution and the probabilities of "at least" and "at most" associated to the hypergeometric probabilities, is presented.

## Hypergeometric Probabilities

If in a population of size $N$ there are $R$ successes and if $n$ items are randomly selected from $N$, then the probability that there are $x$ succese among the $n$ selected is given by:
$P(X = x) = \dfrac{ \displaystyle {R \choose x} \displaystyle {N - R \choose n - x} }{ \displaystyle {N \choose n} }$
The calculator below calculates the hypergeometric probability distribution $P(X = x)$ from different values of $x$. The calculator below helps in investigating the hypergeometric probabilities without wasting too much time in the computations.
This calculator also calculates the probability of "at least" $x$ given by $P(X \ge x)$ and "at most" $x$ given by $P(X \le x)$ related to hypergeometric probabilities.

A working example is solved manually below and then the values used in this example are the default values (when you first open this page) used in the calculator below to check the answers.
Working Example
There are 12 balls in a box with 7 of which are red and the remaining ones are black. Five balls are selected at random from the box.
a) What is the the probability that 3 of the 5 balls selected are red?
b) What is the the probability that at least 3 of the 5 balls selected are red?
c) What is the the probability that 3 at most of the 5 balls selected are red?

Solution to Example
a) Given Total population has size: $N = 12$ , we may consider a red ball as a success, hence $R = 7$ and the number of selected balls from the whole population is: $n = 5$
$P(X = 3) = \dfrac{ \displaystyle {7 \choose 3} \displaystyle {12 - 7 \choose 5 - 3} }{ \displaystyle {12 \choose 5} }$

$= \dfrac{ \displaystyle {7 \choose 3} \displaystyle {5 \choose 2} }{ \displaystyle {12 \choose 5} } = 175 /396 \approx 0.4419$

b)
At least 3 red means $x$ is either $3, 4,\; \text{or} \; 5$ or $x \ge 3$
$P(\text{at least 3}) = P(X \ge 3) = P( X = 3 \; or \; X = 4 \; or \; X = 5 )$
$P(X \ge 3) = P(X = 3) + P(X = 4) + P(X = 5 )$
Using the hypergeometric formula, the above probability may be written as
$= \dfrac{ {7 \choose 3} {12 - 7 \choose 5 - 3} }{ {12 \choose 5} } + \dfrac{ {7 \choose 4} {12 - 7 \choose 5 - 4} }{ {12 \choose 5} } + \dfrac{ {7 \choose 5} {12 - 7 \choose 5 - 5} }{ {12 \choose 5} }$

$= \dfrac{ {7 \choose 3} {5 \choose 2} }{ {12 \choose 5} } + \dfrac{ {7 \choose 4} {5 \choose 1} }{ {12 \choose 5} } + \dfrac{ {7 \choose 5} {5 \choose 0} }{ {12 \choose 5} } = 91/132 \approx 0.6894$

c)
At most 3 red means $x$ is either $0, 1, 2 \; \text{or} \; 3$ or $x \le 3$
$P(\text{at most 3}) = P(X \le 3) = P( X = 0 \; or \; X = 1 \; or \; X = 2 \; or \; X = 3 )$
$P(X \le 3) = P(X = 0) + P(X = 1) + P(X = 2 ) + P(X = 3 ) =$
Using the hypergeometric formula, the above probability may be written as
$= \dfrac{ {7 \choose 0} {12 - 7 \choose 5 - 0} }{ {12 \choose 5} } + \dfrac{ {7 \choose 1} {12 - 7 \choose 5 - 1} }{ {12 \choose 5} } + \dfrac{ {7 \choose 2} {12 - 7 \choose 5 - 2} }{ {12 \choose 5} } + \dfrac{ {7 \choose 3} {12 - 7 \choose 5-3} }{ {12 \choose 5} }$

$= \dfrac{ {7 \choose 0} {5 \choose 5} }{ {12 \choose 5} } + \dfrac{ {7 \choose 1} {5 \choose 4} }{ {12 \choose 5} } + \dfrac{ {7 \choose 2} {5 \choose 3} }{ {12 \choose 5} } + \dfrac{ {7 \choose 3} {5 \choose 2} }{ {12 \choose 5} } = 149/198 \approx 0.7525$

## How to use the calculator

1 - Enter the size of the popualtion $N$ , and the total number of successes $R$ within the population. Enter the size $n$ of the sample selected from the population and the number of successes $x$ and press "Calculate".
$N$, $R$ and $n$ are positive integers and $x$ is a non negative integer.
$0 \le x \le n$ ,   $R \lt N$ ,   $N-R \ge n - x$

 Population size $N$ = 12 Total number of successes $R$ = 7 Total Number of Selected items $n$ = 5 $x$ = 3 $P(X = x)$ = $P(X \le x)$ = (at most) $P(X \ge x)$ = (at least)

More on statistics tutorials.