(*  geometric_cdf_values.nb *)
(* *)
(*  Purpose: *)
(*    Evaluate the Geometric CDF *)
(*    at selected argument values, *)
(*    and write the data to a file. *)
(* *)
(*  Modified:  21 January 2006 *)
(*  Author:  John Burkardt *)

Needs["Statistics`DiscreteDistributions`"]

pvec = {1/10, 1/10, 1/10,1/10,2/10,2/10,2/10,2/10,3/10,4/10,5/10,5/10,5/10,9/10 };
xvec={1,2,3,10,1,2,3,10,3,3,3,5,10,3};
fvec = {};
num = Length [ xvec ];

Do[{ p = pvec[[i]], x= xvec[[i]],
dist = GeometricDistribution[p], f = N[CDF[dist,x],16],
fvec = Append [ fvec, f ],
Print["GeometricCDF[",p,"](",x,")=",f]
}, {i, 1, num,1}]

fileout=OpenWrite["C:\\Documents and Settings\\burkardt\\Desktop\\Misc\\mathematica\\geometric_cdf_values.txt"];
SetOptions[fileout,FormatType->TextForm];
Write[fileout,"#  geometric_cdf_values.txt"];today=DateList[];Write[fileout,"#  Created on ",today];Write[fileout,"#"];
Write[fileout,"#  p  x  f"];
Write[fileout,"#"];
Do[{p=pvec[[i]];x=xvec[[i]];f=fvec[[i]];Write[fileout,N[p,16],"  ",x,"  ",N[f,16]]},{i,1,num,1}];Close[fileout];