(*  hypergeometric_pdf_values.nb *)
(* *)
(*  Purpose: *)
(*    Evaluate the hypergeometric PDF *)
(*    at selected argument values, *)
(*    and write the data to a file. *)
(* *)
(*  Modified:  08 January 2008 *)
(*  Author:  John Burkardt *)

samvec={
10,10,10,10,
6, 7, 8, 9,
10,10,10,10,
10,10,10,10};
sucvec = {
90,90,90,90,
90,90,90,90,
 10, 30, 50, 70,
90,90,90,90};
popvec = {
100,100,100,100,
100,100,100,100,
100,100,100,100,
90, 200,1000,10000};
nvec = {
7,8,9,10,
6, 6, 6, 6,
6,6,6,6,
0, 0, 0,0};
fvec = {};
num = Length [ nvec ];

Do[{ sam = samvec[[i]], suc = sucvec[[i]],pop=popvec[[i]],n=nvec[[i]],
dist = HypergeometricDistribution[sam,suc,pop], f = N[PDF[dist,n],16],
fvec = Append [ fvec, f ],
Print["HyperPDF[",sam,",",suc,",",pop,"](",n,")=",f]
}, {i, 1, num,1}]

fileout=OpenWrite["/Users/burkardt/public_html/math_src/test_values/hypergeometric_pdf_values.txt"];SetOptions[fileout,FormatType->TextForm];Write[fileout,"#  hypergeometric_pdf_values.txt"];today=DateList[];Write[fileout,"#  Created on ",today];Write[fileout,"#"];Write[fileout,"#  sam  suc  pop  n  f"];Write[fileout,"#"];Do[{sam=samvec[[i]];suc=sucvec[[i]];pop=popvec[[i]];n=nvec[[i]];f=fvec[[i]];Write[fileout,sam,"  ",suc,"  ",pop,"  ",n,"  ",N[f,16]]},{i,1,num,1}] ;
Close[fileout];