(*  student_noncentral_cdf_values.nb *)
(* *)
(*  Purpose: *)
(*    Evaluate the noncentral Student CDF *)
(*    at selected argument values, *)
(*    and write the data to a file. *)
(* *)
(*  Modified:  13 February 2006 *)
(*  Author:  John Burkardt *)

Needs["Statistics`ContinuousDistributions`"]

nvec={1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,15,20,25,1,2,3,10,10,10,10,10,10,10,10,10};
lambdavec={0,0,0,1/2,1/2,1/2,1,1,1,2,2,2,4,4,4,7,7,7,1,1,1,2,3,4,2,3,4,2,3,4};
xvec={3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,15,15,15,5/100,5/100,5/100,4,4,4,5,5,5,6,6,6};
fvec = {};
num = Length [ xvec ];

Do [ {n=nvec[[i]], lambda = lambdavec[[i]], x=SetPrecision[xvec[[i]],20],
dist=NoncentralStudentTDistribution[n,lambda],
f = N[CDF[dist,x],16] ,
fvec = Append [ fvec, f],
      Print["  NoncentralStudentTCDF[",n,",",lambda,",",x,"]=",f] },{i,1,num,1}]

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