31 double probChiSquared(
double x,
unsigned int n)
35 const unsigned int nmax = 300;
37 const double hf = r1/2;
38 const double th = r1/3;
39 const double f1 = 2*r1/9;
40 const double c1 = 1.128379167095513;
41 const double chipdf = 100;
42 const double xmax = 174.673;
43 const double xmax2 = 2*xmax;
44 const double xlim = 24;
45 const double eps = 1e-30;
48 double h, w, s, t, fi, e;
51 if (x == 0 || n/20 > x)
55 h = w < xlim ? erfc(w) : 0;
60 w = (::pow(x*s,th)-(1-t))/::sqrt(2*t);
70 if(u < xmax2 && (x/n) <= chipdf ) {
91 h = w < xlim ? c1*w*s*e+erfc(w) : 0;
97 return h > eps ? h : 0;