(*  von_mises_cdf_values.nb *)
(* *)
(*  Purpose: *)
(*    Evaluate the von Mises CDF*)
(*    at selected argument values, *)
(*    and write the data to a file. *)
(* *)
(*  Modified:  15 February 2006 *)
(*  Author:  John Burkardt *)

avec={0.0,0.0,0.0,0.0,0.0,
1.0, 1.0, 1.0, 1.0, 1.0, 1.0 ,
-2.0, -1.0, 0.0, 1.0, 2.0, 3.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
bvec = { 1.0, 1.0, 1.0, 1.0, 1.0,
2.0, 2.0, 2.0, 2.0, 2.0, 2.0,
3.0, 3.0, 3.0, 3.0, 3.0, 3.0,
0.0, 1.0, 2.0, 3.0, 4.0, 5.0 };
xvec={-5*Pi/6, -Pi/2,0.0, Pi/3, 2*Pi/3,
1.0, 1.2, 1.4, 1.6, 1.8, 2.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
Pi/4, Pi/4, Pi/4, Pi/4, Pi/4, Pi/4 };
fvec = {};
num = Length [ xvec ];

Do [ { a= avec[[i]], 
       b=bvec[[i]],
      x = xvec[[i]],
f=NIntegrate[Exp[b*Cos[t-a]]/(2*Pi*BesselI[0,b]),{t,-Pi+a,x},
WorkingPrecision->32],
fvec = Append [ fvec, f],
      Print["VMCDF[",a,",",b,",",N[x,16],"]=",N[f,16]] },{i,1,num,1}]

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