Hypergeometric distribution
From Wikipedia, the free encyclopedia
Probability mass function |
|
Cumulative distribution function |
|
Parameters | |
---|---|
Support | |
Probability mass function (pmf) | |
Cumulative distribution function (cdf) | |
Mean | |
Median | |
Mode | |
Variance | |
Skewness | |
Excess kurtosis |
|
Entropy | |
Moment-generating function (mgf) | |
Characteristic function |
In probability theory and statistics, the hypergeometric distribution is a discrete probability distribution that describes the number of successes in a sequence of n draws from a finite population without replacement.
drawn | not drawn | total | |
---|---|---|---|
defective | k | D − k | D |
nondefective | n − k | N + k − n − D | N − D |
total | n | N − n | N |
A typical example is illustrated by the contingency table above: there is a shipment of N objects in which D are defective. The hypergeometric distribution describes the probability that in a sample of n distinctive objects drawn from the shipment exactly k objects are defective.
In general, if a random variable X follows the hypergeometric distribution with parameters N, D and n, then the probability of getting exactly k successes is given by
The probability is positive when k is between max{ 0, D + n − N } and min{ n, D }.
The formula can be understood as follows: There are possible samples (without replacement). There are ways to obtain k defective objects and there are ways to fill out the rest of the sample with non-defective objects.
When the population size is large compared to the sample size (i.e., N is much larger than n) the hypergeometric distribution is approximated reasonably well by a binomial distribution with parameters n (number of trials) and p = D / N (probability of success in a single trial).
The fact that the sum of the probabilities, as k runs through the range of possible values, is equal to 1, is essentially Vandermonde's identity from combinatorics.
Contents |
[edit] Application and example
The classical application of the hypergeometric distribution is sampling without replacement. Think of an urn with two types of marbles, black ones and white ones. Define drawing a white marble as a success and drawing a black marble as a failure (analogous to the binomial distribution). If the variable N describes the number of all marbles in the urn (see contingency table above) and D describes the number of white marbles (called defective in the example above), then N − D corresponds to the number of black marbles.
Now, assume that there are 5 white and 45 black marbles in the urn. Standing next to the urn, you close your eyes and draw 10 marbles without replacement. What's the probability p (k=4) that you draw exactly 4 white marbles (and - of course - 6 black marbles) ?
This problem is summarized by the following contingency table:
drawn | not drawn | total | |
---|---|---|---|
white marbles | 4 (k) | 1 = 5 − 4 (D − k) | 5 (D) |
black marbles | 6 = 10 − 4 (n − k) | 39 = 50 + 4 − 10 − 5 (N + k − n − D) | 45 (N − D) |
total | 10 (n) | 40 (N − n) | 50 (N) |
The probability Pr (k = x) of drawing exactly x white marbles (= number of successes) can be calculated by the formula
Hence, in this example x = 4, calculate
So, the probability of drawing exactly 4 white marbles is quite low (approximately 0.004) and the event is very unlikely. It means, if you repeated your random experiment (drawing 10 marbles from the urn of 50 marbles without replacement) 1000 times you just would expect to obtain such a result 4 times.
But what about the probability of drawing even (all) 5 white marbles? You will intuitively agree upon that this is even more unlikely than drawing 4 white marbles. Let us calculate the probability for such an extreme event.
The contingency table is as follows:
drawn | not drawn | total | |
---|---|---|---|
white marbles | 5 (k) | 0 = 5 − 5 (D − k) | 5 (D) |
black marbles | 5 = 10 − 5 (n − k) | 40 = 50 + 5 − 10 − 5 (N + k − n − D) | 45 (N − D) |
total | 10 (n) | 40 (N − n) | 50 (N) |
And we can calculate the probability as follows (notice that the denominator always stays the same):
As expected, the probability of drawing 5 white marbles is even much lower than drawing 4 white marbles.
Conclusion:
Consequently, one could expand the initial question as follows: If you draw 10 marbles from an urn (containing 5 white and 45 black marbles), what's the probability of drawing at least 4 white marbles? Or, what's the probability of drawing 4 white marbles and more extreme outcomes such as drawing 5)? This corresponds to calculating the cumulative probability p(k>=4) and can be calculated by the cumulative distribution function (cdf). Since the hypergeometric distribution is a discrete probability distribution the cumulative probability can be calculated easily by adding all corresponding single probability values.
In our example you just have to sum-up Pr (k = 4) and Pr (k = 5):
- Pr (k ≥ 4) = 0.003964583 + 0.0001189375 = 0.004083520
You can easily re-calculate the example given above with the hypergeometric distribution calculator (see also link below) or the free statistical programming language R which is sometimes also called GNU S:
The code snippets for R are as follows:
Pr (k = 4): type
choose (5,4) * choose (45,6) / choose (50,10)
p(k=5): type
choose (5,5) * choose (45,5) / choose (50,10)
or alternatively,
dhyper (5, m=5, n=45, k=10)
p(k>=4): type
phyper (q=3, m=5, n=45, k=10, lower.tail = FALSE)
Explanation:
q : number of white marbles drawn [k in the contingency table]
m : number of white marbles (total) [D in the contingency table]
n : number of black marbles (total) [N - D in the contingency table]
k : number of marbles drawn (total) [n in the contingency table]
lower.tail = FALSE : if lower.tail is set TRUE, than p(k<=x) is calculated; if set to FALSE, p(k>x) is calculated --> in order to calculate p(k>=4) you have to calculate p(k>3)
In addition, the open-source spreadsheet program Gnumeric has the function HYPGEOMDIST to perform the same calculation (Microsoft Excel also has the HYPGEOMDIST function, but the Excel implementation does not support the cumulative option provided by Gnumeric).
If n is much smaller than min (D, N − D), then the hypergeometric distribution approaches the binomial distribution. In other words, this is the case when the number of marbles drawn from the urn is clearly smaller than both the number of black and white marbles. Roughly speaking, sampling with or without replacement is almost identical in large populations.
[edit] Symmetries
This symmetry can be intuitively understood if you repaint all the black marbles to white and vice versa, thus the black and white marbles simply change roles.
- f(k;N,D,n) = f(k;N,n,D)
This symmetry can be intuitively understood if instead of drawing marbles, you label the marbles that you would have drawn. Both expressions give the probability that exactly k marbles are "black" and labeled "drawn"
[edit] Relationship to Fisher's exact test
The test (see above) based on the hypergeometric distribution (hypergeometric test) is identical to the corresponding one-tailed version of Fisher's exact test. Reciprocally, the p-value of a two-sided Fisher's exact test can be calculated as the sum of two appropriate hypergeometric tests (for more information see the following web site).
[edit] Related distributions
- is a binomial distribution as where .