Hypergeometric distribution
From Free net encyclopedia
Template:Probability distribution}\over {N \choose n}}</math>|
cdf =| mean =<math>nD\over N</math>| median =| mode =| variance =<math>n(D/N)(1-D/N)(N-n)\over (N-1)</math>| skewness =| kurtosis =| entropy =| mgf =<math>\fracTemplate:N-D \choose nTemplate:N \choose n\,_2F_1(-n,-D;N-D-n+1;e^{t})</math>| char =<math>\fracTemplate:N-D \choose nTemplate:N \choose n\,_2F_1(-n,-D;N-D-n+1;e^{it})</math>
}} 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
- <math> f(k;N,D,n) = {{{D \choose k} {{N-D} \choose {n-k}}}\over {N \choose n}}</math>
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 <math> N \choose n </math> possible samples (without replacement). There are <math> D \choose k </math> ways to obtain k defective objects and there are <math> {N-D} \choose {n-k} </math> 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 |
Application and example
The classical application of the hypergeometric distribution is sampling without replacement. Think of an urn with two types of balls, black ones and white ones. Define drawing a white ball as a success and drawing a black ball as a failure (analogous to the binomial distribution). If the variable N describes the number of all balls in the urn (see contingency table above) and D describes the number of white balls (called defective in the example above), then N-D corresponds to the number of black balls.
Now, assume that there are 5 white and 45 black balls in the urn. Standing next to the urn, you close your eyes and draw 10 balls without replacement. What's the probability p (k=4) that you draw exactly 4 white balls (and - of course - 6 black balls) ?
This problem is summarized by the following contingency table:
drawn | not drawn | total | |
---|---|---|---|
white balls | 4 (k) | 1 = 5 - 4 (D-k) | 5 (D) |
black balls | 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 p (k=x) of drawing exactly x white balls (= number of successes) can be calculated by the formula
- <math> p(k=x) = f(k;N,D,n) = {{{D \choose k} {{N-D} \choose {n-k}}}\over {N \choose n}}</math>
Hence, in this example x is 4 you calculate
- <math> p(k=4) = f(4;50,5,10) = {{{5 \choose 4} {{45} \choose {6}}}\over {50 \choose 10}} = 0.003964583 </math>
So, the probability of drawing exactly 4 white balls is quite low (approximately 0.004) and the event is very unlikely. It means, if you repeated your random experiment (drawing 10 balls from the urn of 50 balls without replacement) 1000 times you just would expect to obtain such a result 4 times.
O.k., fine. But what about the probability of drawing even (all) 5 white balls? You intuitively will agree upon that this is even more unlikely than drawing 4 white balls.
Well, let's calculate the probability for such an extreme event.
The contingeny table is as follows:
drawn | not drawn | total | |
---|---|---|---|
white balls | 5 (k) | 0 = 5 - 5 (D-k) | 5 (D) |
black balls | 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 you can calculate the probability as follows (notice that the denominator always stays the same):
- <math> p(k=5) = f(5;50,5,10) = {{{5 \choose 5} {{45} \choose {5}}}\over {50 \choose 10}} = 0.0001189375 </math>
You were right, as expected, the probability of drawing 5 white balls is even much lower than drawing 4 white balls.
Conclusion:
Consequently, one could expand the initial question as follows:
If you draw 10 balls from an urn (containing 5 white and 45 black balls), what's the probability of drawing at least 4 white balls? Or, what's the probability of drawing 4 white balls 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 probablity distribution the cumulative probability can be calculated easily by adding all corresponding single probability values.
In our example you just have to sum-up p(k=4) and p(k=5):
p(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:
p(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)
p(k>=4): type
phyper(q=3, m=5, n=45, k=10, lower.tail = FALSE)
Explanation:
q : number of white balls drawn [k in the contingency table]
m : number of white balls (total) [D in the contingency table]
n : number of black balls (total) [N - D in the contingency table]
k : number of balls 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 calculated p(k>=4) you have to calculate p(k>3)
If n is much smaller than min (D, N-D), then the hypergeometric distribution approaches the binomial distribution. In other word: this is the case when the number of balls drawn from the urn is clearly smaller than both the number of black and white balls. Roughly speaking, sampling with or without replacement is almost identical in large populations.
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).
Related distributions
- <math>Y \sim \mathrm{Binomial}(n = n, p = D/N)</math> is a binomial distribution as <math>Y = \lim_{N \to \infty} X</math> where <math>X \sim \mathrm{Hypergeometric}(D, N, n)</math>.
External links
de:Hypergeometrische Verteilung pt:Distribuição hipergeométrica es:Distribución hipergeométrica fr:Loi hypergéométrique it:Variabile casuale Ipergeometrica he:התפלגות היפרגאומטרית