In this screencast I am going to demonstrate the hypergeometric distribution, I am going
to derive the probability function for it, and I am go through an example. So the hypergeometric
distribution is used often time when we have sampling without replacement. A lot of times
this is the case when we have a small population, or we have destructive sampling. Now if you
have a really big population and you remove samples from it without replacement, the population
is so big that removing a small sample doesn't really do anything to the characteristics
of the population. So that you would use the binomial distribution. So, the hypergeometric
distribution is when you have some sort of populations of limited size, and let's just
say that that's capital N. Of the capital N items, we have capital K, that have some
sort of characteristic, and I am going to refer to K as being a success, although in
some cases you could turn this around and say K is really a failure. So we have K, and
we have N-K, so those combined give us our capital N, which is some sort of limited size
population. Now we take a sample from this, we assume its mixed up, and that sample is
going to have little n items, and the number of successes in that sample we'll denote by
little x. This is often times used when trying to answer a question like "what is the probability
that the sample of size little n has X successes?" This is used a lot in product testing. So
I am going to start this, the derivation of the hypergeometric sequence, by noting that
the probability of having x successes in a sample of size n, so n will be set by the
user, and also x will be chosen, but the function is going to be a function of x, is the number
of ways that satisfy a particular constraint, divided by the total possibilities. So the
number of ways that satisfy a constraint. Now our sample is going to be composed of
a certain number of successes, and a certain number of failures, and if we multiply these
two together for every possible combination of successes with every possible combination
of the failures, then that will be the number of ways that satisfy a constraint, and now
we're saying that we have x successes, so this here is going to be x, number of failures
then is going to be the number of items in the sample, minus the number of successes.
We have a K successes in our population, so if I go back here to our diagram, we have
K successes in our population of big N. So how many ways can we put K successes that
are possible, so K possibilities, into x spots. Its just K choose x. If we had twenty successes
in our population of 100 and our sample is going to have 3 successes that would
be 20 choose 3. There are that many ways to combine the K successes in our population
into x number of spots. Now what about failures? How many ways, remember we have N minus K
possible failures in our population, and we're going to put that into little n minus x spots,
so how many different ways can we combine N minus K failures in the population into
n minus x spots, its just a combination. So for each of these successes on the left we
can multiply that with each of these failures on the right. So to calculate the total number
of ways to satisfy the constraint its just the product of these two. Now remember, probability
was the total number of ways that we could satisfy a constraint divided by the total
number of possibilities. The top of this is going to be K choose x times big N minus big
K over n minus x, but the denominator is the total number of ways that we can take capital
N items and put them into little n spots, which is just big N choose little n, so this
is the probability function for the hypergeometric sequence. So I've got an example problem here.
You work for a pharmaceutical company that produces a product called "Curesall." The
FDA arrives, and they want to do a random check. They want to test a week worth of production.
In a week your company makes twenty batches, they are going to take five of them and this
is going to be a destructive test, so it's a sampling without replacement. Your internal
testing during the week has indicated that seventeen of the twenty batches are good.
What is the probability that at least 4 of the 5 batches tested are good? First of all,
whenever you see at least that is sort of a cue that you are going to be using the sum
of two different probabilities, so at least would mean you have 4 or 5. So this is really what
I am asking for is f of 4 plus f of 5. We have our population of twenty batches, and
we know that seventeen are successful, so I am going to say "K then is equal to 17, and big
N is equal to 20. Now, the FDA comes and they take a random sample of 5 items, so little
n is equal to 5. What's the probability that 4 or 5, so x equals 4 or 5, are successful?"
So we can just plug these values into the hypergeometric function here. When you do
that you get f of 4 is equal to about 0.46, and you get f of 5, which equals about 0.40.
So the total probability that at least 4 of the 5 batches tested are good is 86 percent.
Now let me show you how to do this in Microsoft Excel. I've set this up in Microsoft Excel,
I have my big N and I am going to label this big N, I have big K here, that is the number
of successes in our population, and big n is the number of total batches. This is going
to be little n, n bar. This is the number of successes in our sample of size 5. This
is 4 or 5. In Microsoft Excel there is a function, hypegeom.dist, and this returns the hypergeometric
distribution. So, the first thing here is the samples successes, so sample s is the
sample successes, so that's going to be 4. The number in our sample was 5, so that was
n bar. the next thing is the successes in our population. We have big K successes in
our population. The number in our population, we have big N, and this is going to be false
because we're not doing a cumulative distribution here. So this is going to determine the probability
that we get, in our sample size five, we get exactly four successes, and that's 46 percent.
And I can drag this down, and we get about 40, and then I can just sum those two, and
that's what we got using the formula, about 86 percent, same thing we get using this formula
because this is the exact formula that Excel is using.