/* function to compute inverse of students t */ /* Uses routine pst_ to compute students t and Numerical recipes routine */ /* zbrent to solve for inverse */ /* Parameters *q = 2 sided confidence level probability */ /* *v = Degrees of freedom */ /* Value returned is t such that prob(abs(t)>q) */ /* Limitations: Correct to within 1e-5 (zbrent tol) and will only */ /* return solutions between 0 and 100 */ /* global variables that are parameters passed to function */ double ql,vl; double psti_(q,v) double *q,*v; { double fpsti(); double zbrent(); ql= *q; vl= *v; /* printf("%g %g\n",ql,vl); */ return zbrent(fpsti,0.,100.,1.0e-5); } /* function to pass to zbrent for psti */ double fpsti(t) double t; { double pst(); return pst(&t,&vl)-1.+(ql); } /* function to compute students t */ /* Uses Numerical Recipes routine betai */ /* Based on numerical recipes equation 6.3.9 (p181) */ /* Parameters *t = Students t Abssicia */ /* *v = Degrees of freedom */ /* Value returned is prob(abs(t)>q) */ double pst(t,v) double *t,*v; { double betai(); return 1.-betai((*v)/2., 0.5, (*v)/((*v)+(*t)*(*t))); }