Probability Distribution Function and Shape

> restart;

> with(plots):

The Hypergeometric Distribution

Consider a population of size N with G good and B bad elements where N=G+B . Suppose we now take a sample of size n without replacement from this population. The random variable of interest is X = the number of good elements in the sample. X follows a hypergeometric distribution which will be denoted by Hypergeometric( G, B, n ).

If X is a random variable having the Hypergeometric( G, B, n ) distribution, then the probability distribution function for X is

f ( x ) = P( X = x ) = [Maple Math] , x = 1,2, ..., n

The following code will draw a probability histogram for the Hypergeometric( G, B, n ) distribution with G =15, B =5, and n =5. You are encourage to try other values of G , B , and n .

>

> G:=15; B:=5; n:=5;

[Maple Math]

[Maple Math]

[Maple Math]

> ProbHist(HypergeometricPDF(G,B,n,g),0..5);

[Maple Plot]

To see the effect of changes of G on the shape of the hypergeometric distribution, the following animation will draw a series of probability histograms as G varies from 1 to 20 by increments of 1 when N =40 and n =10. Recall B = N-G.

> B:=40-G: n:=10:

> for G from 1 to 20 do

> num:=convert(evalf(G), string):

> tracker[G]:=textplot([8, 0.4, `G is `.num],color=blue):

> H[G]:=ProbHist(HypergeometricPDF(G,B,n,x),0..10):

> P[G]:=display({H[G],tracker[G]}):

> od:

> display([seq(P[G], G=1..20)], insequence=true,title="N is fixed at 40, G is increasing");

[Maple Plot]

Let's see what happens as we hold G constant and allow n to vary from 1 to 30. G is set at 10, but you are encouraged to try other values.

> G:=10: B:=40-G:

> for n from 1 to 30 do

> num:=convert(evalf(n), string):

> tracker[n]:=textplot([15, 0.5, `n is `.num],color=blue):

> H[n]:=ProbHist(HypergeometricPDF(G,B,n,x),0..n):

> P[n]:=display({H[n],tracker[n]}):

> od:

> display([seq(P[n], n=1..30)], insequence=true,title="G is fixed at 10, n is increasing");

[Maple Plot]