Doxygen Source Code Documentation
cdflib.h File Reference
#include <stdio.h>#include <stdlib.h>#include <math.h>Go to the source code of this file.
| Functions | |
| double | algdiv (double *, double *) | 
| double | alngam (double *) | 
| double | alnrel (double *) | 
| double | apser (double *, double *, double *, double *) | 
| double | basym (double *, double *, double *, double *) | 
| double | bcorr (double *, double *) | 
| double | betaln (double *, double *) | 
| double | bfrac (double *, double *, double *, double *, double *, double *) | 
| void | bgrat (double *, double *, double *, double *, double *, double *, int *i) | 
| double | bpser (double *, double *, double *, double *) | 
| void | bratio (double *, double *, double *, double *, double *, double *, int *) | 
| double | brcmp1 (int *, double *, double *, double *, double *) | 
| double | brcomp (double *, double *, double *, double *) | 
| double | bup (double *, double *, double *, double *, int *, double *) | 
| void | cdfbet (int *, double *, double *, double *, double *, double *, double *, int *, double *) | 
| void | cdfbin (int *, double *, double *, double *, double *, double *, double *, int *, double *) | 
| void | cdfchi (int *, double *, double *, double *, double *, int *, double *) | 
| void | cdfchn (int *, double *, double *, double *, double *, double *, int *, double *) | 
| void | cdff (int *, double *, double *, double *, double *, double *, int *, double *) | 
| void | cdffnc (int *, double *, double *, double *, double *, double *, double *, int *s, double *) | 
| void | cdfgam (int *, double *, double *, double *, double *, double *, int *, double *) | 
| void | cdfnbn (int *, double *, double *, double *, double *, double *, double *, int *, double *) | 
| void | cdfnor (int *, double *, double *, double *, double *, double *, int *, double *) | 
| void | cdfpoi (int *, double *, double *, double *, double *, int *, double *) | 
| void | cdft (int *, double *, double *, double *, double *, int *, double *) | 
| void | cumbet (double *, double *, double *, double *, double *, double *) | 
| void | cumbin (double *, double *, double *, double *, double *, double *) | 
| void | cumchi (double *, double *, double *, double *) | 
| void | cumchn (double *, double *, double *, double *, double *) | 
| void | cumf (double *, double *, double *, double *, double *) | 
| void | cumfnc (double *, double *, double *, double *, double *, double *) | 
| void | cumgam (double *, double *, double *, double *) | 
| void | cumnbn (double *, double *, double *, double *, double *, double *) | 
| void | cumnor (double *, double *, double *) | 
| void | cumpoi (double *, double *, double *, double *) | 
| void | cumt (double *, double *, double *, double *) | 
| double | dbetrm (double *, double *) | 
| double | devlpl (double[], int *, double *) | 
| double | dexpm1 (double *) | 
| double | dinvnr (double *p, double *q) | 
| void | E0000 (int, int *, double *, double *, unsigned long *, unsigned long *, double *, double *, double *, double *, double *, double *, double *) | 
| void | dinvr (int *, double *, double *, unsigned long *, unsigned long *) | 
| void | dstinv (double *, double *, double *, double *, double *, double *, double *) | 
| double | dlanor (double *) | 
| double | dln1mx (double *) | 
| double | dln1px (double *) | 
| double | dlnbet (double *, double *) | 
| double | dlngam (double *) | 
| double | dstrem (double *) | 
| double | dt1 (double *, double *, double *) | 
| void | E0001 (int, int *, double *, double *, double *, double *, unsigned long *, unsigned long *, double *, double *, double *, double *) | 
| void | dzror (int *, double *, double *, double *, double *, unsigned long *, unsigned long *) | 
| void | dstzr (double *zxlo, double *zxhi, double *zabstl, double *zreltl) | 
| double | erf1 (double *) | 
| double | erfc1 (int *, double *) | 
| double | esum (int *, double *) | 
| double | exparg (int *) | 
| double | fpser (double *, double *, double *, double *) | 
| double | gam1 (double *) | 
| void | gaminv (double *, double *, double *, double *, double *, int *) | 
| double | gamln (double *) | 
| double | gamln1 (double *) | 
| double | Xgamm (double *) | 
| void | grat1 (double *, double *, double *, double *, double *, double *) | 
| void | gratio (double *, double *, double *, double *, int *) | 
| double | gsumln (double *, double *) | 
| double | psi (double *) | 
| double | rcomp (double *, double *) | 
| double | rexp (double *) | 
| double | rlog (double *) | 
| double | rlog1 (double *) | 
| double | spmpar (int *) | 
| double | stvaln (double *) | 
| double | fifdint (double) | 
| double | fifdmax1 (double, double) | 
| double | fifdmin1 (double, double) | 
| double | fifdsign (double, double) | 
| long | fifidint (double) | 
| long | fifmod (long, long) | 
| void | ftnstop (char *) | 
| int | ipmpar (int *) | 
Function Documentation
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_00.c. References a, algdiv(), alnrel(), c, v, and x2. Referenced by algdiv(), betaln(), bgrat(), bpser(), brcmp1(), brcomp(), and dlnbet(). 
 00015 {
00016 static double c0 = .833333333333333e-01;
00017 static double c1 = -.277777777760991e-02;
00018 static double c2 = .793650666825390e-03;
00019 static double c3 = -.595202931351870e-03;
00020 static double c4 = .837308034031215e-03;
00021 static double c5 = -.165322962780713e-02;
00022 static double algdiv,c,d,h,s11,s3,s5,s7,s9,t,u,v,w,x,x2,T1;
00023 /*
00024      ..
00025      .. Executable Statements ..
00026 */
00027     if(*a <= *b) goto S10;
00028     h = *b/ *a;
00029     c = 1.0e0/(1.0e0+h);
00030     x = h/(1.0e0+h);
00031     d = *a+(*b-0.5e0);
00032     goto S20;
00033 S10:
00034     h = *a/ *b;
00035     c = h/(1.0e0+h);
00036     x = 1.0e0/(1.0e0+h);
00037     d = *b+(*a-0.5e0);
00038 S20:
00039 /*
00040                 SET SN = (1 - X**N)/(1 - X)
00041 */
00042     x2 = x*x;
00043     s3 = 1.0e0+(x+x2);
00044     s5 = 1.0e0+(x+x2*s3);
00045     s7 = 1.0e0+(x+x2*s5);
00046     s9 = 1.0e0+(x+x2*s7);
00047     s11 = 1.0e0+(x+x2*s9);
00048 /*
00049                 SET W = DEL(B) - DEL(A + B)
00050 */
00051     t = pow(1.0e0/ *b,2.0);
00052     w = ((((c5*s11*t+c4*s9)*t+c3*s7)*t+c2*s5)*t+c1*s3)*t+c0;
00053     w *= (c/ *b);
00054 /*
00055                     COMBINE THE RESULTS
00056 */
00057     T1 = *a/ *b;
00058     u = d*alnrel(&T1);
00059     v = *a*(log(*b)-1.0e0);
00060     if(u <= v) goto S30;
00061     algdiv = w-v-u;
00062     return algdiv;
00063 S30:
00064     algdiv = w-u-v;
00065     return algdiv;
00066 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_01.c. References alngam(), devlpl(), fifidint(), i, and offset. Referenced by alngam(), cumchn(), and cumfnc(). 
 00036 {
00037 #define hln2pi 0.91893853320467274178e0
00038 static double coef[5] = {
00039     0.83333333333333023564e-1,-0.27777777768818808e-2,0.79365006754279e-3,
00040     -0.594997310889e-3,0.8065880899e-3
00041 };
00042 static double scoefd[4] = {
00043     0.62003838007126989331e2,0.9822521104713994894e1,-0.8906016659497461257e1,
00044     0.1000000000000000000e1
00045 };
00046 static double scoefn[9] = {
00047     0.62003838007127258804e2,0.36036772530024836321e2,0.20782472531792126786e2,
00048     0.6338067999387272343e1,0.215994312846059073e1,0.3980671310203570498e0,
00049     0.1093115956710439502e0,0.92381945590275995e-2,0.29737866448101651e-2
00050 };
00051 static int K1 = 9;
00052 static int K3 = 4;
00053 static int K5 = 5;
00054 static double alngam,offset,prod,xx;
00055 static int i,n;
00056 static double T2,T4,T6;
00057 /*
00058      ..
00059      .. Executable Statements ..
00060 */
00061     if(!(*x <= 6.0e0)) goto S70;
00062     prod = 1.0e0;
00063     xx = *x;
00064     if(!(*x > 3.0e0)) goto S30;
00065 S10:
00066     if(!(xx > 3.0e0)) goto S20;
00067     xx -= 1.0e0;
00068     prod *= xx;
00069     goto S10;
00070 S30:
00071 S20:
00072     if(!(*x < 2.0e0)) goto S60;
00073 S40:
00074     if(!(xx < 2.0e0)) goto S50;
00075     prod /= xx;
00076     xx += 1.0e0;
00077     goto S40;
00078 S60:
00079 S50:
00080     T2 = xx-2.0e0;
00081     T4 = xx-2.0e0;
00082     alngam = devlpl(scoefn,&K1,&T2)/devlpl(scoefd,&K3,&T4);
00083 /*
00084      COMPUTE RATIONAL APPROXIMATION TO GAMMA(X)
00085 */
00086     alngam *= prod;
00087     alngam = log(alngam);
00088     goto S110;
00089 S70:
00090     offset = hln2pi;
00091 /*
00092      IF NECESSARY MAKE X AT LEAST 12 AND CARRY CORRECTION IN OFFSET
00093 */
00094     n = fifidint(12.0e0-*x);
00095     if(!(n > 0)) goto S90;
00096     prod = 1.0e0;
00097     for(i=1; i<=n; i++) prod *= (*x+(double)(i-1));
00098     offset -= log(prod);
00099     xx = *x+(double)n;
00100     goto S100;
00101 S90:
00102     xx = *x;
00103 S100:
00104 /*
00105      COMPUTE POWER SERIES
00106 */
00107     T6 = 1.0e0/pow(xx,2.0);
00108     alngam = devlpl(coef,&K5,&T6)/xx;
00109     alngam += (offset+(xx-0.5e0)*log(xx)-xx);
00110 S110:
00111     return alngam;
00112 #undef hln2pi
00113 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_02.c. Referenced by algdiv(), alnrel(), betaln(), bgrat(), brcmp1(), brcomp(), dlnbet(), gaminv(), and gsumln(). 
 00008 {
00009 static double p1 = -.129418923021993e+01;
00010 static double p2 = .405303492862024e+00;
00011 static double p3 = -.178874546012214e-01;
00012 static double q1 = -.162752256355323e+01;
00013 static double q2 = .747811014037616e+00;
00014 static double q3 = -.845104217945565e-01;
00015 static double alnrel,t,t2,w,x;
00016 /*
00017      ..
00018      .. Executable Statements ..
00019 */
00020     if(fabs(*a) > 0.375e0) goto S10;
00021     t = *a/(*a+2.0e0);
00022     t2 = t*t;
00023     w = (((p3*t2+p2)*t2+p1)*t2+1.0e0)/(((q3*t2+q2)*t2+q1)*t2+1.0e0);
00024     alnrel = 2.0e0*t*w;
00025     return alnrel;
00026 S10:
00027     x = 1.e0+*a;
00028     alnrel = log(x);
00029     return alnrel;
00030 } /* END */
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 2 of file cdf_03.c. References a, apser(), c, and psi(). Referenced by apser(), and bratio(). 
 00010 {
00011 static double g = .577215664901533e0;
00012 static double apser,aj,bx,c,j,s,t,tol;
00013 /*
00014      ..
00015      .. Executable Statements ..
00016 */
00017     bx = *b**x;
00018     t = *x-bx;
00019     if(*b**eps > 2.e-2) goto S10;
00020     c = log(*x)+psi(b)+g+t;
00021     goto S20;
00022 S10:
00023     c = log(bx)+g+t;
00024 S20:
00025     tol = 5.0e0**eps*fabs(c);
00026     j = 1.0e0;
00027     s = 0.0e0;
00028 S30:
00029     j += 1.0e0;
00030     t *= (*x-bx/j);
00031     aj = t/j;
00032     s += aj;
00033     if(fabs(aj) > tol) goto S30;
00034     apser = -(*a*(c+s));
00035     return apser;
00036 } /* END */
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 2 of file cdf_04.c. References a, basym(), bcorr(), c, erfc1(), i, r, rlog1(), z0, and zn. Referenced by basym(), and bratio(). 
 00011 {
00012 static double e0 = 1.12837916709551e0;
00013 static double e1 = .353553390593274e0;
00014 static int num = 20;
00015 /*
00016 ------------------------
00017      ****** NUM IS THE MAXIMUM VALUE THAT N CAN TAKE IN THE DO LOOP
00018             ENDING AT STATEMENT 50. IT IS REQUIRED THAT NUM BE EVEN.
00019             THE ARRAYS A0, B0, C, D HAVE DIMENSION NUM + 1.
00020 ------------------------
00021      E0 = 2/SQRT(PI)
00022      E1 = 2**(-3/2)
00023 ------------------------
00024 */
00025 static int K3 = 1;
00026 static double basym,bsum,dsum,f,h,h2,hn,j0,j1,r,r0,r1,s,sum,t,t0,t1,u,w,w0,z,z0,
00027     z2,zn,znm1;
00028 static int i,im1,imj,j,m,mm1,mmj,n,np1;
00029 static double a0[21],b0[21],c[21],d[21],T1,T2;
00030 /*
00031      ..
00032      .. Executable Statements ..
00033 */
00034     basym = 0.0e0;
00035     if(*a >= *b) goto S10;
00036     h = *a/ *b;
00037     r0 = 1.0e0/(1.0e0+h);
00038     r1 = (*b-*a)/ *b;
00039     w0 = 1.0e0/sqrt(*a*(1.0e0+h));
00040     goto S20;
00041 S10:
00042     h = *b/ *a;
00043     r0 = 1.0e0/(1.0e0+h);
00044     r1 = (*b-*a)/ *a;
00045     w0 = 1.0e0/sqrt(*b*(1.0e0+h));
00046 S20:
00047     T1 = -(*lambda/ *a);
00048     T2 = *lambda/ *b;
00049     f = *a*rlog1(&T1)+*b*rlog1(&T2);
00050     t = exp(-f);
00051     if(t == 0.0e0) return basym;
00052     z0 = sqrt(f);
00053     z = 0.5e0*(z0/e1);
00054     z2 = f+f;
00055     a0[0] = 2.0e0/3.0e0*r1;
00056     c[0] = -(0.5e0*a0[0]);
00057     d[0] = -c[0];
00058     j0 = 0.5e0/e0*erfc1(&K3,&z0);
00059     j1 = e1;
00060     sum = j0+d[0]*w0*j1;
00061     s = 1.0e0;
00062     h2 = h*h;
00063     hn = 1.0e0;
00064     w = w0;
00065     znm1 = z;
00066     zn = z2;
00067     for(n=2; n<=num; n+=2) {
00068         hn = h2*hn;
00069         a0[n-1] = 2.0e0*r0*(1.0e0+h*hn)/((double)n+2.0e0);
00070         np1 = n+1;
00071         s += hn;
00072         a0[np1-1] = 2.0e0*r1*s/((double)n+3.0e0);
00073         for(i=n; i<=np1; i++) {
00074             r = -(0.5e0*((double)i+1.0e0));
00075             b0[0] = r*a0[0];
00076             for(m=2; m<=i; m++) {
00077                 bsum = 0.0e0;
00078                 mm1 = m-1;
00079                 for(j=1; j<=mm1; j++) {
00080                     mmj = m-j;
00081                     bsum += (((double)j*r-(double)mmj)*a0[j-1]*b0[mmj-1]);
00082                 }
00083                 b0[m-1] = r*a0[m-1]+bsum/(double)m;
00084             }
00085             c[i-1] = b0[i-1]/((double)i+1.0e0);
00086             dsum = 0.0e0;
00087             im1 = i-1;
00088             for(j=1; j<=im1; j++) {
00089                 imj = i-j;
00090                 dsum += (d[imj-1]*c[j-1]);
00091             }
00092             d[i-1] = -(dsum+c[i-1]);
00093         }
00094         j0 = e1*znm1+((double)n-1.0e0)*j0;
00095         j1 = e1*zn+(double)n*j1;
00096         znm1 = z2*znm1;
00097         zn = z2*zn;
00098         w = w0*w;
00099         t0 = d[n-1]*w*j0;
00100         w = w0*w;
00101         t1 = d[np1-1]*w*j1;
00102         sum += (t0+t1);
00103         if(fabs(t0)+fabs(t1) <= *eps*sum) goto S80;
00104     }
00105 S80:
00106     u = exp(-bcorr(a,b));
00107     basym = e0*t*u*sum;
00108     return basym;
00109 } /* END */
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_05.c. References a, bcorr(), c, fifdmax1(), fifdmin1(), and x2. Referenced by basym(), bcorr(), betaln(), brcmp1(), brcomp(), and dlnbet(). 
 00012 {
00013 static double c0 = .833333333333333e-01;
00014 static double c1 = -.277777777760991e-02;
00015 static double c2 = .793650666825390e-03;
00016 static double c3 = -.595202931351870e-03;
00017 static double c4 = .837308034031215e-03;
00018 static double c5 = -.165322962780713e-02;
00019 static double bcorr,a,b,c,h,s11,s3,s5,s7,s9,t,w,x,x2;
00020 /*
00021      ..
00022      .. Executable Statements ..
00023 */
00024     a = fifdmin1(*a0,*b0);
00025     b = fifdmax1(*a0,*b0);
00026     h = a/b;
00027     c = h/(1.0e0+h);
00028     x = 1.0e0/(1.0e0+h);
00029     x2 = x*x;
00030 /*
00031                 SET SN = (1 - X**N)/(1 - X)
00032 */
00033     s3 = 1.0e0+(x+x2);
00034     s5 = 1.0e0+(x+x2*s3);
00035     s7 = 1.0e0+(x+x2*s5);
00036     s9 = 1.0e0+(x+x2*s7);
00037     s11 = 1.0e0+(x+x2*s9);
00038 /*
00039                 SET W = DEL(B) - DEL(A + B)
00040 */
00041     t = pow(1.0e0/b,2.0);
00042     w = ((((c5*s11*t+c4*s9)*t+c3*s7)*t+c2*s5)*t+c1*s3)*t+c0;
00043     w *= (c/b);
00044 /*
00045                    COMPUTE  DEL(A) + W
00046 */
00047     t = pow(1.0e0/a,2.0);
00048     bcorr = (((((c5*t+c4)*t+c3)*t+c2)*t+c1)*t+c0)/a+w;
00049     return bcorr;
00050 } /* END */
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_06.c. References a, algdiv(), alnrel(), bcorr(), betaln(), c, fifdmax1(), fifdmin1(), gamln(), gsumln(), i, and v. Referenced by betaln(), bpser(), brcmp1(), and brcomp(). 
 00010 {
00011 static double e = .918938533204673e0;
00012 static double betaln,a,b,c,h,u,v,w,z;
00013 static int i,n;
00014 static double T1;
00015 /*
00016      ..
00017      .. Executable Statements ..
00018 */
00019     a = fifdmin1(*a0,*b0);
00020     b = fifdmax1(*a0,*b0);
00021     if(a >= 8.0e0) goto S100;
00022     if(a >= 1.0e0) goto S20;
00023 /*
00024 -----------------------------------------------------------------------
00025                    PROCEDURE WHEN A .LT. 1
00026 -----------------------------------------------------------------------
00027 */
00028     if(b >= 8.0e0) goto S10;
00029     T1 = a+b;
00030     betaln = gamln(&a)+(gamln(&b)-gamln(&T1));
00031     return betaln;
00032 S10:
00033     betaln = gamln(&a)+algdiv(&a,&b);
00034     return betaln;
00035 S20:
00036 /*
00037 -----------------------------------------------------------------------
00038                 PROCEDURE WHEN 1 .LE. A .LT. 8
00039 -----------------------------------------------------------------------
00040 */
00041     if(a > 2.0e0) goto S40;
00042     if(b > 2.0e0) goto S30;
00043     betaln = gamln(&a)+gamln(&b)-gsumln(&a,&b);
00044     return betaln;
00045 S30:
00046     w = 0.0e0;
00047     if(b < 8.0e0) goto S60;
00048     betaln = gamln(&a)+algdiv(&a,&b);
00049     return betaln;
00050 S40:
00051 /*
00052                 REDUCTION OF A WHEN B .LE. 1000
00053 */
00054     if(b > 1000.0e0) goto S80;
00055     n = a-1.0e0;
00056     w = 1.0e0;
00057     for(i=1; i<=n; i++) {
00058         a -= 1.0e0;
00059         h = a/b;
00060         w *= (h/(1.0e0+h));
00061     }
00062     w = log(w);
00063     if(b < 8.0e0) goto S60;
00064     betaln = w+gamln(&a)+algdiv(&a,&b);
00065     return betaln;
00066 S60:
00067 /*
00068                  REDUCTION OF B WHEN B .LT. 8
00069 */
00070     n = b-1.0e0;
00071     z = 1.0e0;
00072     for(i=1; i<=n; i++) {
00073         b -= 1.0e0;
00074         z *= (b/(a+b));
00075     }
00076     betaln = w+log(z)+(gamln(&a)+(gamln(&b)-gsumln(&a,&b)));
00077     return betaln;
00078 S80:
00079 /*
00080                 REDUCTION OF A WHEN B .GT. 1000
00081 */
00082     n = a-1.0e0;
00083     w = 1.0e0;
00084     for(i=1; i<=n; i++) {
00085         a -= 1.0e0;
00086         w *= (a/(1.0e0+a/b));
00087     }
00088     betaln = log(w)-(double)n*log(b)+(gamln(&a)+algdiv(&a,&b));
00089     return betaln;
00090 S100:
00091 /*
00092 -----------------------------------------------------------------------
00093                    PROCEDURE WHEN A .GE. 8
00094 -----------------------------------------------------------------------
00095 */
00096     w = bcorr(&a,&b);
00097     h = a/b;
00098     c = h/(1.0e0+h);
00099     u = -((a-0.5e0)*log(c));
00100     v = b*alnrel(&h);
00101     if(u <= v) goto S110;
00102     betaln = -(0.5e0*log(b))+e+w-v-u;
00103     return betaln;
00104 S110:
00105     betaln = -(0.5e0*log(b))+e+w-u-v;
00106     return betaln;
00107 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_07.c. References a, bfrac(), brcomp(), c, p, and r. Referenced by bfrac(), and bratio(). 
 00010 {
00011 static double bfrac,alpha,an,anp1,beta,bn,bnp1,c,c0,c1,e,n,p,r,r0,s,t,w,yp1;
00012 /*
00013      ..
00014      .. Executable Statements ..
00015 */
00016     bfrac = brcomp(a,b,x,y);
00017     if(bfrac == 0.0e0) return bfrac;
00018     c = 1.0e0+*lambda;
00019     c0 = *b/ *a;
00020     c1 = 1.0e0+1.0e0/ *a;
00021     yp1 = *y+1.0e0;
00022     n = 0.0e0;
00023     p = 1.0e0;
00024     s = *a+1.0e0;
00025     an = 0.0e0;
00026     bn = anp1 = 1.0e0;
00027     bnp1 = c/c1;
00028     r = c1/c;
00029 S10:
00030 /*
00031         CONTINUED FRACTION CALCULATION
00032 */
00033     n += 1.0e0;
00034     t = n/ *a;
00035     w = n*(*b-n)**x;
00036     e = *a/s;
00037     alpha = p*(p+c0)*e*e*(w**x);
00038     e = (1.0e0+t)/(c1+t+t);
00039     beta = n+w/s+e*(c+n*yp1);
00040     p = 1.0e0+t;
00041     s += 2.0e0;
00042 /*
00043         UPDATE AN, BN, ANP1, AND BNP1
00044 */
00045     t = alpha*an+beta*anp1;
00046     an = anp1;
00047     anp1 = t;
00048     t = alpha*bn+beta*bnp1;
00049     bn = bnp1;
00050     bnp1 = t;
00051     r0 = r;
00052     r = anp1/bnp1;
00053     if(fabs(r-r0) <= *eps*r) goto S20;
00054 /*
00055         RESCALE AN, BN, ANP1, AND BNP1
00056 */
00057     an /= bnp1;
00058     bn /= bnp1;
00059     anp1 = r;
00060     bnp1 = 1.0e0;
00061     goto S10;
00062 S20:
00063 /*
00064                  TERMINATION
00065 */
00066     bfrac *= r;
00067     return bfrac;
00068 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_08.c. References a, algdiv(), alnrel(), c, gam1(), grat1(), i, l, n2, p, q, r, and v. Referenced by bratio(). 
 00012 {
00013 static double bm1,bp2n,cn,coef,dj,j,l,lnx,n2,nu,p,q,r,s,sum,t,t2,u,v,z;
00014 static int i,n,nm1;
00015 static double c[30],d[30],T1;
00016 /*
00017      ..
00018      .. Executable Statements ..
00019 */
00020     bm1 = *b-0.5e0-0.5e0;
00021     nu = *a+0.5e0*bm1;
00022     if(*y > 0.375e0) goto S10;
00023     T1 = -*y;
00024     lnx = alnrel(&T1);
00025     goto S20;
00026 S10:
00027     lnx = log(*x);
00028 S20:
00029     z = -(nu*lnx);
00030     if(*b*z == 0.0e0) goto S70;
00031 /*
00032                  COMPUTATION OF THE EXPANSION
00033                  SET R = EXP(-Z)*Z**B/GAMMA(B)
00034 */
00035     r = *b*(1.0e0+gam1(b))*exp(*b*log(z));
00036     r *= (exp(*a*lnx)*exp(0.5e0*bm1*lnx));
00037     u = algdiv(b,a)+*b*log(nu);
00038     u = r*exp(-u);
00039     if(u == 0.0e0) goto S70;
00040     grat1(b,&z,&r,&p,&q,eps);
00041     v = 0.25e0*pow(1.0e0/nu,2.0);
00042     t2 = 0.25e0*lnx*lnx;
00043     l = *w/u;
00044     j = q/r;
00045     sum = j;
00046     t = cn = 1.0e0;
00047     n2 = 0.0e0;
00048     for(n=1; n<=30; n++) {
00049         bp2n = *b+n2;
00050         j = (bp2n*(bp2n+1.0e0)*j+(z+bp2n+1.0e0)*t)*v;
00051         n2 += 2.0e0;
00052         t *= t2;
00053         cn /= (n2*(n2+1.0e0));
00054         c[n-1] = cn;
00055         s = 0.0e0;
00056         if(n == 1) goto S40;
00057         nm1 = n-1;
00058         coef = *b-(double)n;
00059         for(i=1; i<=nm1; i++) {
00060             s += (coef*c[i-1]*d[n-i-1]);
00061             coef += *b;
00062         }
00063 S40:
00064         d[n-1] = bm1*cn+s/(double)n;
00065         dj = d[n-1]*j;
00066         sum += dj;
00067         if(sum <= 0.0e0) goto S70;
00068         if(fabs(dj) <= *eps*(sum+l)) goto S60;
00069     }
00070 S60:
00071 /*
00072                     ADD THE RESULTS TO W
00073 */
00074     *ierr = 0;
00075     *w += (u*sum);
00076     return;
00077 S70:
00078 /*
00079                THE EXPANSION CANNOT BE COMPUTED
00080 */
00081     *ierr = 1;
00082     return;
00083 } /* END */
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 2 of file cdf_09.c. References a, algdiv(), betaln(), bpser(), c, fifdmax1(), fifdmin1(), gam1(), gamln1(), and i. Referenced by bpser(), and bratio(). 
 00009 {
00010 static double bpser,a0,apb,b0,c,n,sum,t,tol,u,w,z;
00011 static int i,m;
00012 /*
00013      ..
00014      .. Executable Statements ..
00015 */
00016     bpser = 0.0e0;
00017     if(*x == 0.0e0) return bpser;
00018 /*
00019 -----------------------------------------------------------------------
00020             COMPUTE THE FACTOR X**A/(A*BETA(A,B))
00021 -----------------------------------------------------------------------
00022 */
00023     a0 = fifdmin1(*a,*b);
00024     if(a0 < 1.0e0) goto S10;
00025     z = *a*log(*x)-betaln(a,b);
00026     bpser = exp(z)/ *a;
00027     goto S100;
00028 S10:
00029     b0 = fifdmax1(*a,*b);
00030     if(b0 >= 8.0e0) goto S90;
00031     if(b0 > 1.0e0) goto S40;
00032 /*
00033             PROCEDURE FOR A0 .LT. 1 AND B0 .LE. 1
00034 */
00035     bpser = pow(*x,*a);
00036     if(bpser == 0.0e0) return bpser;
00037     apb = *a+*b;
00038     if(apb > 1.0e0) goto S20;
00039     z = 1.0e0+gam1(&apb);
00040     goto S30;
00041 S20:
00042     u = *a+*b-1.e0;
00043     z = (1.0e0+gam1(&u))/apb;
00044 S30:
00045     c = (1.0e0+gam1(a))*(1.0e0+gam1(b))/z;
00046     bpser *= (c*(*b/apb));
00047     goto S100;
00048 S40:
00049 /*
00050          PROCEDURE FOR A0 .LT. 1 AND 1 .LT. B0 .LT. 8
00051 */
00052     u = gamln1(&a0);
00053     m = b0-1.0e0;
00054     if(m < 1) goto S60;
00055     c = 1.0e0;
00056     for(i=1; i<=m; i++) {
00057         b0 -= 1.0e0;
00058         c *= (b0/(a0+b0));
00059     }
00060     u = log(c)+u;
00061 S60:
00062     z = *a*log(*x)-u;
00063     b0 -= 1.0e0;
00064     apb = a0+b0;
00065     if(apb > 1.0e0) goto S70;
00066     t = 1.0e0+gam1(&apb);
00067     goto S80;
00068 S70:
00069     u = a0+b0-1.e0;
00070     t = (1.0e0+gam1(&u))/apb;
00071 S80:
00072     bpser = exp(z)*(a0/ *a)*(1.0e0+gam1(&b0))/t;
00073     goto S100;
00074 S90:
00075 /*
00076             PROCEDURE FOR A0 .LT. 1 AND B0 .GE. 8
00077 */
00078     u = gamln1(&a0)+algdiv(&a0,&b0);
00079     z = *a*log(*x)-u;
00080     bpser = a0/ *a*exp(z);
00081 S100:
00082     if(bpser == 0.0e0 || *a <= 0.1e0**eps) return bpser;
00083 /*
00084 -----------------------------------------------------------------------
00085                      COMPUTE THE SERIES
00086 -----------------------------------------------------------------------
00087 */
00088     sum = n = 0.0e0;
00089     c = 1.0e0;
00090     tol = *eps/ *a;
00091 S110:
00092     n += 1.0e0;
00093     c *= ((0.5e0+(0.5e0-*b/n))**x);
00094     w = c/(*a+n);
00095     sum += w;
00096     if(fabs(w) > tol) goto S110;
00097     bpser *= (1.0e0+*a*sum);
00098     return bpser;
00099 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_10.c. References a, apser(), basym(), bfrac(), bgrat(), bpser(), bup(), fifdmax1(), fifdmin1(), fpser(), ind, spmpar(), x0, and y0. Referenced by cumbet(), cumf(), and cumfnc(). 
 00038 {
00039 static int K1 = 1;
00040 static double a0,b0,eps,lambda,t,x0,y0,z;
00041 static int ierr1,ind,n;
00042 static double T2,T3,T4,T5;
00043 /*
00044      ..
00045      .. Executable Statements ..
00046 */
00047 /*
00048      ****** EPS IS A MACHINE DEPENDENT CONSTANT. EPS IS THE SMALLEST
00049             FLOATING POINT NUMBER FOR WHICH 1.0 + EPS .GT. 1.0
00050 */
00051     eps = spmpar(&K1);
00052     *w = *w1 = 0.0e0;
00053     if(*a < 0.0e0 || *b < 0.0e0) goto S270;
00054     if(*a == 0.0e0 && *b == 0.0e0) goto S280;
00055     if(*x < 0.0e0 || *x > 1.0e0) goto S290;
00056     if(*y < 0.0e0 || *y > 1.0e0) goto S300;
00057     z = *x+*y-0.5e0-0.5e0;
00058     if(fabs(z) > 3.0e0*eps) goto S310;
00059     *ierr = 0;
00060     if(*x == 0.0e0) goto S210;
00061     if(*y == 0.0e0) goto S230;
00062     if(*a == 0.0e0) goto S240;
00063     if(*b == 0.0e0) goto S220;
00064     eps = fifdmax1(eps,1.e-15);
00065     if(fifdmax1(*a,*b) < 1.e-3*eps) goto S260;
00066     ind = 0;
00067     a0 = *a;
00068     b0 = *b;
00069     x0 = *x;
00070     y0 = *y;
00071     if(fifdmin1(a0,b0) > 1.0e0) goto S40;
00072 /*
00073              PROCEDURE FOR A0 .LE. 1 OR B0 .LE. 1
00074 */
00075     if(*x <= 0.5e0) goto S10;
00076     ind = 1;
00077     a0 = *b;
00078     b0 = *a;
00079     x0 = *y;
00080     y0 = *x;
00081 S10:
00082     if(b0 < fifdmin1(eps,eps*a0)) goto S90;
00083     if(a0 < fifdmin1(eps,eps*b0) && b0*x0 <= 1.0e0) goto S100;
00084     if(fifdmax1(a0,b0) > 1.0e0) goto S20;
00085     if(a0 >= fifdmin1(0.2e0,b0)) goto S110;
00086     if(pow(x0,a0) <= 0.9e0) goto S110;
00087     if(x0 >= 0.3e0) goto S120;
00088     n = 20;
00089     goto S140;
00090 S20:
00091     if(b0 <= 1.0e0) goto S110;
00092     if(x0 >= 0.3e0) goto S120;
00093     if(x0 >= 0.1e0) goto S30;
00094     if(pow(x0*b0,a0) <= 0.7e0) goto S110;
00095 S30:
00096     if(b0 > 15.0e0) goto S150;
00097     n = 20;
00098     goto S140;
00099 S40:
00100 /*
00101              PROCEDURE FOR A0 .GT. 1 AND B0 .GT. 1
00102 */
00103     if(*a > *b) goto S50;
00104     lambda = *a-(*a+*b)**x;
00105     goto S60;
00106 S50:
00107     lambda = (*a+*b)**y-*b;
00108 S60:
00109     if(lambda >= 0.0e0) goto S70;
00110     ind = 1;
00111     a0 = *b;
00112     b0 = *a;
00113     x0 = *y;
00114     y0 = *x;
00115     lambda = fabs(lambda);
00116 S70:
00117     if(b0 < 40.0e0 && b0*x0 <= 0.7e0) goto S110;
00118     if(b0 < 40.0e0) goto S160;
00119     if(a0 > b0) goto S80;
00120     if(a0 <= 100.0e0) goto S130;
00121     if(lambda > 0.03e0*a0) goto S130;
00122     goto S200;
00123 S80:
00124     if(b0 <= 100.0e0) goto S130;
00125     if(lambda > 0.03e0*b0) goto S130;
00126     goto S200;
00127 S90:
00128 /*
00129             EVALUATION OF THE APPROPRIATE ALGORITHM
00130 */
00131     *w = fpser(&a0,&b0,&x0,&eps);
00132     *w1 = 0.5e0+(0.5e0-*w);
00133     goto S250;
00134 S100:
00135     *w1 = apser(&a0,&b0,&x0,&eps);
00136     *w = 0.5e0+(0.5e0-*w1);
00137     goto S250;
00138 S110:
00139     *w = bpser(&a0,&b0,&x0,&eps);
00140     *w1 = 0.5e0+(0.5e0-*w);
00141     goto S250;
00142 S120:
00143     *w1 = bpser(&b0,&a0,&y0,&eps);
00144     *w = 0.5e0+(0.5e0-*w1);
00145     goto S250;
00146 S130:
00147     T2 = 15.0e0*eps;
00148     *w = bfrac(&a0,&b0,&x0,&y0,&lambda,&T2);
00149     *w1 = 0.5e0+(0.5e0-*w);
00150     goto S250;
00151 S140:
00152     *w1 = bup(&b0,&a0,&y0,&x0,&n,&eps);
00153     b0 += (double)n;
00154 S150:
00155     T3 = 15.0e0*eps;
00156     bgrat(&b0,&a0,&y0,&x0,w1,&T3,&ierr1);
00157     *w = 0.5e0+(0.5e0-*w1);
00158     goto S250;
00159 S160:
00160     n = b0;
00161     b0 -= (double)n;
00162     if(b0 != 0.0e0) goto S170;
00163     n -= 1;
00164     b0 = 1.0e0;
00165 S170:
00166     *w = bup(&b0,&a0,&y0,&x0,&n,&eps);
00167     if(x0 > 0.7e0) goto S180;
00168     *w += bpser(&a0,&b0,&x0,&eps);
00169     *w1 = 0.5e0+(0.5e0-*w);
00170     goto S250;
00171 S180:
00172     if(a0 > 15.0e0) goto S190;
00173     n = 20;
00174     *w += bup(&a0,&b0,&x0,&y0,&n,&eps);
00175     a0 += (double)n;
00176 S190:
00177     T4 = 15.0e0*eps;
00178     bgrat(&a0,&b0,&x0,&y0,w,&T4,&ierr1);
00179     *w1 = 0.5e0+(0.5e0-*w);
00180     goto S250;
00181 S200:
00182     T5 = 100.0e0*eps;
00183     *w = basym(&a0,&b0,&lambda,&T5);
00184     *w1 = 0.5e0+(0.5e0-*w);
00185     goto S250;
00186 S210:
00187 /*
00188                TERMINATION OF THE PROCEDURE
00189 */
00190     if(*a == 0.0e0) goto S320;
00191 S220:
00192     *w = 0.0e0;
00193     *w1 = 1.0e0;
00194     return;
00195 S230:
00196     if(*b == 0.0e0) goto S330;
00197 S240:
00198     *w = 1.0e0;
00199     *w1 = 0.0e0;
00200     return;
00201 S250:
00202     if(ind == 0) return;
00203     t = *w;
00204     *w = *w1;
00205     *w1 = t;
00206     return;
00207 S260:
00208 /*
00209            PROCEDURE FOR A AND B .LT. 1.E-3*EPS
00210 */
00211     *w = *b/(*a+*b);
00212     *w1 = *a/(*a+*b);
00213     return;
00214 S270:
00215 /*
00216                        ERROR RETURN
00217 */
00218     *ierr = 1;
00219     return;
00220 S280:
00221     *ierr = 2;
00222     return;
00223 S290:
00224     *ierr = 3;
00225     return;
00226 S300:
00227     *ierr = 4;
00228     return;
00229 S310:
00230     *ierr = 5;
00231     return;
00232 S320:
00233     *ierr = 6;
00234     return;
00235 S330:
00236     *ierr = 7;
00237     return;
00238 } /* END */
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_11.c. References a, algdiv(), alnrel(), bcorr(), betaln(), brcmp1(), c, esum(), fifdmax1(), fifdmin1(), gam1(), gamln1(), i, rlog1(), v, x0, and y0. Referenced by brcmp1(), and bup(). 
 00008 {
00009 static double Const = .398942280401433e0;
00010 static double brcmp1,a0,apb,b0,c,e,h,lambda,lnx,lny,t,u,v,x0,y0,z;
00011 static int i,n;
00012 /*
00013 -----------------
00014      CONST = 1/SQRT(2*PI)
00015 -----------------
00016 */
00017 static double T1,T2,T3,T4;
00018 /*
00019      ..
00020      .. Executable Statements ..
00021 */
00022     a0 = fifdmin1(*a,*b);
00023     if(a0 >= 8.0e0) goto S130;
00024     if(*x > 0.375e0) goto S10;
00025     lnx = log(*x);
00026     T1 = -*x;
00027     lny = alnrel(&T1);
00028     goto S30;
00029 S10:
00030     if(*y > 0.375e0) goto S20;
00031     T2 = -*y;
00032     lnx = alnrel(&T2);
00033     lny = log(*y);
00034     goto S30;
00035 S20:
00036     lnx = log(*x);
00037     lny = log(*y);
00038 S30:
00039     z = *a*lnx+*b*lny;
00040     if(a0 < 1.0e0) goto S40;
00041     z -= betaln(a,b);
00042     brcmp1 = esum(mu,&z);
00043     return brcmp1;
00044 S40:
00045 /*
00046 -----------------------------------------------------------------------
00047               PROCEDURE FOR A .LT. 1 OR B .LT. 1
00048 -----------------------------------------------------------------------
00049 */
00050     b0 = fifdmax1(*a,*b);
00051     if(b0 >= 8.0e0) goto S120;
00052     if(b0 > 1.0e0) goto S70;
00053 /*
00054                    ALGORITHM FOR B0 .LE. 1
00055 */
00056     brcmp1 = esum(mu,&z);
00057     if(brcmp1 == 0.0e0) return brcmp1;
00058     apb = *a+*b;
00059     if(apb > 1.0e0) goto S50;
00060     z = 1.0e0+gam1(&apb);
00061     goto S60;
00062 S50:
00063     u = *a+*b-1.e0;
00064     z = (1.0e0+gam1(&u))/apb;
00065 S60:
00066     c = (1.0e0+gam1(a))*(1.0e0+gam1(b))/z;
00067     brcmp1 = brcmp1*(a0*c)/(1.0e0+a0/b0);
00068     return brcmp1;
00069 S70:
00070 /*
00071                 ALGORITHM FOR 1 .LT. B0 .LT. 8
00072 */
00073     u = gamln1(&a0);
00074     n = b0-1.0e0;
00075     if(n < 1) goto S90;
00076     c = 1.0e0;
00077     for(i=1; i<=n; i++) {
00078         b0 -= 1.0e0;
00079         c *= (b0/(a0+b0));
00080     }
00081     u = log(c)+u;
00082 S90:
00083     z -= u;
00084     b0 -= 1.0e0;
00085     apb = a0+b0;
00086     if(apb > 1.0e0) goto S100;
00087     t = 1.0e0+gam1(&apb);
00088     goto S110;
00089 S100:
00090     u = a0+b0-1.e0;
00091     t = (1.0e0+gam1(&u))/apb;
00092 S110:
00093     brcmp1 = a0*esum(mu,&z)*(1.0e0+gam1(&b0))/t;
00094     return brcmp1;
00095 S120:
00096 /*
00097                    ALGORITHM FOR B0 .GE. 8
00098 */
00099     u = gamln1(&a0)+algdiv(&a0,&b0);
00100     T3 = z-u;
00101     brcmp1 = a0*esum(mu,&T3);
00102     return brcmp1;
00103 S130:
00104 /*
00105 -----------------------------------------------------------------------
00106               PROCEDURE FOR A .GE. 8 AND B .GE. 8
00107 -----------------------------------------------------------------------
00108 */
00109     if(*a > *b) goto S140;
00110     h = *a/ *b;
00111     x0 = h/(1.0e0+h);
00112     y0 = 1.0e0/(1.0e0+h);
00113     lambda = *a-(*a+*b)**x;
00114     goto S150;
00115 S140:
00116     h = *b/ *a;
00117     x0 = 1.0e0/(1.0e0+h);
00118     y0 = h/(1.0e0+h);
00119     lambda = (*a+*b)**y-*b;
00120 S150:
00121     e = -(lambda/ *a);
00122     if(fabs(e) > 0.6e0) goto S160;
00123     u = rlog1(&e);
00124     goto S170;
00125 S160:
00126     u = e-log(*x/x0);
00127 S170:
00128     e = lambda/ *b;
00129     if(fabs(e) > 0.6e0) goto S180;
00130     v = rlog1(&e);
00131     goto S190;
00132 S180:
00133     v = e-log(*y/y0);
00134 S190:
00135     T4 = -(*a*u+*b*v);
00136     z = esum(mu,&T4);
00137     brcmp1 = Const*sqrt(*b*x0)*z*exp(-bcorr(a,b));
00138     return brcmp1;
00139 } /* END */
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 2 of file cdf_12.c. References a, algdiv(), alnrel(), bcorr(), betaln(), brcomp(), c, fifdmax1(), fifdmin1(), gam1(), gamln1(), i, rlog1(), v, x0, and y0. Referenced by bfrac(), and brcomp(). 
 00008 {
00009 static double Const = .398942280401433e0;
00010 static double brcomp,a0,apb,b0,c,e,h,lambda,lnx,lny,t,u,v,x0,y0,z;
00011 static int i,n;
00012 /*
00013 -----------------
00014      CONST = 1/SQRT(2*PI)
00015 -----------------
00016 */
00017 static double T1,T2;
00018 /*
00019      ..
00020      .. Executable Statements ..
00021 */
00022     brcomp = 0.0e0;
00023     if(*x == 0.0e0 || *y == 0.0e0) return brcomp;
00024     a0 = fifdmin1(*a,*b);
00025     if(a0 >= 8.0e0) goto S130;
00026     if(*x > 0.375e0) goto S10;
00027     lnx = log(*x);
00028     T1 = -*x;
00029     lny = alnrel(&T1);
00030     goto S30;
00031 S10:
00032     if(*y > 0.375e0) goto S20;
00033     T2 = -*y;
00034     lnx = alnrel(&T2);
00035     lny = log(*y);
00036     goto S30;
00037 S20:
00038     lnx = log(*x);
00039     lny = log(*y);
00040 S30:
00041     z = *a*lnx+*b*lny;
00042     if(a0 < 1.0e0) goto S40;
00043     z -= betaln(a,b);
00044     brcomp = exp(z);
00045     return brcomp;
00046 S40:
00047 /*
00048 -----------------------------------------------------------------------
00049               PROCEDURE FOR A .LT. 1 OR B .LT. 1
00050 -----------------------------------------------------------------------
00051 */
00052     b0 = fifdmax1(*a,*b);
00053     if(b0 >= 8.0e0) goto S120;
00054     if(b0 > 1.0e0) goto S70;
00055 /*
00056                    ALGORITHM FOR B0 .LE. 1
00057 */
00058     brcomp = exp(z);
00059     if(brcomp == 0.0e0) return brcomp;
00060     apb = *a+*b;
00061     if(apb > 1.0e0) goto S50;
00062     z = 1.0e0+gam1(&apb);
00063     goto S60;
00064 S50:
00065     u = *a+*b-1.e0;
00066     z = (1.0e0+gam1(&u))/apb;
00067 S60:
00068     c = (1.0e0+gam1(a))*(1.0e0+gam1(b))/z;
00069     brcomp = brcomp*(a0*c)/(1.0e0+a0/b0);
00070     return brcomp;
00071 S70:
00072 /*
00073                 ALGORITHM FOR 1 .LT. B0 .LT. 8
00074 */
00075     u = gamln1(&a0);
00076     n = b0-1.0e0;
00077     if(n < 1) goto S90;
00078     c = 1.0e0;
00079     for(i=1; i<=n; i++) {
00080         b0 -= 1.0e0;
00081         c *= (b0/(a0+b0));
00082     }
00083     u = log(c)+u;
00084 S90:
00085     z -= u;
00086     b0 -= 1.0e0;
00087     apb = a0+b0;
00088     if(apb > 1.0e0) goto S100;
00089     t = 1.0e0+gam1(&apb);
00090     goto S110;
00091 S100:
00092     u = a0+b0-1.e0;
00093     t = (1.0e0+gam1(&u))/apb;
00094 S110:
00095     brcomp = a0*exp(z)*(1.0e0+gam1(&b0))/t;
00096     return brcomp;
00097 S120:
00098 /*
00099                    ALGORITHM FOR B0 .GE. 8
00100 */
00101     u = gamln1(&a0)+algdiv(&a0,&b0);
00102     brcomp = a0*exp(z-u);
00103     return brcomp;
00104 S130:
00105 /*
00106 -----------------------------------------------------------------------
00107               PROCEDURE FOR A .GE. 8 AND B .GE. 8
00108 -----------------------------------------------------------------------
00109 */
00110     if(*a > *b) goto S140;
00111     h = *a/ *b;
00112     x0 = h/(1.0e0+h);
00113     y0 = 1.0e0/(1.0e0+h);
00114     lambda = *a-(*a+*b)**x;
00115     goto S150;
00116 S140:
00117     h = *b/ *a;
00118     x0 = 1.0e0/(1.0e0+h);
00119     y0 = h/(1.0e0+h);
00120     lambda = (*a+*b)**y-*b;
00121 S150:
00122     e = -(lambda/ *a);
00123     if(fabs(e) > 0.6e0) goto S160;
00124     u = rlog1(&e);
00125     goto S170;
00126 S160:
00127     u = e-log(*x/x0);
00128 S170:
00129     e = lambda/ *b;
00130     if(fabs(e) > 0.6e0) goto S180;
00131     v = rlog1(&e);
00132     goto S190;
00133 S180:
00134     v = e-log(*y/y0);
00135 S190:
00136     z = exp(-(*a*u+*b*v));
00137     brcomp = Const*sqrt(*b*x0)*z*exp(-bcorr(a,b));
00138     return brcomp;
00139 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_13.c. References a, brcmp1(), bup(), exparg(), i, l, and r. Referenced by bratio(), and bup(). 
 00009 {
00010 static int K1 = 1;
00011 static int K2 = 0;
00012 static double bup,ap1,apb,d,l,r,t,w;
00013 static int i,k,kp1,mu,nm1;
00014 /*
00015      ..
00016      .. Executable Statements ..
00017 */
00018 /*
00019           OBTAIN THE SCALING FACTOR EXP(-MU) AND
00020              EXP(MU)*(X**A*Y**B/BETA(A,B))/A
00021 */
00022     apb = *a+*b;
00023     ap1 = *a+1.0e0;
00024     mu = 0;
00025     d = 1.0e0;
00026     if(*n == 1 || *a < 1.0e0) goto S10;
00027     if(apb < 1.1e0*ap1) goto S10;
00028     mu = fabs(exparg(&K1));
00029     k = exparg(&K2);
00030     if(k < mu) mu = k;
00031     t = mu;
00032     d = exp(-t);
00033 S10:
00034     bup = brcmp1(&mu,a,b,x,y)/ *a;
00035     if(*n == 1 || bup == 0.0e0) return bup;
00036     nm1 = *n-1;
00037     w = d;
00038 /*
00039           LET K BE THE INDEX OF THE MAXIMUM TERM
00040 */
00041     k = 0;
00042     if(*b <= 1.0e0) goto S50;
00043     if(*y > 1.e-4) goto S20;
00044     k = nm1;
00045     goto S30;
00046 S20:
00047     r = (*b-1.0e0)**x/ *y-*a;
00048     if(r < 1.0e0) goto S50;
00049     k = t = nm1;
00050     if(r < t) k = r;
00051 S30:
00052 /*
00053           ADD THE INCREASING TERMS OF THE SERIES
00054 */
00055     for(i=1; i<=k; i++) {
00056         l = i-1;
00057         d = (apb+l)/(ap1+l)**x*d;
00058         w += d;
00059     }
00060     if(k == nm1) goto S70;
00061 S50:
00062 /*
00063           ADD THE REMAINING TERMS OF THE SERIES
00064 */
00065     kp1 = k+1;
00066     for(i=kp1; i<=nm1; i++) {
00067         l = i-1;
00068         d = (apb+l)/(ap1+l)**x*d;
00069         w += d;
00070         if(d <= *eps*w) goto S70;
00071     }
00072 S70:
00073 /*
00074                TERMINATE THE PROCEDURE
00075 */
00076     bup *= w;
00077     return bup;
00078 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_14.c. References a, cumbet(), dinvr(), dstinv(), dstzr(), dzror(), p, q, and spmpar(). Referenced by beta_p2t(), and beta_t2p(). 
 00025 : 1..4 00026 iwhich = 1 : Calculate P and Q from X,Y,A and B 00027 iwhich = 2 : Calculate X and Y from P,Q,A and B 00028 iwhich = 3 : Calculate A from P,Q,X,Y and B 00029 iwhich = 4 : Calculate B from P,Q,X,Y and A 00030 00031 P <--> The integral from 0 to X of the chi-square 00032 distribution. 00033 Input range: [0, 1]. 00034 00035 Q <--> 1-P. 00036 Input range: [0, 1]. 00037 P + Q = 1.0. 00038 00039 X <--> Upper limit of integration of beta density. 00040 Input range: [0,1]. 00041 Search range: [0,1] 00042 00043 Y <--> 1-X. 00044 Input range: [0,1]. 00045 Search range: [0,1] 00046 X + Y = 1.0. 00047 00048 A <--> The first parameter of the beta density. 00049 Input range: (0, +infinity). 00050 Search range: [1D-300,1D300] 00051 00052 B <--> The second parameter of the beta density. 00053 Input range: (0, +infinity). 00054 Search range: [1D-300,1D300] 00055 00056 STATUS <-- 0 if calculation completed correctly 00057 -I if input parameter number I is out of range 00058 1 if answer appears to be lower than lowest 00059 search bound 00060 2 if answer appears to be higher than greatest 00061 search bound 00062 3 if P + Q .ne. 1 00063 4 if X + Y .ne. 1 00064 00065 BOUND <-- Undefined if STATUS is 0 00066 00067 Bound exceeded by parameter number I if STATUS 00068 is negative. 00069 00070 Lower search bound if STATUS is 1. 00071 00072 Upper search bound if STATUS is 2. 00073 00074 00075 Method 00076 00077 00078 Cumulative distribution function (P) is calculated directly by 00079 code associated with the following reference. 00080 00081 DiDinato, A. R. and Morris, A. H. Algorithm 708: Significant 00082 Digit Computation of the Incomplete Beta Function Ratios. ACM 00083 Trans. Math. Softw. 18 (1993), 360-373. 00084 00085 Computation of other parameters involve a seach for a value that 00086 produces the desired value of P. The search relies on the 00087 monotinicity of P with the other parameter. 00088 00089 00090 Note 00091 00092 00093 The beta density is proportional to 00094 t^(A-1) * (1-t)^(B-1) 00095 00096 **********************************************************************/ 00097 { 00098 #define tol (1.0e-8) 00099 #define atol (1.0e-50) 00100 #define zero (1.0e-300) 00101 #define inf 1.0e300 00102 #define one 1.0e0 00103 static int K1 = 1; 00104 static double K2 = 0.0e0; 00105 static double K3 = 1.0e0; 00106 static double K8 = 0.5e0; 00107 static double K9 = 5.0e0; 00108 static double fx,xhi,xlo,cum,ccum,xy,pq; 00109 static unsigned long qhi,qleft,qporq; 00110 static double T4,T5,T6,T7,T10,T11,T12,T13,T14,T15; 00111 /* 00112 .. 00113 .. Executable Statements .. 00114 */ 00115 /* 00116 Check arguments 00117 */ 00118 if(!(*which < 1 || *which > 4)) goto S30; 00119 if(!(*which < 1)) goto S10; 00120 *bound = 1.0e0; 00121 goto S20; 00122 S10: 00123 *bound = 4.0e0; 00124 S20: 00125 *status = -1; 00126 return; 00127 S30: 00128 if(*which == 1) goto S70; 00129 /* 00130 P 00131 */ 00132 if(!(*p < 0.0e0 || *p > 1.0e0)) goto S60; 00133 if(!(*p < 0.0e0)) goto S40; 00134 *bound = 0.0e0; 00135 goto S50; 00136 S40: 00137 *bound = 1.0e0; 00138 S50: 00139 *status = -2; 00140 return; 00141 S70: 00142 S60: 00143 if(*which == 1) goto S110; 00144 /* 00145 Q 00146 */ 00147 if(!(*q < 0.0e0 || *q > 1.0e0)) goto S100; 00148 if(!(*q < 0.0e0)) goto S80; 00149 *bound = 0.0e0; 00150 goto S90; 00151 S80: 00152 *bound = 1.0e0; 00153 S90: 00154 *status = -3; 00155 return; 00156 S110: 00157 S100: 00158 if(*which == 2) goto S150; 00159 /* 00160 X 00161 */ 00162 if(!(*x < 0.0e0 || *x > 1.0e0)) goto S140; 00163 if(!(*x < 0.0e0)) goto S120; 00164 *bound = 0.0e0; 00165 goto S130; 00166 S120: 00167 *bound = 1.0e0; 00168 S130: 00169 *status = -4; 00170 return; 00171 S150: 00172 S140: 00173 if(*which == 2) goto S190; 00174 /* 00175 Y 00176 */ 00177 if(!(*y < 0.0e0 || *y > 1.0e0)) goto S180; 00178 if(!(*y < 0.0e0)) goto S160; 00179 *bound = 0.0e0; 00180 goto S170; 00181 S160: 00182 *bound = 1.0e0; 00183 S170: 00184 *status = -5; 00185 return; 00186 S190: 00187 S180: 00188 if(*which == 3) goto S210; 00189 /* 00190 A 00191 */ 00192 if(!(*a <= 0.0e0)) goto S200; 00193 *bound = 0.0e0; 00194 *status = -6; 00195 return; 00196 S210: 00197 S200: 00198 if(*which == 4) goto S230; 00199 /* 00200 B 00201 */ 00202 if(!(*b <= 0.0e0)) goto S220; 00203 *bound = 0.0e0; 00204 *status = -7; 00205 return; 00206 S230: 00207 S220: 00208 if(*which == 1) goto S270; 00209 /* 00210 P + Q 00211 */ 00212 pq = *p+*q; 00213 if(!(fabs(pq-0.5e0-0.5e0) > 3.0e0*spmpar(&K1))) goto S260; 00214 if(!(pq < 0.0e0)) goto S240; 00215 *bound = 0.0e0; 00216 goto S250; 00217 S240: 00218 *bound = 1.0e0; 00219 S250: 00220 *status = 3; 00221 return; 00222 S270: 00223 S260: 00224 if(*which == 2) goto S310; 00225 /* 00226 X + Y 00227 */ 00228 xy = *x+*y; 00229 if(!(fabs(xy-0.5e0-0.5e0) > 3.0e0*spmpar(&K1))) goto S300; 00230 if(!(xy < 0.0e0)) goto S280; 00231 *bound = 0.0e0; 00232 goto S290; 00233 S280: 00234 *bound = 1.0e0; 00235 S290: 00236 *status = 4; 00237 return; 00238 S310: 00239 S300: 00240 if(!(*which == 1)) qporq = *p <= *q; 00241 /* 00242 Select the minimum of P or Q 00243 Calculate ANSWERS 00244 */ 00245 if(1 == *which) { 00246 /* 00247 Calculating P and Q 00248 */ 00249 cumbet(x,y,a,b,p,q); 00250 *status = 0; 00251 } 00252 else if(2 == *which) { 00253 /* 00254 Calculating X and Y 00255 */ 00256 T4 = atol; 00257 T5 = tol; 00258 dstzr(&K2,&K3,&T4,&T5); 00259 if(!qporq) goto S340; 00260 *status = 0; 00261 dzror(status,x,&fx,&xlo,&xhi,&qleft,&qhi); 00262 *y = one-*x; 00263 S320: 00264 if(!(*status == 1)) goto S330; 00265 cumbet(x,y,a,b,&cum,&ccum); 00266 fx = cum-*p; 00267 dzror(status,x,&fx,&xlo,&xhi,&qleft,&qhi); 00268 *y = one-*x; 00269 goto S320; 00270 S330: 00271 goto S370; 00272 S340: 00273 *status = 0; 00274 dzror(status,y,&fx,&xlo,&xhi,&qleft,&qhi); 00275 *x = one-*y; 00276 S350: 00277 if(!(*status == 1)) goto S360; 00278 cumbet(x,y,a,b,&cum,&ccum); 00279 fx = ccum-*q; 00280 dzror(status,y,&fx,&xlo,&xhi,&qleft,&qhi); 00281 *x = one-*y; 00282 goto S350; 00283 S370: 00284 S360: 00285 if(!(*status == -1)) goto S400; 00286 if(!qleft) goto S380; 00287 *status = 1; 00288 *bound = 0.0e0; 00289 goto S390; 00290 S380: 00291 *status = 2; 00292 *bound = 1.0e0; 00293 S400: 00294 S390: 00295 ; 00296 } 00297 else if(3 == *which) { 00298 /* 00299 Computing A 00300 */ 00301 *a = 5.0e0; 00302 T6 = zero; 00303 T7 = inf; 00304 T10 = atol; 00305 T11 = tol; 00306 dstinv(&T6,&T7,&K8,&K8,&K9,&T10,&T11); 00307 *status = 0; 00308 dinvr(status,a,&fx,&qleft,&qhi); 00309 S410: 00310 if(!(*status == 1)) goto S440; 00311 cumbet(x,y,a,b,&cum,&ccum); 00312 if(!qporq) goto S420; 00313 fx = cum-*p; 00314 goto S430; 00315 S420: 00316 fx = ccum-*q; 00317 S430: 00318 dinvr(status,a,&fx,&qleft,&qhi); 00319 goto S410; 00320 S440: 00321 if(!(*status == -1)) goto S470; 00322 if(!qleft) goto S450; 00323 *status = 1; 00324 *bound = zero; 00325 goto S460; 00326 S450: 00327 *status = 2; 00328 *bound = inf; 00329 S470: 00330 S460: 00331 ; 00332 } 00333 else if(4 == *which) { 00334 /* 00335 Computing B 00336 */ 00337 *b = 5.0e0; 00338 T12 = zero; 00339 T13 = inf; 00340 T14 = atol; 00341 T15 = tol; 00342 dstinv(&T12,&T13,&K8,&K8,&K9,&T14,&T15); 00343 *status = 0; 00344 dinvr(status,b,&fx,&qleft,&qhi); 00345 S480: 00346 if(!(*status == 1)) goto S510; 00347 cumbet(x,y,a,b,&cum,&ccum); 00348 if(!qporq) goto S490; 00349 fx = cum-*p; 00350 goto S500; 00351 S490: 00352 fx = ccum-*q; 00353 S500: 00354 dinvr(status,b,&fx,&qleft,&qhi); 00355 goto S480; 00356 S510: 00357 if(!(*status == -1)) goto S540; 00358 if(!qleft) goto S520; 00359 *status = 1; 00360 *bound = zero; 00361 goto S530; 00362 S520: 00363 *status = 2; 00364 *bound = inf; 00365 S530: 00366 ; 00367 } 00368 S540: 00369 return; 00370 #undef tol 00371 #undef atol 00372 #undef zero 00373 #undef inf 00374 #undef one 00375 } /* END */ | 
| 
 | ||||||||||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_15.c. References cumbin(), dinvr(), dstinv(), dstzr(), dzror(), p, q, spmpar(), and xn. Referenced by binomial_p2t(), and binomial_t2p(). 
 00025 : 1..4 00026 iwhich = 1 : Calculate P and Q from S,XN,PR and OMPR 00027 iwhich = 2 : Calculate S from P,Q,XN,PR and OMPR 00028 iwhich = 3 : Calculate XN from P,Q,S,PR and OMPR 00029 iwhich = 4 : Calculate PR and OMPR from P,Q,S and XN 00030 00031 P <--> The cumulation from 0 to S of the binomial distribution. 00032 (Probablility of S or fewer successes in XN trials each 00033 with probability of success PR.) 00034 Input range: [0,1]. 00035 00036 Q <--> 1-P. 00037 Input range: [0, 1]. 00038 P + Q = 1.0. 00039 00040 S <--> The number of successes observed. 00041 Input range: [0, XN] 00042 Search range: [0, XN] 00043 00044 XN <--> The number of binomial trials. 00045 Input range: (0, +infinity). 00046 Search range: [1E-300, 1E300] 00047 00048 PR <--> The probability of success in each binomial trial. 00049 Input range: [0,1]. 00050 Search range: [0,1] 00051 00052 OMPR <--> 1-PR 00053 Input range: [0,1]. 00054 Search range: [0,1] 00055 PR + OMPR = 1.0 00056 00057 STATUS <-- 0 if calculation completed correctly 00058 -I if input parameter number I is out of range 00059 1 if answer appears to be lower than lowest 00060 search bound 00061 2 if answer appears to be higher than greatest 00062 search bound 00063 3 if P + Q .ne. 1 00064 4 if PR + OMPR .ne. 1 00065 00066 BOUND <-- Undefined if STATUS is 0 00067 00068 Bound exceeded by parameter number I if STATUS 00069 is negative. 00070 00071 Lower search bound if STATUS is 1. 00072 00073 Upper search bound if STATUS is 2. 00074 00075 00076 Method 00077 00078 00079 Formula 26.5.24 of Abramowitz and Stegun, Handbook of 00080 Mathematical Functions (1966) is used to reduce the binomial 00081 distribution to the cumulative incomplete beta distribution. 00082 00083 Computation of other parameters involve a seach for a value that 00084 produces the desired value of P. The search relies on the 00085 monotinicity of P with the other parameter. 00086 00087 00088 **********************************************************************/ 00089 { 00090 #define atol (1.0e-50) 00091 #define tol (1.0e-8) 00092 #define zero (1.0e-300) 00093 #define inf 1.0e300 00094 #define one 1.0e0 00095 static int K1 = 1; 00096 static double K2 = 0.0e0; 00097 static double K3 = 0.5e0; 00098 static double K4 = 5.0e0; 00099 static double K11 = 1.0e0; 00100 static double fx,xhi,xlo,cum,ccum,pq,prompr; 00101 static unsigned long qhi,qleft,qporq; 00102 static double T5,T6,T7,T8,T9,T10,T12,T13; 00103 /* 00104 .. 00105 .. Executable Statements .. 00106 */ 00107 /* 00108 Check arguments 00109 */ 00110 if(!(*which < 1 && *which > 4)) goto S30; 00111 if(!(*which < 1)) goto S10; 00112 *bound = 1.0e0; 00113 goto S20; 00114 S10: 00115 *bound = 4.0e0; 00116 S20: 00117 *status = -1; 00118 return; 00119 S30: 00120 if(*which == 1) goto S70; 00121 /* 00122 P 00123 */ 00124 if(!(*p < 0.0e0 || *p > 1.0e0)) goto S60; 00125 if(!(*p < 0.0e0)) goto S40; 00126 *bound = 0.0e0; 00127 goto S50; 00128 S40: 00129 *bound = 1.0e0; 00130 S50: 00131 *status = -2; 00132 return; 00133 S70: 00134 S60: 00135 if(*which == 1) goto S110; 00136 /* 00137 Q 00138 */ 00139 if(!(*q < 0.0e0 || *q > 1.0e0)) goto S100; 00140 if(!(*q < 0.0e0)) goto S80; 00141 *bound = 0.0e0; 00142 goto S90; 00143 S80: 00144 *bound = 1.0e0; 00145 S90: 00146 *status = -3; 00147 return; 00148 S110: 00149 S100: 00150 if(*which == 3) goto S130; 00151 /* 00152 XN 00153 */ 00154 if(!(*xn <= 0.0e0)) goto S120; 00155 *bound = 0.0e0; 00156 *status = -5; 00157 return; 00158 S130: 00159 S120: 00160 if(*which == 2) goto S170; 00161 /* 00162 S 00163 */ 00164 if(!(*s < 0.0e0 || *which != 3 && *s > *xn)) goto S160; 00165 if(!(*s < 0.0e0)) goto S140; 00166 *bound = 0.0e0; 00167 goto S150; 00168 S140: 00169 *bound = *xn; 00170 S150: 00171 *status = -4; 00172 return; 00173 S170: 00174 S160: 00175 if(*which == 4) goto S210; 00176 /* 00177 PR 00178 */ 00179 if(!(*pr < 0.0e0 || *pr > 1.0e0)) goto S200; 00180 if(!(*pr < 0.0e0)) goto S180; 00181 *bound = 0.0e0; 00182 goto S190; 00183 S180: 00184 *bound = 1.0e0; 00185 S190: 00186 *status = -6; 00187 return; 00188 S210: 00189 S200: 00190 if(*which == 4) goto S250; 00191 /* 00192 OMPR 00193 */ 00194 if(!(*ompr < 0.0e0 || *ompr > 1.0e0)) goto S240; 00195 if(!(*ompr < 0.0e0)) goto S220; 00196 *bound = 0.0e0; 00197 goto S230; 00198 S220: 00199 *bound = 1.0e0; 00200 S230: 00201 *status = -7; 00202 return; 00203 S250: 00204 S240: 00205 if(*which == 1) goto S290; 00206 /* 00207 P + Q 00208 */ 00209 pq = *p+*q; 00210 if(!(fabs(pq-0.5e0-0.5e0) > 3.0e0*spmpar(&K1))) goto S280; 00211 if(!(pq < 0.0e0)) goto S260; 00212 *bound = 0.0e0; 00213 goto S270; 00214 S260: 00215 *bound = 1.0e0; 00216 S270: 00217 *status = 3; 00218 return; 00219 S290: 00220 S280: 00221 if(*which == 4) goto S330; 00222 /* 00223 PR + OMPR 00224 */ 00225 prompr = *pr+*ompr; 00226 if(!(fabs(prompr-0.5e0-0.5e0) > 3.0e0*spmpar(&K1))) goto S320; 00227 if(!(prompr < 0.0e0)) goto S300; 00228 *bound = 0.0e0; 00229 goto S310; 00230 S300: 00231 *bound = 1.0e0; 00232 S310: 00233 *status = 4; 00234 return; 00235 S330: 00236 S320: 00237 if(!(*which == 1)) qporq = *p <= *q; 00238 /* 00239 Select the minimum of P or Q 00240 Calculate ANSWERS 00241 */ 00242 if(1 == *which) { 00243 /* 00244 Calculating P 00245 */ 00246 cumbin(s,xn,pr,ompr,p,q); 00247 *status = 0; 00248 } 00249 else if(2 == *which) { 00250 /* 00251 Calculating S 00252 */ 00253 *s = 5.0e0; 00254 T5 = atol; 00255 T6 = tol; 00256 dstinv(&K2,xn,&K3,&K3,&K4,&T5,&T6); 00257 *status = 0; 00258 dinvr(status,s,&fx,&qleft,&qhi); 00259 S340: 00260 if(!(*status == 1)) goto S370; 00261 cumbin(s,xn,pr,ompr,&cum,&ccum); 00262 if(!qporq) goto S350; 00263 fx = cum-*p; 00264 goto S360; 00265 S350: 00266 fx = ccum-*q; 00267 S360: 00268 dinvr(status,s,&fx,&qleft,&qhi); 00269 goto S340; 00270 S370: 00271 if(!(*status == -1)) goto S400; 00272 if(!qleft) goto S380; 00273 *status = 1; 00274 *bound = 0.0e0; 00275 goto S390; 00276 S380: 00277 *status = 2; 00278 *bound = *xn; 00279 S400: 00280 S390: 00281 ; 00282 } 00283 else if(3 == *which) { 00284 /* 00285 Calculating XN 00286 */ 00287 *xn = 5.0e0; 00288 T7 = zero; 00289 T8 = inf; 00290 T9 = atol; 00291 T10 = tol; 00292 dstinv(&T7,&T8,&K3,&K3,&K4,&T9,&T10); 00293 *status = 0; 00294 dinvr(status,xn,&fx,&qleft,&qhi); 00295 S410: 00296 if(!(*status == 1)) goto S440; 00297 cumbin(s,xn,pr,ompr,&cum,&ccum); 00298 if(!qporq) goto S420; 00299 fx = cum-*p; 00300 goto S430; 00301 S420: 00302 fx = ccum-*q; 00303 S430: 00304 dinvr(status,xn,&fx,&qleft,&qhi); 00305 goto S410; 00306 S440: 00307 if(!(*status == -1)) goto S470; 00308 if(!qleft) goto S450; 00309 *status = 1; 00310 *bound = zero; 00311 goto S460; 00312 S450: 00313 *status = 2; 00314 *bound = inf; 00315 S470: 00316 S460: 00317 ; 00318 } 00319 else if(4 == *which) { 00320 /* 00321 Calculating PR and OMPR 00322 */ 00323 T12 = atol; 00324 T13 = tol; 00325 dstzr(&K2,&K11,&T12,&T13); 00326 if(!qporq) goto S500; 00327 *status = 0; 00328 dzror(status,pr,&fx,&xlo,&xhi,&qleft,&qhi); 00329 *ompr = one-*pr; 00330 S480: 00331 if(!(*status == 1)) goto S490; 00332 cumbin(s,xn,pr,ompr,&cum,&ccum); 00333 fx = cum-*p; 00334 dzror(status,pr,&fx,&xlo,&xhi,&qleft,&qhi); 00335 *ompr = one-*pr; 00336 goto S480; 00337 S490: 00338 goto S530; 00339 S500: 00340 *status = 0; 00341 dzror(status,ompr,&fx,&xlo,&xhi,&qleft,&qhi); 00342 *pr = one-*ompr; 00343 S510: 00344 if(!(*status == 1)) goto S520; 00345 cumbin(s,xn,pr,ompr,&cum,&ccum); 00346 fx = ccum-*q; 00347 dzror(status,ompr,&fx,&xlo,&xhi,&qleft,&qhi); 00348 *pr = one-*ompr; 00349 goto S510; 00350 S530: 00351 S520: 00352 if(!(*status == -1)) goto S560; 00353 if(!qleft) goto S540; 00354 *status = 1; 00355 *bound = 0.0e0; 00356 goto S550; 00357 S540: 00358 *status = 2; 00359 *bound = 1.0e0; 00360 S550: 00361 ; 00362 } 00363 S560: 00364 return; 00365 #undef atol 00366 #undef tol 00367 #undef zero 00368 #undef inf 00369 #undef one 00370 } /* END */ | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_16.c. References cumchi(), dinvr(), dstinv(), p, q, and spmpar(). Referenced by chisq_p2t(), and chisq_t2p(). 
 00025 : 1..3 00026 iwhich = 1 : Calculate P and Q from X and DF 00027 iwhich = 2 : Calculate X from P,Q and DF 00028 iwhich = 3 : Calculate DF from P,Q and X 00029 00030 P <--> The integral from 0 to X of the chi-square 00031 distribution. 00032 Input range: [0, 1]. 00033 00034 Q <--> 1-P. 00035 Input range: (0, 1]. 00036 P + Q = 1.0. 00037 00038 X <--> Upper limit of integration of the non-central 00039 chi-square distribution. 00040 Input range: [0, +infinity). 00041 Search range: [0,1E300] 00042 00043 DF <--> Degrees of freedom of the 00044 chi-square distribution. 00045 Input range: (0, +infinity). 00046 Search range: [ 1E-300, 1E300] 00047 00048 STATUS <-- 0 if calculation completed correctly 00049 -I if input parameter number I is out of range 00050 1 if answer appears to be lower than lowest 00051 search bound 00052 2 if answer appears to be higher than greatest 00053 search bound 00054 3 if P + Q .ne. 1 00055 10 indicates error returned from cumgam. See 00056 references in cdfgam 00057 00058 BOUND <-- Undefined if STATUS is 0 00059 00060 Bound exceeded by parameter number I if STATUS 00061 is negative. 00062 00063 Lower search bound if STATUS is 1. 00064 00065 Upper search bound if STATUS is 2. 00066 00067 00068 Method 00069 00070 00071 Formula 26.4.19 of Abramowitz and Stegun, Handbook of 00072 Mathematical Functions (1966) is used to reduce the chisqure 00073 distribution to the incomplete distribution. 00074 00075 Computation of other parameters involve a seach for a value that 00076 produces the desired value of P. The search relies on the 00077 monotinicity of P with the other parameter. 00078 00079 **********************************************************************/ 00080 { 00081 #define tol (1.0e-8) 00082 #define atol (1.0e-50) 00083 #define zero (1.0e-300) 00084 #define inf 1.0e300 00085 static int K1 = 1; 00086 static double K2 = 0.0e0; 00087 static double K4 = 0.5e0; 00088 static double K5 = 5.0e0; 00089 static double fx,cum,ccum,pq,porq; 00090 static unsigned long qhi,qleft,qporq; 00091 static double T3,T6,T7,T8,T9,T10,T11; 00092 /* 00093 .. 00094 .. Executable Statements .. 00095 */ 00096 /* 00097 Check arguments 00098 */ 00099 if(!(*which < 1 || *which > 3)) goto S30; 00100 if(!(*which < 1)) goto S10; 00101 *bound = 1.0e0; 00102 goto S20; 00103 S10: 00104 *bound = 3.0e0; 00105 S20: 00106 *status = -1; 00107 return; 00108 S30: 00109 if(*which == 1) goto S70; 00110 /* 00111 P 00112 */ 00113 if(!(*p < 0.0e0 || *p > 1.0e0)) goto S60; 00114 if(!(*p < 0.0e0)) goto S40; 00115 *bound = 0.0e0; 00116 goto S50; 00117 S40: 00118 *bound = 1.0e0; 00119 S50: 00120 *status = -2; 00121 return; 00122 S70: 00123 S60: 00124 if(*which == 1) goto S110; 00125 /* 00126 Q 00127 */ 00128 if(!(*q <= 0.0e0 || *q > 1.0e0)) goto S100; 00129 if(!(*q <= 0.0e0)) goto S80; 00130 *bound = 0.0e0; 00131 goto S90; 00132 S80: 00133 *bound = 1.0e0; 00134 S90: 00135 *status = -3; 00136 return; 00137 S110: 00138 S100: 00139 if(*which == 2) goto S130; 00140 /* 00141 X 00142 */ 00143 if(!(*x < 0.0e0)) goto S120; 00144 *bound = 0.0e0; 00145 *status = -4; 00146 return; 00147 S130: 00148 S120: 00149 if(*which == 3) goto S150; 00150 /* 00151 DF 00152 */ 00153 if(!(*df <= 0.0e0)) goto S140; 00154 *bound = 0.0e0; 00155 *status = -5; 00156 return; 00157 S150: 00158 S140: 00159 if(*which == 1) goto S190; 00160 /* 00161 P + Q 00162 */ 00163 pq = *p+*q; 00164 if(!(fabs(pq-0.5e0-0.5e0) > 3.0e0*spmpar(&K1))) goto S180; 00165 if(!(pq < 0.0e0)) goto S160; 00166 *bound = 0.0e0; 00167 goto S170; 00168 S160: 00169 *bound = 1.0e0; 00170 S170: 00171 *status = 3; 00172 return; 00173 S190: 00174 S180: 00175 if(*which == 1) goto S220; 00176 /* 00177 Select the minimum of P or Q 00178 */ 00179 qporq = *p <= *q; 00180 if(!qporq) goto S200; 00181 porq = *p; 00182 goto S210; 00183 S200: 00184 porq = *q; 00185 S220: 00186 S210: 00187 /* 00188 Calculate ANSWERS 00189 */ 00190 if(1 == *which) { 00191 /* 00192 Calculating P and Q 00193 */ 00194 *status = 0; 00195 cumchi(x,df,p,q); 00196 if(porq > 1.5e0) { 00197 *status = 10; 00198 return; 00199 } 00200 } 00201 else if(2 == *which) { 00202 /* 00203 Calculating X 00204 */ 00205 *x = 5.0e0; 00206 T3 = inf; 00207 T6 = atol; 00208 T7 = tol; 00209 dstinv(&K2,&T3,&K4,&K4,&K5,&T6,&T7); 00210 *status = 0; 00211 dinvr(status,x,&fx,&qleft,&qhi); 00212 S230: 00213 if(!(*status == 1)) goto S270; 00214 cumchi(x,df,&cum,&ccum); 00215 if(!qporq) goto S240; 00216 fx = cum-*p; 00217 goto S250; 00218 S240: 00219 fx = ccum-*q; 00220 S250: 00221 if(!(fx+porq > 1.5e0)) goto S260; 00222 *status = 10; 00223 return; 00224 S260: 00225 dinvr(status,x,&fx,&qleft,&qhi); 00226 goto S230; 00227 S270: 00228 if(!(*status == -1)) goto S300; 00229 if(!qleft) goto S280; 00230 *status = 1; 00231 *bound = 0.0e0; 00232 goto S290; 00233 S280: 00234 *status = 2; 00235 *bound = inf; 00236 S300: 00237 S290: 00238 ; 00239 } 00240 else if(3 == *which) { 00241 /* 00242 Calculating DF 00243 */ 00244 *df = 5.0e0; 00245 T8 = zero; 00246 T9 = inf; 00247 T10 = atol; 00248 T11 = tol; 00249 dstinv(&T8,&T9,&K4,&K4,&K5,&T10,&T11); 00250 *status = 0; 00251 dinvr(status,df,&fx,&qleft,&qhi); 00252 S310: 00253 if(!(*status == 1)) goto S350; 00254 cumchi(x,df,&cum,&ccum); 00255 if(!qporq) goto S320; 00256 fx = cum-*p; 00257 goto S330; 00258 S320: 00259 fx = ccum-*q; 00260 S330: 00261 if(!(fx+porq > 1.5e0)) goto S340; 00262 *status = 10; 00263 return; 00264 S340: 00265 dinvr(status,df,&fx,&qleft,&qhi); 00266 goto S310; 00267 S350: 00268 if(!(*status == -1)) goto S380; 00269 if(!qleft) goto S360; 00270 *status = 1; 00271 *bound = zero; 00272 goto S370; 00273 S360: 00274 *status = 2; 00275 *bound = inf; 00276 S370: 00277 ; 00278 } 00279 S380: 00280 return; 00281 #undef tol 00282 #undef atol 00283 #undef zero 00284 #undef inf 00285 } /* END */ | 
| 
 | ||||||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_17.c. References cumchn(), dinvr(), dstinv(), p, and q. 
 00025 : 1..4 00026 iwhich = 1 : Calculate P and Q from X and DF 00027 iwhich = 2 : Calculate X from P,DF and PNONC 00028 iwhich = 3 : Calculate DF from P,X and PNONC 00029 iwhich = 3 : Calculate PNONC from P,X and DF 00030 00031 P <--> The integral from 0 to X of the non-central chi-square 00032 distribution. 00033 Input range: [0, 1-1E-16). 00034 00035 Q <--> 1-P. 00036 Q is not used by this subroutine and is only included 00037 for similarity with other cdf* routines. 00038 00039 X <--> Upper limit of integration of the non-central 00040 chi-square distribution. 00041 Input range: [0, +infinity). 00042 Search range: [0,1E300] 00043 00044 DF <--> Degrees of freedom of the non-central 00045 chi-square distribution. 00046 Input range: (0, +infinity). 00047 Search range: [ 1E-300, 1E300] 00048 00049 PNONC <--> Non-centrality parameter of the non-central 00050 chi-square distribution. 00051 Input range: [0, +infinity). 00052 Search range: [0,1E4] 00053 00054 STATUS <-- 0 if calculation completed correctly 00055 -I if input parameter number I is out of range 00056 1 if answer appears to be lower than lowest 00057 search bound 00058 2 if answer appears to be higher than greatest 00059 search bound 00060 00061 BOUND <-- Undefined if STATUS is 0 00062 00063 Bound exceeded by parameter number I if STATUS 00064 is negative. 00065 00066 Lower search bound if STATUS is 1. 00067 00068 Upper search bound if STATUS is 2. 00069 00070 00071 Method 00072 00073 00074 Formula 26.4.25 of Abramowitz and Stegun, Handbook of 00075 Mathematical Functions (1966) is used to compute the cumulative 00076 distribution function. 00077 00078 Computation of other parameters involve a seach for a value that 00079 produces the desired value of P. The search relies on the 00080 monotinicity of P with the other parameter. 00081 00082 00083 WARNING 00084 00085 The computation time required for this routine is proportional 00086 to the noncentrality parameter (PNONC). Very large values of 00087 this parameter can consume immense computer resources. This is 00088 why the search range is bounded by 10,000. 00089 00090 **********************************************************************/ 00091 { 00092 #define tent4 1.0e4 00093 #define tol (1.0e-8) 00094 #define atol (1.0e-50) 00095 #define zero (1.0e-300) 00096 #define one (1.0e0-1.0e-16) 00097 #define inf 1.0e300 00098 static double K1 = 0.0e0; 00099 static double K3 = 0.5e0; 00100 static double K4 = 5.0e0; 00101 static double fx,cum,ccum; 00102 static unsigned long qhi,qleft; 00103 static double T2,T5,T6,T7,T8,T9,T10,T11,T12,T13; 00104 /* 00105 .. 00106 .. Executable Statements .. 00107 */ 00108 /* 00109 Check arguments 00110 */ 00111 if(!(*which < 1 || *which > 4)) goto S30; 00112 if(!(*which < 1)) goto S10; 00113 *bound = 1.0e0; 00114 goto S20; 00115 S10: 00116 *bound = 4.0e0; 00117 S20: 00118 *status = -1; 00119 return; 00120 S30: 00121 if(*which == 1) goto S70; 00122 /* 00123 P 00124 */ 00125 if(!(*p < 0.0e0 || *p > one)) goto S60; 00126 if(!(*p < 0.0e0)) goto S40; 00127 *bound = 0.0e0; 00128 goto S50; 00129 S40: 00130 *bound = one; 00131 S50: 00132 *status = -2; 00133 return; 00134 S70: 00135 S60: 00136 if(*which == 2) goto S90; 00137 /* 00138 X 00139 */ 00140 if(!(*x < 0.0e0)) goto S80; 00141 *bound = 0.0e0; 00142 *status = -4; 00143 return; 00144 S90: 00145 S80: 00146 if(*which == 3) goto S110; 00147 /* 00148 DF 00149 */ 00150 if(!(*df <= 0.0e0)) goto S100; 00151 *bound = 0.0e0; 00152 *status = -5; 00153 return; 00154 S110: 00155 S100: 00156 if(*which == 4) goto S130; 00157 /* 00158 PNONC 00159 */ 00160 if(!(*pnonc < 0.0e0)) goto S120; 00161 *bound = 0.0e0; 00162 *status = -6; 00163 return; 00164 S130: 00165 S120: 00166 /* 00167 Calculate ANSWERS 00168 */ 00169 if(1 == *which) { 00170 /* 00171 Calculating P and Q 00172 */ 00173 cumchn(x,df,pnonc,p,q); 00174 *status = 0; 00175 } 00176 else if(2 == *which) { 00177 /* 00178 Calculating X 00179 */ 00180 *x = 5.0e0; 00181 T2 = inf; 00182 T5 = atol; 00183 T6 = tol; 00184 dstinv(&K1,&T2,&K3,&K3,&K4,&T5,&T6); 00185 *status = 0; 00186 dinvr(status,x,&fx,&qleft,&qhi); 00187 S140: 00188 if(!(*status == 1)) goto S150; 00189 cumchn(x,df,pnonc,&cum,&ccum); 00190 fx = cum-*p; 00191 dinvr(status,x,&fx,&qleft,&qhi); 00192 goto S140; 00193 S150: 00194 if(!(*status == -1)) goto S180; 00195 if(!qleft) goto S160; 00196 *status = 1; 00197 *bound = 0.0e0; 00198 goto S170; 00199 S160: 00200 *status = 2; 00201 *bound = inf; 00202 S180: 00203 S170: 00204 ; 00205 } 00206 else if(3 == *which) { 00207 /* 00208 Calculating DF 00209 */ 00210 *df = 5.0e0; 00211 T7 = zero; 00212 T8 = inf; 00213 T9 = atol; 00214 T10 = tol; 00215 dstinv(&T7,&T8,&K3,&K3,&K4,&T9,&T10); 00216 *status = 0; 00217 dinvr(status,df,&fx,&qleft,&qhi); 00218 S190: 00219 if(!(*status == 1)) goto S200; 00220 cumchn(x,df,pnonc,&cum,&ccum); 00221 fx = cum-*p; 00222 dinvr(status,df,&fx,&qleft,&qhi); 00223 goto S190; 00224 S200: 00225 if(!(*status == -1)) goto S230; 00226 if(!qleft) goto S210; 00227 *status = 1; 00228 *bound = zero; 00229 goto S220; 00230 S210: 00231 *status = 2; 00232 *bound = inf; 00233 S230: 00234 S220: 00235 ; 00236 } 00237 else if(4 == *which) { 00238 /* 00239 Calculating PNONC 00240 */ 00241 *pnonc = 5.0e0; 00242 T11 = tent4; 00243 T12 = atol; 00244 T13 = tol; 00245 dstinv(&K1,&T11,&K3,&K3,&K4,&T12,&T13); 00246 *status = 0; 00247 dinvr(status,pnonc,&fx,&qleft,&qhi); 00248 S240: 00249 if(!(*status == 1)) goto S250; 00250 cumchn(x,df,pnonc,&cum,&ccum); 00251 fx = cum-*p; 00252 dinvr(status,pnonc,&fx,&qleft,&qhi); 00253 goto S240; 00254 S250: 00255 if(!(*status == -1)) goto S280; 00256 if(!qleft) goto S260; 00257 *status = 1; 00258 *bound = zero; 00259 goto S270; 00260 S260: 00261 *status = 2; 00262 *bound = tent4; 00263 S270: 00264 ; 00265 } 00266 S280: 00267 return; 00268 #undef tent4 00269 #undef tol 00270 #undef atol 00271 #undef zero 00272 #undef one 00273 #undef inf 00274 } /* END */ | 
| 
 | ||||||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_18.c. References cumf(), dinvr(), dstinv(), p, q, and spmpar(). Referenced by fstat_p2t(), fstat_t2p(), fstat_t2pp(), and identify_repeats(). 
 00025 : 1..4 00026 iwhich = 1 : Calculate P and Q from F,DFN and DFD 00027 iwhich = 2 : Calculate F from P,Q,DFN and DFD 00028 iwhich = 3 : Calculate DFN from P,Q,F and DFD 00029 iwhich = 4 : Calculate DFD from P,Q,F and DFN 00030 00031 P <--> The integral from 0 to F of the f-density. 00032 Input range: [0,1]. 00033 00034 Q <--> 1-P. 00035 Input range: (0, 1]. 00036 P + Q = 1.0. 00037 00038 F <--> Upper limit of integration of the f-density. 00039 Input range: [0, +infinity). 00040 Search range: [0,1E300] 00041 00042 DFN < --> Degrees of freedom of the numerator sum of squares. 00043 Input range: (0, +infinity). 00044 Search range: [ 1E-300, 1E300] 00045 00046 DFD < --> Degrees of freedom of the denominator sum of squares. 00047 Input range: (0, +infinity). 00048 Search range: [ 1E-300, 1E300] 00049 00050 STATUS <-- 0 if calculation completed correctly 00051 -I if input parameter number I is out of range 00052 1 if answer appears to be lower than lowest 00053 search bound 00054 2 if answer appears to be higher than greatest 00055 search bound 00056 3 if P + Q .ne. 1 00057 00058 BOUND <-- Undefined if STATUS is 0 00059 00060 Bound exceeded by parameter number I if STATUS 00061 is negative. 00062 00063 Lower search bound if STATUS is 1. 00064 00065 Upper search bound if STATUS is 2. 00066 00067 00068 Method 00069 00070 00071 Formula 26.6.2 of Abramowitz and Stegun, Handbook of 00072 Mathematical Functions (1966) is used to reduce the computation 00073 of the cumulative distribution function for the F variate to 00074 that of an incomplete beta. 00075 00076 Computation of other parameters involve a seach for a value that 00077 produces the desired value of P. The search relies on the 00078 monotinicity of P with the other parameter. 00079 00080 WARNING 00081 00082 The value of the cumulative F distribution is not necessarily 00083 monotone in either degrees of freedom. There thus may be two 00084 values that provide a given CDF value. This routine assumes 00085 monotonicity and will find an arbitrary one of the two values. 00086 00087 **********************************************************************/ 00088 { 00089 #define tol (1.0e-8) 00090 #define atol (1.0e-50) 00091 #define zero (1.0e-300) 00092 #define inf 1.0e300 00093 static int K1 = 1; 00094 static double K2 = 0.0e0; 00095 static double K4 = 0.5e0; 00096 static double K5 = 5.0e0; 00097 static double pq,fx,cum,ccum; 00098 static unsigned long qhi,qleft,qporq; 00099 static double T3,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15; 00100 /* 00101 .. 00102 .. Executable Statements .. 00103 */ 00104 /* 00105 Check arguments 00106 */ 00107 if(!(*which < 1 || *which > 4)) goto S30; 00108 if(!(*which < 1)) goto S10; 00109 *bound = 1.0e0; 00110 goto S20; 00111 S10: 00112 *bound = 4.0e0; 00113 S20: 00114 *status = -1; 00115 return; 00116 S30: 00117 if(*which == 1) goto S70; 00118 /* 00119 P 00120 */ 00121 if(!(*p < 0.0e0 || *p > 1.0e0)) goto S60; 00122 if(!(*p < 0.0e0)) goto S40; 00123 *bound = 0.0e0; 00124 goto S50; 00125 S40: 00126 *bound = 1.0e0; 00127 S50: 00128 *status = -2; 00129 return; 00130 S70: 00131 S60: 00132 if(*which == 1) goto S110; 00133 /* 00134 Q 00135 */ 00136 if(!(*q <= 0.0e0 || *q > 1.0e0)) goto S100; 00137 if(!(*q <= 0.0e0)) goto S80; 00138 *bound = 0.0e0; 00139 goto S90; 00140 S80: 00141 *bound = 1.0e0; 00142 S90: 00143 *status = -3; 00144 return; 00145 S110: 00146 S100: 00147 if(*which == 2) goto S130; 00148 /* 00149 F 00150 */ 00151 if(!(*f < 0.0e0)) goto S120; 00152 *bound = 0.0e0; 00153 *status = -4; 00154 return; 00155 S130: 00156 S120: 00157 if(*which == 3) goto S150; 00158 /* 00159 DFN 00160 */ 00161 if(!(*dfn <= 0.0e0)) goto S140; 00162 *bound = 0.0e0; 00163 *status = -5; 00164 return; 00165 S150: 00166 S140: 00167 if(*which == 4) goto S170; 00168 /* 00169 DFD 00170 */ 00171 if(!(*dfd <= 0.0e0)) goto S160; 00172 *bound = 0.0e0; 00173 *status = -6; 00174 return; 00175 S170: 00176 S160: 00177 if(*which == 1) goto S210; 00178 /* 00179 P + Q 00180 */ 00181 pq = *p+*q; 00182 if(!(fabs(pq-0.5e0-0.5e0) > 3.0e0*spmpar(&K1))) goto S200; 00183 if(!(pq < 0.0e0)) goto S180; 00184 *bound = 0.0e0; 00185 goto S190; 00186 S180: 00187 *bound = 1.0e0; 00188 S190: 00189 *status = 3; 00190 return; 00191 S210: 00192 S200: 00193 if(!(*which == 1)) qporq = *p <= *q; 00194 /* 00195 Select the minimum of P or Q 00196 Calculate ANSWERS 00197 */ 00198 if(1 == *which) { 00199 /* 00200 Calculating P 00201 */ 00202 cumf(f,dfn,dfd,p,q); 00203 *status = 0; 00204 } 00205 else if(2 == *which) { 00206 /* 00207 Calculating F 00208 */ 00209 *f = 5.0e0; 00210 T3 = inf; 00211 T6 = atol; 00212 T7 = tol; 00213 dstinv(&K2,&T3,&K4,&K4,&K5,&T6,&T7); 00214 *status = 0; 00215 dinvr(status,f,&fx,&qleft,&qhi); 00216 S220: 00217 if(!(*status == 1)) goto S250; 00218 cumf(f,dfn,dfd,&cum,&ccum); 00219 if(!qporq) goto S230; 00220 fx = cum-*p; 00221 goto S240; 00222 S230: 00223 fx = ccum-*q; 00224 S240: 00225 dinvr(status,f,&fx,&qleft,&qhi); 00226 goto S220; 00227 S250: 00228 if(!(*status == -1)) goto S280; 00229 if(!qleft) goto S260; 00230 *status = 1; 00231 *bound = 0.0e0; 00232 goto S270; 00233 S260: 00234 *status = 2; 00235 *bound = inf; 00236 S280: 00237 S270: 00238 ; 00239 } 00240 else if(3 == *which) { 00241 /* 00242 Calculating DFN 00243 */ 00244 *dfn = 5.0e0; 00245 T8 = zero; 00246 T9 = inf; 00247 T10 = atol; 00248 T11 = tol; 00249 dstinv(&T8,&T9,&K4,&K4,&K5,&T10,&T11); 00250 *status = 0; 00251 dinvr(status,dfn,&fx,&qleft,&qhi); 00252 S290: 00253 if(!(*status == 1)) goto S320; 00254 cumf(f,dfn,dfd,&cum,&ccum); 00255 if(!qporq) goto S300; 00256 fx = cum-*p; 00257 goto S310; 00258 S300: 00259 fx = ccum-*q; 00260 S310: 00261 dinvr(status,dfn,&fx,&qleft,&qhi); 00262 goto S290; 00263 S320: 00264 if(!(*status == -1)) goto S350; 00265 if(!qleft) goto S330; 00266 *status = 1; 00267 *bound = zero; 00268 goto S340; 00269 S330: 00270 *status = 2; 00271 *bound = inf; 00272 S350: 00273 S340: 00274 ; 00275 } 00276 else if(4 == *which) { 00277 /* 00278 Calculating DFD 00279 */ 00280 *dfd = 5.0e0; 00281 T12 = zero; 00282 T13 = inf; 00283 T14 = atol; 00284 T15 = tol; 00285 dstinv(&T12,&T13,&K4,&K4,&K5,&T14,&T15); 00286 *status = 0; 00287 dinvr(status,dfd,&fx,&qleft,&qhi); 00288 S360: 00289 if(!(*status == 1)) goto S390; 00290 cumf(f,dfn,dfd,&cum,&ccum); 00291 if(!qporq) goto S370; 00292 fx = cum-*p; 00293 goto S380; 00294 S370: 00295 fx = ccum-*q; 00296 S380: 00297 dinvr(status,dfd,&fx,&qleft,&qhi); 00298 goto S360; 00299 S390: 00300 if(!(*status == -1)) goto S420; 00301 if(!qleft) goto S400; 00302 *status = 1; 00303 *bound = zero; 00304 goto S410; 00305 S400: 00306 *status = 2; 00307 *bound = inf; 00308 S410: 00309 ; 00310 } 00311 S420: 00312 return; 00313 #undef tol 00314 #undef atol 00315 #undef zero 00316 #undef inf 00317 } /* END */ | 
| 
 | ||||||||||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_19.c. References cumfnc(), dinvr(), dstinv(), p, and q. 
 00025 : 1..5 00026 iwhich = 1 : Calculate P and Q from F,DFN,DFD and PNONC 00027 iwhich = 2 : Calculate F from P,Q,DFN,DFD and PNONC 00028 iwhich = 3 : Calculate DFN from P,Q,F,DFD and PNONC 00029 iwhich = 4 : Calculate DFD from P,Q,F,DFN and PNONC 00030 iwhich = 5 : Calculate PNONC from P,Q,F,DFN and DFD 00031 00032 P <--> The integral from 0 to F of the non-central f-density. 00033 Input range: [0,1-1E-16). 00034 00035 Q <--> 1-P. 00036 Q is not used by this subroutine and is only included 00037 for similarity with other cdf* routines. 00038 00039 F <--> Upper limit of integration of the non-central f-density. 00040 Input range: [0, +infinity). 00041 Search range: [0,1E300] 00042 00043 DFN < --> Degrees of freedom of the numerator sum of squares. 00044 Input range: (0, +infinity). 00045 Search range: [ 1E-300, 1E300] 00046 00047 DFD < --> Degrees of freedom of the denominator sum of squares. 00048 Must be in range: (0, +infinity). 00049 Input range: (0, +infinity). 00050 Search range: [ 1E-300, 1E300] 00051 00052 PNONC <-> The non-centrality parameter 00053 Input range: [0,infinity) 00054 Search range: [0,1E4] 00055 00056 STATUS <-- 0 if calculation completed correctly 00057 -I if input parameter number I is out of range 00058 1 if answer appears to be lower than lowest 00059 search bound 00060 2 if answer appears to be higher than greatest 00061 search bound 00062 3 if P + Q .ne. 1 00063 00064 BOUND <-- Undefined if STATUS is 0 00065 00066 Bound exceeded by parameter number I if STATUS 00067 is negative. 00068 00069 Lower search bound if STATUS is 1. 00070 00071 Upper search bound if STATUS is 2. 00072 00073 00074 Method 00075 00076 00077 Formula 26.6.20 of Abramowitz and Stegun, Handbook of 00078 Mathematical Functions (1966) is used to compute the cumulative 00079 distribution function. 00080 00081 Computation of other parameters involve a seach for a value that 00082 produces the desired value of P. The search relies on the 00083 monotinicity of P with the other parameter. 00084 00085 WARNING 00086 00087 The computation time required for this routine is proportional 00088 to the noncentrality parameter (PNONC). Very large values of 00089 this parameter can consume immense computer resources. This is 00090 why the search range is bounded by 10,000. 00091 00092 WARNING 00093 00094 The value of the cumulative noncentral F distribution is not 00095 necessarily monotone in either degrees of freedom. There thus 00096 may be two values that provide a given CDF value. This routine 00097 assumes monotonicity and will find an arbitrary one of the two 00098 values. 00099 00100 **********************************************************************/ 00101 { 00102 #define tent4 1.0e4 00103 #define tol (1.0e-8) 00104 #define atol (1.0e-50) 00105 #define zero (1.0e-300) 00106 #define one (1.0e0-1.0e-16) 00107 #define inf 1.0e300 00108 static double K1 = 0.0e0; 00109 static double K3 = 0.5e0; 00110 static double K4 = 5.0e0; 00111 static double fx,cum,ccum; 00112 static unsigned long qhi,qleft; 00113 static double T2,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17; 00114 /* 00115 .. 00116 .. Executable Statements .. 00117 */ 00118 /* 00119 Check arguments 00120 */ 00121 if(!(*which < 1 || *which > 5)) goto S30; 00122 if(!(*which < 1)) goto S10; 00123 *bound = 1.0e0; 00124 goto S20; 00125 S10: 00126 *bound = 5.0e0; 00127 S20: 00128 *status = -1; 00129 return; 00130 S30: 00131 if(*which == 1) goto S70; 00132 /* 00133 P 00134 */ 00135 if(!(*p < 0.0e0 || *p > one)) goto S60; 00136 if(!(*p < 0.0e0)) goto S40; 00137 *bound = 0.0e0; 00138 goto S50; 00139 S40: 00140 *bound = one; 00141 S50: 00142 *status = -2; 00143 return; 00144 S70: 00145 S60: 00146 if(*which == 2) goto S90; 00147 /* 00148 F 00149 */ 00150 if(!(*f < 0.0e0)) goto S80; 00151 *bound = 0.0e0; 00152 *status = -4; 00153 return; 00154 S90: 00155 S80: 00156 if(*which == 3) goto S110; 00157 /* 00158 DFN 00159 */ 00160 if(!(*dfn <= 0.0e0)) goto S100; 00161 *bound = 0.0e0; 00162 *status = -5; 00163 return; 00164 S110: 00165 S100: 00166 if(*which == 4) goto S130; 00167 /* 00168 DFD 00169 */ 00170 if(!(*dfd <= 0.0e0)) goto S120; 00171 *bound = 0.0e0; 00172 *status = -6; 00173 return; 00174 S130: 00175 S120: 00176 if(*which == 5) goto S150; 00177 /* 00178 PHONC 00179 */ 00180 if(!(*phonc < 0.0e0)) goto S140; 00181 *bound = 0.0e0; 00182 *status = -7; 00183 return; 00184 S150: 00185 S140: 00186 /* 00187 Calculate ANSWERS 00188 */ 00189 if(1 == *which) { 00190 /* 00191 Calculating P 00192 */ 00193 cumfnc(f,dfn,dfd,phonc,p,q); 00194 *status = 0; 00195 } 00196 else if(2 == *which) { 00197 /* 00198 Calculating F 00199 */ 00200 *f = 5.0e0; 00201 T2 = inf; 00202 T5 = atol; 00203 T6 = tol; 00204 dstinv(&K1,&T2,&K3,&K3,&K4,&T5,&T6); 00205 *status = 0; 00206 dinvr(status,f,&fx,&qleft,&qhi); 00207 S160: 00208 if(!(*status == 1)) goto S170; 00209 cumfnc(f,dfn,dfd,phonc,&cum,&ccum); 00210 fx = cum-*p; 00211 dinvr(status,f,&fx,&qleft,&qhi); 00212 goto S160; 00213 S170: 00214 if(!(*status == -1)) goto S200; 00215 if(!qleft) goto S180; 00216 *status = 1; 00217 *bound = 0.0e0; 00218 goto S190; 00219 S180: 00220 *status = 2; 00221 *bound = inf; 00222 S200: 00223 S190: 00224 ; 00225 } 00226 else if(3 == *which) { 00227 /* 00228 Calculating DFN 00229 */ 00230 *dfn = 5.0e0; 00231 T7 = zero; 00232 T8 = inf; 00233 T9 = atol; 00234 T10 = tol; 00235 dstinv(&T7,&T8,&K3,&K3,&K4,&T9,&T10); 00236 *status = 0; 00237 dinvr(status,dfn,&fx,&qleft,&qhi); 00238 S210: 00239 if(!(*status == 1)) goto S220; 00240 cumfnc(f,dfn,dfd,phonc,&cum,&ccum); 00241 fx = cum-*p; 00242 dinvr(status,dfn,&fx,&qleft,&qhi); 00243 goto S210; 00244 S220: 00245 if(!(*status == -1)) goto S250; 00246 if(!qleft) goto S230; 00247 *status = 1; 00248 *bound = zero; 00249 goto S240; 00250 S230: 00251 *status = 2; 00252 *bound = inf; 00253 S250: 00254 S240: 00255 ; 00256 } 00257 else if(4 == *which) { 00258 /* 00259 Calculating DFD 00260 */ 00261 *dfd = 5.0e0; 00262 T11 = zero; 00263 T12 = inf; 00264 T13 = atol; 00265 T14 = tol; 00266 dstinv(&T11,&T12,&K3,&K3,&K4,&T13,&T14); 00267 *status = 0; 00268 dinvr(status,dfd,&fx,&qleft,&qhi); 00269 S260: 00270 if(!(*status == 1)) goto S270; 00271 cumfnc(f,dfn,dfd,phonc,&cum,&ccum); 00272 fx = cum-*p; 00273 dinvr(status,dfd,&fx,&qleft,&qhi); 00274 goto S260; 00275 S270: 00276 if(!(*status == -1)) goto S300; 00277 if(!qleft) goto S280; 00278 *status = 1; 00279 *bound = zero; 00280 goto S290; 00281 S280: 00282 *status = 2; 00283 *bound = inf; 00284 S300: 00285 S290: 00286 ; 00287 } 00288 else if(5 == *which) { 00289 /* 00290 Calculating PHONC 00291 */ 00292 *phonc = 5.0e0; 00293 T15 = tent4; 00294 T16 = atol; 00295 T17 = tol; 00296 dstinv(&K1,&T15,&K3,&K3,&K4,&T16,&T17); 00297 *status = 0; 00298 dinvr(status,phonc,&fx,&qleft,&qhi); 00299 S310: 00300 if(!(*status == 1)) goto S320; 00301 cumfnc(f,dfn,dfd,phonc,&cum,&ccum); 00302 fx = cum-*p; 00303 dinvr(status,phonc,&fx,&qleft,&qhi); 00304 goto S310; 00305 S320: 00306 if(!(*status == -1)) goto S350; 00307 if(!qleft) goto S330; 00308 *status = 1; 00309 *bound = 0.0e0; 00310 goto S340; 00311 S330: 00312 *status = 2; 00313 *bound = tent4; 00314 S340: 00315 ; 00316 } 00317 S350: 00318 return; 00319 #undef tent4 00320 #undef tol 00321 #undef atol 00322 #undef zero 00323 #undef one 00324 #undef inf 00325 } /* END */ | 
| 
 | ||||||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_20.c. References cumgam(), dinvr(), dstinv(), gaminv(), p, q, scale, shape, and spmpar(). Referenced by gamma_p2t(), and gamma_t2p(). 
 00025 : 1..4 00026 iwhich = 1 : Calculate P and Q from X,SHAPE and SCALE 00027 iwhich = 2 : Calculate X from P,Q,SHAPE and SCALE 00028 iwhich = 3 : Calculate SHAPE from P,Q,X and SCALE 00029 iwhich = 4 : Calculate SCALE from P,Q,X and SHAPE 00030 00031 P <--> The integral from 0 to X of the gamma density. 00032 Input range: [0,1]. 00033 00034 Q <--> 1-P. 00035 Input range: (0, 1]. 00036 P + Q = 1.0. 00037 00038 X <--> The upper limit of integration of the gamma density. 00039 Input range: [0, +infinity). 00040 Search range: [0,1E300] 00041 00042 SHAPE <--> The shape parameter of the gamma density. 00043 Input range: (0, +infinity). 00044 Search range: [1E-300,1E300] 00045 00046 SCALE <--> The scale parameter of the gamma density. 00047 Input range: (0, +infinity). 00048 Search range: (1E-300,1E300] 00049 00050 STATUS <-- 0 if calculation completed correctly 00051 -I if input parameter number I is out of range 00052 1 if answer appears to be lower than lowest 00053 search bound 00054 2 if answer appears to be higher than greatest 00055 search bound 00056 3 if P + Q .ne. 1 00057 10 if the gamma or inverse gamma routine cannot 00058 compute the answer. Usually happens only for 00059 X and SHAPE very large (gt 1E10 or more) 00060 00061 BOUND <-- Undefined if STATUS is 0 00062 00063 Bound exceeded by parameter number I if STATUS 00064 is negative. 00065 00066 Lower search bound if STATUS is 1. 00067 00068 Upper search bound if STATUS is 2. 00069 00070 00071 Method 00072 00073 00074 Cumulative distribution function (P) is calculated directly by 00075 the code associated with: 00076 00077 DiDinato, A. R. and Morris, A. H. Computation of the incomplete 00078 gamma function ratios and their inverse. ACM Trans. Math. 00079 Softw. 12 (1986), 377-393. 00080 00081 Computation of other parameters involve a seach for a value that 00082 produces the desired value of P. The search relies on the 00083 monotinicity of P with the other parameter. 00084 00085 00086 Note 00087 00088 00089 00090 The gamma density is proportional to 00091 T**(SHAPE - 1) * EXP(- SCALE * T) 00092 00093 **********************************************************************/ 00094 { 00095 #define tol (1.0e-8) 00096 #define atol (1.0e-50) 00097 #define zero (1.0e-300) 00098 #define inf 1.0e300 00099 static int K1 = 1; 00100 static double K5 = 0.5e0; 00101 static double K6 = 5.0e0; 00102 static double xx,fx,xscale,cum,ccum,pq,porq; 00103 static int ierr; 00104 static unsigned long qhi,qleft,qporq; 00105 static double T2,T3,T4,T7,T8,T9; 00106 /* 00107 .. 00108 .. Executable Statements .. 00109 */ 00110 /* 00111 Check arguments 00112 */ 00113 if(!(*which < 1 || *which > 4)) goto S30; 00114 if(!(*which < 1)) goto S10; 00115 *bound = 1.0e0; 00116 goto S20; 00117 S10: 00118 *bound = 4.0e0; 00119 S20: 00120 *status = -1; 00121 return; 00122 S30: 00123 if(*which == 1) goto S70; 00124 /* 00125 P 00126 */ 00127 if(!(*p < 0.0e0 || *p > 1.0e0)) goto S60; 00128 if(!(*p < 0.0e0)) goto S40; 00129 *bound = 0.0e0; 00130 goto S50; 00131 S40: 00132 *bound = 1.0e0; 00133 S50: 00134 *status = -2; 00135 return; 00136 S70: 00137 S60: 00138 if(*which == 1) goto S110; 00139 /* 00140 Q 00141 */ 00142 if(!(*q <= 0.0e0 || *q > 1.0e0)) goto S100; 00143 if(!(*q <= 0.0e0)) goto S80; 00144 *bound = 0.0e0; 00145 goto S90; 00146 S80: 00147 *bound = 1.0e0; 00148 S90: 00149 *status = -3; 00150 return; 00151 S110: 00152 S100: 00153 if(*which == 2) goto S130; 00154 /* 00155 X 00156 */ 00157 if(!(*x < 0.0e0)) goto S120; 00158 *bound = 0.0e0; 00159 *status = -4; 00160 return; 00161 S130: 00162 S120: 00163 if(*which == 3) goto S150; 00164 /* 00165 SHAPE 00166 */ 00167 if(!(*shape <= 0.0e0)) goto S140; 00168 *bound = 0.0e0; 00169 *status = -5; 00170 return; 00171 S150: 00172 S140: 00173 if(*which == 4) goto S170; 00174 /* 00175 SCALE 00176 */ 00177 if(!(*scale <= 0.0e0)) goto S160; 00178 *bound = 0.0e0; 00179 *status = -6; 00180 return; 00181 S170: 00182 S160: 00183 if(*which == 1) goto S210; 00184 /* 00185 P + Q 00186 */ 00187 pq = *p+*q; 00188 if(!(fabs(pq-0.5e0-0.5e0) > 3.0e0*spmpar(&K1))) goto S200; 00189 if(!(pq < 0.0e0)) goto S180; 00190 *bound = 0.0e0; 00191 goto S190; 00192 S180: 00193 *bound = 1.0e0; 00194 S190: 00195 *status = 3; 00196 return; 00197 S210: 00198 S200: 00199 if(*which == 1) goto S240; 00200 /* 00201 Select the minimum of P or Q 00202 */ 00203 qporq = *p <= *q; 00204 if(!qporq) goto S220; 00205 porq = *p; 00206 goto S230; 00207 S220: 00208 porq = *q; 00209 S240: 00210 S230: 00211 /* 00212 Calculate ANSWERS 00213 */ 00214 if(1 == *which) { 00215 /* 00216 Calculating P 00217 */ 00218 *status = 0; 00219 xscale = *x**scale; 00220 cumgam(&xscale,shape,p,q); 00221 if(porq > 1.5e0) *status = 10; 00222 } 00223 else if(2 == *which) { 00224 /* 00225 Computing X 00226 */ 00227 T2 = -1.0e0; 00228 gaminv(shape,&xx,&T2,p,q,&ierr); 00229 if(ierr < 0.0e0) { 00230 *status = 10; 00231 return; 00232 } 00233 else { 00234 *x = xx/ *scale; 00235 *status = 0; 00236 } 00237 } 00238 else if(3 == *which) { 00239 /* 00240 Computing SHAPE 00241 */ 00242 *shape = 5.0e0; 00243 xscale = *x**scale; 00244 T3 = zero; 00245 T4 = inf; 00246 T7 = atol; 00247 T8 = tol; 00248 dstinv(&T3,&T4,&K5,&K5,&K6,&T7,&T8); 00249 *status = 0; 00250 dinvr(status,shape,&fx,&qleft,&qhi); 00251 S250: 00252 if(!(*status == 1)) goto S290; 00253 cumgam(&xscale,shape,&cum,&ccum); 00254 if(!qporq) goto S260; 00255 fx = cum-*p; 00256 goto S270; 00257 S260: 00258 fx = ccum-*q; 00259 S270: 00260 if(!(qporq && cum > 1.5e0 || !qporq && ccum > 1.5e0)) goto S280; 00261 *status = 10; 00262 return; 00263 S280: 00264 dinvr(status,shape,&fx,&qleft,&qhi); 00265 goto S250; 00266 S290: 00267 if(!(*status == -1)) goto S320; 00268 if(!qleft) goto S300; 00269 *status = 1; 00270 *bound = zero; 00271 goto S310; 00272 S300: 00273 *status = 2; 00274 *bound = inf; 00275 S320: 00276 S310: 00277 ; 00278 } 00279 else if(4 == *which) { 00280 /* 00281 Computing SCALE 00282 */ 00283 T9 = -1.0e0; 00284 gaminv(shape,&xx,&T9,p,q,&ierr); 00285 if(ierr < 0.0e0) { 00286 *status = 10; 00287 return; 00288 } 00289 else { 00290 *scale = xx/ *x; 00291 *status = 0; 00292 } 00293 } 00294 return; 00295 #undef tol 00296 #undef atol 00297 #undef zero 00298 #undef inf 00299 } /* END */ | 
| 
 | ||||||||||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_21.c. References cumnbn(), dinvr(), dstinv(), dstzr(), dzror(), p, q, spmpar(), and xn. 
 00034 : 1..4 00035 iwhich = 1 : Calculate P and Q from S,XN,PR and OMPR 00036 iwhich = 2 : Calculate S from P,Q,XN,PR and OMPR 00037 iwhich = 3 : Calculate XN from P,Q,S,PR and OMPR 00038 iwhich = 4 : Calculate PR and OMPR from P,Q,S and XN 00039 00040 P <--> The cumulation from 0 to S of the negative 00041 binomial distribution. 00042 Input range: [0,1]. 00043 00044 Q <--> 1-P. 00045 Input range: (0, 1]. 00046 P + Q = 1.0. 00047 00048 S <--> The upper limit of cumulation of the binomial distribution. 00049 There are F or fewer failures before the XNth success. 00050 Input range: [0, +infinity). 00051 Search range: [0, 1E300] 00052 00053 XN <--> The number of successes. 00054 Input range: [0, +infinity). 00055 Search range: [0, 1E300] 00056 00057 PR <--> The probability of success in each binomial trial. 00058 Input range: [0,1]. 00059 Search range: [0,1]. 00060 00061 OMPR <--> 1-PR 00062 Input range: [0,1]. 00063 Search range: [0,1] 00064 PR + OMPR = 1.0 00065 00066 STATUS <-- 0 if calculation completed correctly 00067 -I if input parameter number I is out of range 00068 1 if answer appears to be lower than lowest 00069 search bound 00070 2 if answer appears to be higher than greatest 00071 search bound 00072 3 if P + Q .ne. 1 00073 4 if PR + OMPR .ne. 1 00074 00075 BOUND <-- Undefined if STATUS is 0 00076 00077 Bound exceeded by parameter number I if STATUS 00078 is negative. 00079 00080 Lower search bound if STATUS is 1. 00081 00082 Upper search bound if STATUS is 2. 00083 00084 00085 Method 00086 00087 00088 Formula 26.5.26 of Abramowitz and Stegun, Handbook of 00089 Mathematical Functions (1966) is used to reduce calculation of 00090 the cumulative distribution function to that of an incomplete 00091 beta. 00092 00093 Computation of other parameters involve a seach for a value that 00094 produces the desired value of P. The search relies on the 00095 monotinicity of P with the other parameter. 00096 00097 **********************************************************************/ 00098 { 00099 #define tol (1.0e-8) 00100 #define atol (1.0e-50) 00101 #define inf 1.0e300 00102 #define one 1.0e0 00103 static int K1 = 1; 00104 static double K2 = 0.0e0; 00105 static double K4 = 0.5e0; 00106 static double K5 = 5.0e0; 00107 static double K11 = 1.0e0; 00108 static double fx,xhi,xlo,pq,prompr,cum,ccum; 00109 static unsigned long qhi,qleft,qporq; 00110 static double T3,T6,T7,T8,T9,T10,T12,T13; 00111 /* 00112 .. 00113 .. Executable Statements .. 00114 */ 00115 /* 00116 Check arguments 00117 */ 00118 if(!(*which < 1 || *which > 4)) goto S30; 00119 if(!(*which < 1)) goto S10; 00120 *bound = 1.0e0; 00121 goto S20; 00122 S10: 00123 *bound = 4.0e0; 00124 S20: 00125 *status = -1; 00126 return; 00127 S30: 00128 if(*which == 1) goto S70; 00129 /* 00130 P 00131 */ 00132 if(!(*p < 0.0e0 || *p > 1.0e0)) goto S60; 00133 if(!(*p < 0.0e0)) goto S40; 00134 *bound = 0.0e0; 00135 goto S50; 00136 S40: 00137 *bound = 1.0e0; 00138 S50: 00139 *status = -2; 00140 return; 00141 S70: 00142 S60: 00143 if(*which == 1) goto S110; 00144 /* 00145 Q 00146 */ 00147 if(!(*q <= 0.0e0 || *q > 1.0e0)) goto S100; 00148 if(!(*q <= 0.0e0)) goto S80; 00149 *bound = 0.0e0; 00150 goto S90; 00151 S80: 00152 *bound = 1.0e0; 00153 S90: 00154 *status = -3; 00155 return; 00156 S110: 00157 S100: 00158 if(*which == 2) goto S130; 00159 /* 00160 S 00161 */ 00162 if(!(*s < 0.0e0)) goto S120; 00163 *bound = 0.0e0; 00164 *status = -4; 00165 return; 00166 S130: 00167 S120: 00168 if(*which == 3) goto S150; 00169 /* 00170 XN 00171 */ 00172 if(!(*xn < 0.0e0)) goto S140; 00173 *bound = 0.0e0; 00174 *status = -5; 00175 return; 00176 S150: 00177 S140: 00178 if(*which == 4) goto S190; 00179 /* 00180 PR 00181 */ 00182 if(!(*pr < 0.0e0 || *pr > 1.0e0)) goto S180; 00183 if(!(*pr < 0.0e0)) goto S160; 00184 *bound = 0.0e0; 00185 goto S170; 00186 S160: 00187 *bound = 1.0e0; 00188 S170: 00189 *status = -6; 00190 return; 00191 S190: 00192 S180: 00193 if(*which == 4) goto S230; 00194 /* 00195 OMPR 00196 */ 00197 if(!(*ompr < 0.0e0 || *ompr > 1.0e0)) goto S220; 00198 if(!(*ompr < 0.0e0)) goto S200; 00199 *bound = 0.0e0; 00200 goto S210; 00201 S200: 00202 *bound = 1.0e0; 00203 S210: 00204 *status = -7; 00205 return; 00206 S230: 00207 S220: 00208 if(*which == 1) goto S270; 00209 /* 00210 P + Q 00211 */ 00212 pq = *p+*q; 00213 if(!(fabs(pq-0.5e0-0.5e0) > 3.0e0*spmpar(&K1))) goto S260; 00214 if(!(pq < 0.0e0)) goto S240; 00215 *bound = 0.0e0; 00216 goto S250; 00217 S240: 00218 *bound = 1.0e0; 00219 S250: 00220 *status = 3; 00221 return; 00222 S270: 00223 S260: 00224 if(*which == 4) goto S310; 00225 /* 00226 PR + OMPR 00227 */ 00228 prompr = *pr+*ompr; 00229 if(!(fabs(prompr-0.5e0-0.5e0) > 3.0e0*spmpar(&K1))) goto S300; 00230 if(!(prompr < 0.0e0)) goto S280; 00231 *bound = 0.0e0; 00232 goto S290; 00233 S280: 00234 *bound = 1.0e0; 00235 S290: 00236 *status = 4; 00237 return; 00238 S310: 00239 S300: 00240 if(!(*which == 1)) qporq = *p <= *q; 00241 /* 00242 Select the minimum of P or Q 00243 Calculate ANSWERS 00244 */ 00245 if(1 == *which) { 00246 /* 00247 Calculating P 00248 */ 00249 cumnbn(s,xn,pr,ompr,p,q); 00250 *status = 0; 00251 } 00252 else if(2 == *which) { 00253 /* 00254 Calculating S 00255 */ 00256 *s = 5.0e0; 00257 T3 = inf; 00258 T6 = atol; 00259 T7 = tol; 00260 dstinv(&K2,&T3,&K4,&K4,&K5,&T6,&T7); 00261 *status = 0; 00262 dinvr(status,s,&fx,&qleft,&qhi); 00263 S320: 00264 if(!(*status == 1)) goto S350; 00265 cumnbn(s,xn,pr,ompr,&cum,&ccum); 00266 if(!qporq) goto S330; 00267 fx = cum-*p; 00268 goto S340; 00269 S330: 00270 fx = ccum-*q; 00271 S340: 00272 dinvr(status,s,&fx,&qleft,&qhi); 00273 goto S320; 00274 S350: 00275 if(!(*status == -1)) goto S380; 00276 if(!qleft) goto S360; 00277 *status = 1; 00278 *bound = 0.0e0; 00279 goto S370; 00280 S360: 00281 *status = 2; 00282 *bound = inf; 00283 S380: 00284 S370: 00285 ; 00286 } 00287 else if(3 == *which) { 00288 /* 00289 Calculating XN 00290 */ 00291 *xn = 5.0e0; 00292 T8 = inf; 00293 T9 = atol; 00294 T10 = tol; 00295 dstinv(&K2,&T8,&K4,&K4,&K5,&T9,&T10); 00296 *status = 0; 00297 dinvr(status,xn,&fx,&qleft,&qhi); 00298 S390: 00299 if(!(*status == 1)) goto S420; 00300 cumnbn(s,xn,pr,ompr,&cum,&ccum); 00301 if(!qporq) goto S400; 00302 fx = cum-*p; 00303 goto S410; 00304 S400: 00305 fx = ccum-*q; 00306 S410: 00307 dinvr(status,xn,&fx,&qleft,&qhi); 00308 goto S390; 00309 S420: 00310 if(!(*status == -1)) goto S450; 00311 if(!qleft) goto S430; 00312 *status = 1; 00313 *bound = 0.0e0; 00314 goto S440; 00315 S430: 00316 *status = 2; 00317 *bound = inf; 00318 S450: 00319 S440: 00320 ; 00321 } 00322 else if(4 == *which) { 00323 /* 00324 Calculating PR and OMPR 00325 */ 00326 T12 = atol; 00327 T13 = tol; 00328 dstzr(&K2,&K11,&T12,&T13); 00329 if(!qporq) goto S480; 00330 *status = 0; 00331 dzror(status,pr,&fx,&xlo,&xhi,&qleft,&qhi); 00332 *ompr = one-*pr; 00333 S460: 00334 if(!(*status == 1)) goto S470; 00335 cumnbn(s,xn,pr,ompr,&cum,&ccum); 00336 fx = cum-*p; 00337 dzror(status,pr,&fx,&xlo,&xhi,&qleft,&qhi); 00338 *ompr = one-*pr; 00339 goto S460; 00340 S470: 00341 goto S510; 00342 S480: 00343 *status = 0; 00344 dzror(status,ompr,&fx,&xlo,&xhi,&qleft,&qhi); 00345 *pr = one-*ompr; 00346 S490: 00347 if(!(*status == 1)) goto S500; 00348 cumnbn(s,xn,pr,ompr,&cum,&ccum); 00349 fx = ccum-*q; 00350 dzror(status,ompr,&fx,&xlo,&xhi,&qleft,&qhi); 00351 *pr = one-*ompr; 00352 goto S490; 00353 S510: 00354 S500: 00355 if(!(*status == -1)) goto S540; 00356 if(!qleft) goto S520; 00357 *status = 1; 00358 *bound = 0.0e0; 00359 goto S530; 00360 S520: 00361 *status = 2; 00362 *bound = 1.0e0; 00363 S530: 00364 ; 00365 } 00366 S540: 00367 return; 00368 #undef tol 00369 #undef atol 00370 #undef inf 00371 #undef one 00372 } /* END */ | 
| 
 | ||||||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_22.c. References cumnor(), dinvnr(), p, q, and spmpar(). Referenced by initialize(), normal_p2t(), normal_t2p(), and threshold_data(). 
 00025 : 1..4 00026 iwhich = 1 : Calculate P and Q from X,MEAN and SD 00027 iwhich = 2 : Calculate X from P,Q,MEAN and SD 00028 iwhich = 3 : Calculate MEAN from P,Q,X and SD 00029 iwhich = 4 : Calculate SD from P,Q,X and MEAN 00030 00031 P <--> The integral from -infinity to X of the normal density. 00032 Input range: (0,1]. 00033 00034 Q <--> 1-P. 00035 Input range: (0, 1]. 00036 P + Q = 1.0. 00037 00038 X < --> Upper limit of integration of the normal-density. 00039 Input range: ( -infinity, +infinity) 00040 00041 MEAN <--> The mean of the normal density. 00042 Input range: (-infinity, +infinity) 00043 00044 SD <--> Standard Deviation of the normal density. 00045 Input range: (0, +infinity). 00046 00047 STATUS <-- 0 if calculation completed correctly 00048 -I if input parameter number I is out of range 00049 1 if answer appears to be lower than lowest 00050 search bound 00051 2 if answer appears to be higher than greatest 00052 search bound 00053 3 if P + Q .ne. 1 00054 00055 BOUND <-- Undefined if STATUS is 0 00056 00057 Bound exceeded by parameter number I if STATUS 00058 is negative. 00059 00060 Lower search bound if STATUS is 1. 00061 00062 Upper search bound if STATUS is 2. 00063 00064 00065 Method 00066 00067 00068 00069 00070 A slightly modified version of ANORM from 00071 00072 Cody, W.D. (1993). "ALGORITHM 715: SPECFUN - A Portabel FORTRAN 00073 Package of Special Function Routines and Test Drivers" 00074 acm Transactions on Mathematical Software. 19, 22-32. 00075 00076 is used to calulate the cumulative standard normal distribution. 00077 00078 The rational functions from pages 90-95 of Kennedy and Gentle, 00079 Statistical Computing, Marcel Dekker, NY, 1980 are used as 00080 starting values to Newton's Iterations which compute the inverse 00081 standard normal. Therefore no searches are necessary for any 00082 parameter. 00083 00084 For X < -15, the asymptotic expansion for the normal is used as 00085 the starting value in finding the inverse standard normal. 00086 This is formula 26.2.12 of Abramowitz and Stegun. 00087 00088 00089 Note 00090 00091 00092 The normal density is proportional to 00093 exp( - 0.5 * (( X - MEAN)/SD)**2) 00094 00095 **********************************************************************/ 00096 { 00097 static int K1 = 1; 00098 static double z,pq; 00099 /* 00100 .. 00101 .. Executable Statements .. 00102 */ 00103 /* 00104 Check arguments 00105 */ 00106 *status = 0; 00107 if(!(*which < 1 || *which > 4)) goto S30; 00108 if(!(*which < 1)) goto S10; 00109 *bound = 1.0e0; 00110 goto S20; 00111 S10: 00112 *bound = 4.0e0; 00113 S20: 00114 *status = -1; 00115 return; 00116 S30: 00117 if(*which == 1) goto S70; 00118 /* 00119 P 00120 */ 00121 if(!(*p <= 0.0e0 || *p > 1.0e0)) goto S60; 00122 if(!(*p <= 0.0e0)) goto S40; 00123 *bound = 0.0e0; 00124 goto S50; 00125 S40: 00126 *bound = 1.0e0; 00127 S50: 00128 *status = -2; 00129 return; 00130 S70: 00131 S60: 00132 if(*which == 1) goto S110; 00133 /* 00134 Q 00135 */ 00136 if(!(*q <= 0.0e0 || *q > 1.0e0)) goto S100; 00137 if(!(*q <= 0.0e0)) goto S80; 00138 *bound = 0.0e0; 00139 goto S90; 00140 S80: 00141 *bound = 1.0e0; 00142 S90: 00143 *status = -3; 00144 return; 00145 S110: 00146 S100: 00147 if(*which == 1) goto S150; 00148 /* 00149 P + Q 00150 */ 00151 pq = *p+*q; 00152 if(!(fabs(pq-0.5e0-0.5e0) > 3.0e0*spmpar(&K1))) goto S140; 00153 if(!(pq < 0.0e0)) goto S120; 00154 *bound = 0.0e0; 00155 goto S130; 00156 S120: 00157 *bound = 1.0e0; 00158 S130: 00159 *status = 3; 00160 return; 00161 S150: 00162 S140: 00163 if(*which == 4) goto S170; 00164 /* 00165 SD 00166 */ 00167 if(!(*sd <= 0.0e0)) goto S160; 00168 *bound = 0.0e0; 00169 *status = -6; 00170 return; 00171 S170: 00172 S160: 00173 /* 00174 Calculate ANSWERS 00175 */ 00176 if(1 == *which) { 00177 /* 00178 Computing P 00179 */ 00180 z = (*x-*mean)/ *sd; 00181 cumnor(&z,p,q); 00182 } 00183 else if(2 == *which) { 00184 /* 00185 Computing X 00186 */ 00187 z = dinvnr(p,q); 00188 *x = *sd*z+*mean; 00189 } 00190 else if(3 == *which) { 00191 /* 00192 Computing the MEAN 00193 */ 00194 z = dinvnr(p,q); 00195 *mean = *x-*sd*z; 00196 } 00197 else if(4 == *which) { 00198 /* 00199 Computing SD 00200 */ 00201 z = dinvnr(p,q); 00202 *sd = (*x-*mean)/z; 00203 } 00204 return; 00205 } /* END */ | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_23.c. References cumpoi(), dinvr(), dstinv(), p, q, and spmpar(). Referenced by poisson_p2t(), and poisson_t2p(). 
 00025 : 1..3 00026 iwhich = 1 : Calculate P and Q from S and XLAM 00027 iwhich = 2 : Calculate A from P,Q and XLAM 00028 iwhich = 3 : Calculate XLAM from P,Q and S 00029 00030 P <--> The cumulation from 0 to S of the poisson density. 00031 Input range: [0,1]. 00032 00033 Q <--> 1-P. 00034 Input range: (0, 1]. 00035 P + Q = 1.0. 00036 00037 S <--> Upper limit of cumulation of the Poisson. 00038 Input range: [0, +infinity). 00039 Search range: [0,1E300] 00040 00041 XLAM <--> Mean of the Poisson distribution. 00042 Input range: [0, +infinity). 00043 Search range: [0,1E300] 00044 00045 STATUS <-- 0 if calculation completed correctly 00046 -I if input parameter number I is out of range 00047 1 if answer appears to be lower than lowest 00048 search bound 00049 2 if answer appears to be higher than greatest 00050 search bound 00051 3 if P + Q .ne. 1 00052 00053 BOUND <-- Undefined if STATUS is 0 00054 00055 Bound exceeded by parameter number I if STATUS 00056 is negative. 00057 00058 Lower search bound if STATUS is 1. 00059 00060 Upper search bound if STATUS is 2. 00061 00062 00063 Method 00064 00065 00066 Formula 26.4.21 of Abramowitz and Stegun, Handbook of 00067 Mathematical Functions (1966) is used to reduce the computation 00068 of the cumulative distribution function to that of computing a 00069 chi-square, hence an incomplete gamma function. 00070 00071 Cumulative distribution function (P) is calculated directly. 00072 Computation of other parameters involve a seach for a value that 00073 produces the desired value of P. The search relies on the 00074 monotinicity of P with the other parameter. 00075 00076 **********************************************************************/ 00077 { 00078 #define tol (1.0e-8) 00079 #define atol (1.0e-50) 00080 #define inf 1.0e300 00081 static int K1 = 1; 00082 static double K2 = 0.0e0; 00083 static double K4 = 0.5e0; 00084 static double K5 = 5.0e0; 00085 static double fx,cum,ccum,pq; 00086 static unsigned long qhi,qleft,qporq; 00087 static double T3,T6,T7,T8,T9,T10; 00088 /* 00089 .. 00090 .. Executable Statements .. 00091 */ 00092 /* 00093 Check arguments 00094 */ 00095 if(!(*which < 1 || *which > 3)) goto S30; 00096 if(!(*which < 1)) goto S10; 00097 *bound = 1.0e0; 00098 goto S20; 00099 S10: 00100 *bound = 3.0e0; 00101 S20: 00102 *status = -1; 00103 return; 00104 S30: 00105 if(*which == 1) goto S70; 00106 /* 00107 P 00108 */ 00109 if(!(*p < 0.0e0 || *p > 1.0e0)) goto S60; 00110 if(!(*p < 0.0e0)) goto S40; 00111 *bound = 0.0e0; 00112 goto S50; 00113 S40: 00114 *bound = 1.0e0; 00115 S50: 00116 *status = -2; 00117 return; 00118 S70: 00119 S60: 00120 if(*which == 1) goto S110; 00121 /* 00122 Q 00123 */ 00124 if(!(*q <= 0.0e0 || *q > 1.0e0)) goto S100; 00125 if(!(*q <= 0.0e0)) goto S80; 00126 *bound = 0.0e0; 00127 goto S90; 00128 S80: 00129 *bound = 1.0e0; 00130 S90: 00131 *status = -3; 00132 return; 00133 S110: 00134 S100: 00135 if(*which == 2) goto S130; 00136 /* 00137 S 00138 */ 00139 if(!(*s < 0.0e0)) goto S120; 00140 *bound = 0.0e0; 00141 *status = -4; 00142 return; 00143 S130: 00144 S120: 00145 if(*which == 3) goto S150; 00146 /* 00147 XLAM 00148 */ 00149 if(!(*xlam < 0.0e0)) goto S140; 00150 *bound = 0.0e0; 00151 *status = -5; 00152 return; 00153 S150: 00154 S140: 00155 if(*which == 1) goto S190; 00156 /* 00157 P + Q 00158 */ 00159 pq = *p+*q; 00160 if(!(fabs(pq-0.5e0-0.5e0) > 3.0e0*spmpar(&K1))) goto S180; 00161 if(!(pq < 0.0e0)) goto S160; 00162 *bound = 0.0e0; 00163 goto S170; 00164 S160: 00165 *bound = 1.0e0; 00166 S170: 00167 *status = 3; 00168 return; 00169 S190: 00170 S180: 00171 if(!(*which == 1)) qporq = *p <= *q; 00172 /* 00173 Select the minimum of P or Q 00174 Calculate ANSWERS 00175 */ 00176 if(1 == *which) { 00177 /* 00178 Calculating P 00179 */ 00180 cumpoi(s,xlam,p,q); 00181 *status = 0; 00182 } 00183 else if(2 == *which) { 00184 /* 00185 Calculating S 00186 */ 00187 *s = 5.0e0; 00188 T3 = inf; 00189 T6 = atol; 00190 T7 = tol; 00191 dstinv(&K2,&T3,&K4,&K4,&K5,&T6,&T7); 00192 *status = 0; 00193 dinvr(status,s,&fx,&qleft,&qhi); 00194 S200: 00195 if(!(*status == 1)) goto S230; 00196 cumpoi(s,xlam,&cum,&ccum); 00197 if(!qporq) goto S210; 00198 fx = cum-*p; 00199 goto S220; 00200 S210: 00201 fx = ccum-*q; 00202 S220: 00203 dinvr(status,s,&fx,&qleft,&qhi); 00204 goto S200; 00205 S230: 00206 if(!(*status == -1)) goto S260; 00207 if(!qleft) goto S240; 00208 *status = 1; 00209 *bound = 0.0e0; 00210 goto S250; 00211 S240: 00212 *status = 2; 00213 *bound = inf; 00214 S260: 00215 S250: 00216 ; 00217 } 00218 else if(3 == *which) { 00219 /* 00220 Calculating XLAM 00221 */ 00222 *xlam = 5.0e0; 00223 T8 = inf; 00224 T9 = atol; 00225 T10 = tol; 00226 dstinv(&K2,&T8,&K4,&K4,&K5,&T9,&T10); 00227 *status = 0; 00228 dinvr(status,xlam,&fx,&qleft,&qhi); 00229 S270: 00230 if(!(*status == 1)) goto S300; 00231 cumpoi(s,xlam,&cum,&ccum); 00232 if(!qporq) goto S280; 00233 fx = cum-*p; 00234 goto S290; 00235 S280: 00236 fx = ccum-*q; 00237 S290: 00238 dinvr(status,xlam,&fx,&qleft,&qhi); 00239 goto S270; 00240 S300: 00241 if(!(*status == -1)) goto S330; 00242 if(!qleft) goto S310; 00243 *status = 1; 00244 *bound = 0.0e0; 00245 goto S320; 00246 S310: 00247 *status = 2; 00248 *bound = inf; 00249 S320: 00250 ; 00251 } 00252 S330: 00253 return; 00254 #undef tol 00255 #undef atol 00256 #undef inf 00257 } /* END */ | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_24.c. References cumt(), dinvr(), dstinv(), dt1(), p, q, and spmpar(). 
 00025 : 1..3 00026 iwhich = 1 : Calculate P and Q from T and DF 00027 iwhich = 2 : Calculate T from P,Q and DF 00028 iwhich = 3 : Calculate DF from P,Q and T 00029 00030 P <--> The integral from -infinity to t of the t-density. 00031 Input range: (0,1]. 00032 00033 Q <--> 1-P. 00034 Input range: (0, 1]. 00035 P + Q = 1.0. 00036 00037 T <--> Upper limit of integration of the t-density. 00038 Input range: ( -infinity, +infinity). 00039 Search range: [ -1E300, 1E300 ] 00040 00041 DF <--> Degrees of freedom of the t-distribution. 00042 Input range: (0 , +infinity). 00043 Search range: [1e-300, 1E10] 00044 00045 STATUS <-- 0 if calculation completed correctly 00046 -I if input parameter number I is out of range 00047 1 if answer appears to be lower than lowest 00048 search bound 00049 2 if answer appears to be higher than greatest 00050 search bound 00051 3 if P + Q .ne. 1 00052 00053 BOUND <-- Undefined if STATUS is 0 00054 00055 Bound exceeded by parameter number I if STATUS 00056 is negative. 00057 00058 Lower search bound if STATUS is 1. 00059 00060 Upper search bound if STATUS is 2. 00061 00062 00063 Method 00064 00065 00066 Formula 26.5.27 of Abramowitz and Stegun, Handbook of 00067 Mathematical Functions (1966) is used to reduce the computation 00068 of the cumulative distribution function to that of an incomplete 00069 beta. 00070 00071 Computation of other parameters involve a seach for a value that 00072 produces the desired value of P. The search relies on the 00073 monotinicity of P with the other parameter. 00074 00075 **********************************************************************/ 00076 { 00077 #define tol (1.0e-8) 00078 #define atol (1.0e-50) 00079 #define zero (1.0e-300) 00080 #define inf 1.0e300 00081 #define maxdf 1.0e10 00082 static int K1 = 1; 00083 static double K4 = 0.5e0; 00084 static double K5 = 5.0e0; 00085 static double fx,cum,ccum,pq; 00086 static unsigned long qhi,qleft,qporq; 00087 static double T2,T3,T6,T7,T8,T9,T10,T11; 00088 /* 00089 .. 00090 .. Executable Statements .. 00091 */ 00092 /* 00093 Check arguments 00094 */ 00095 if(!(*which < 1 || *which > 3)) goto S30; 00096 if(!(*which < 1)) goto S10; 00097 *bound = 1.0e0; 00098 goto S20; 00099 S10: 00100 *bound = 3.0e0; 00101 S20: 00102 *status = -1; 00103 return; 00104 S30: 00105 if(*which == 1) goto S70; 00106 /* 00107 P 00108 */ 00109 if(!(*p <= 0.0e0 || *p > 1.0e0)) goto S60; 00110 if(!(*p <= 0.0e0)) goto S40; 00111 *bound = 0.0e0; 00112 goto S50; 00113 S40: 00114 *bound = 1.0e0; 00115 S50: 00116 *status = -2; 00117 return; 00118 S70: 00119 S60: 00120 if(*which == 1) goto S110; 00121 /* 00122 Q 00123 */ 00124 if(!(*q <= 0.0e0 || *q > 1.0e0)) goto S100; 00125 if(!(*q <= 0.0e0)) goto S80; 00126 *bound = 0.0e0; 00127 goto S90; 00128 S80: 00129 *bound = 1.0e0; 00130 S90: 00131 *status = -3; 00132 return; 00133 S110: 00134 S100: 00135 if(*which == 3) goto S130; 00136 /* 00137 DF 00138 */ 00139 if(!(*df <= 0.0e0)) goto S120; 00140 *bound = 0.0e0; 00141 *status = -5; 00142 return; 00143 S130: 00144 S120: 00145 if(*which == 1) goto S170; 00146 /* 00147 P + Q 00148 */ 00149 pq = *p+*q; 00150 if(!(fabs(pq-0.5e0-0.5e0) > 3.0e0*spmpar(&K1))) goto S160; 00151 if(!(pq < 0.0e0)) goto S140; 00152 *bound = 0.0e0; 00153 goto S150; 00154 S140: 00155 *bound = 1.0e0; 00156 S150: 00157 *status = 3; 00158 return; 00159 S170: 00160 S160: 00161 if(!(*which == 1)) qporq = *p <= *q; 00162 /* 00163 Select the minimum of P or Q 00164 Calculate ANSWERS 00165 */ 00166 if(1 == *which) { 00167 /* 00168 Computing P and Q 00169 */ 00170 cumt(t,df,p,q); 00171 *status = 0; 00172 } 00173 else if(2 == *which) { 00174 /* 00175 Computing T 00176 .. Get initial approximation for T 00177 */ 00178 *t = dt1(p,q,df); 00179 T2 = -inf; 00180 T3 = inf; 00181 T6 = atol; 00182 T7 = tol; 00183 dstinv(&T2,&T3,&K4,&K4,&K5,&T6,&T7); 00184 *status = 0; 00185 dinvr(status,t,&fx,&qleft,&qhi); 00186 S180: 00187 if(!(*status == 1)) goto S210; 00188 cumt(t,df,&cum,&ccum); 00189 if(!qporq) goto S190; 00190 fx = cum-*p; 00191 goto S200; 00192 S190: 00193 fx = ccum-*q; 00194 S200: 00195 dinvr(status,t,&fx,&qleft,&qhi); 00196 goto S180; 00197 S210: 00198 if(!(*status == -1)) goto S240; 00199 if(!qleft) goto S220; 00200 *status = 1; 00201 *bound = -inf; 00202 goto S230; 00203 S220: 00204 *status = 2; 00205 *bound = inf; 00206 S240: 00207 S230: 00208 ; 00209 } 00210 else if(3 == *which) { 00211 /* 00212 Computing DF 00213 */ 00214 *df = 5.0e0; 00215 T8 = zero; 00216 T9 = maxdf; 00217 T10 = atol; 00218 T11 = tol; 00219 dstinv(&T8,&T9,&K4,&K4,&K5,&T10,&T11); 00220 *status = 0; 00221 dinvr(status,df,&fx,&qleft,&qhi); 00222 S250: 00223 if(!(*status == 1)) goto S280; 00224 cumt(t,df,&cum,&ccum); 00225 if(!qporq) goto S260; 00226 fx = cum-*p; 00227 goto S270; 00228 S260: 00229 fx = ccum-*q; 00230 S270: 00231 dinvr(status,df,&fx,&qleft,&qhi); 00232 goto S250; 00233 S280: 00234 if(!(*status == -1)) goto S310; 00235 if(!qleft) goto S290; 00236 *status = 1; 00237 *bound = zero; 00238 goto S300; 00239 S290: 00240 *status = 2; 00241 *bound = maxdf; 00242 S300: 00243 ; 00244 } 00245 S310: 00246 return; 00247 #undef tol 00248 #undef atol 00249 #undef zero 00250 #undef inf 00251 #undef maxdf 00252 } /* END */ | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_25.c. Referenced by cdfbet(), cumbin(), cumnbn(), and cumt(). 
 00056 {
00057 static int ierr;
00058 /*
00059      ..
00060      .. Executable Statements ..
00061 */
00062     if(!(*x <= 0.0e0)) goto S10;
00063     *cum = 0.0e0;
00064     *ccum = 1.0e0;
00065     return;
00066 S10:
00067     if(!(*y <= 0.0e0)) goto S20;
00068     *cum = 1.0e0;
00069     *ccum = 0.0e0;
00070     return;
00071 S20:
00072     bratio(a,b,x,y,cum,ccum,&ierr);
00073 /*
00074      Call bratio routine
00075 */
00076     return;
00077 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_26.c. Referenced by cdfbin(). 
 00051 {
00052 static double T1,T2;
00053 /*
00054      ..
00055      .. Executable Statements ..
00056 */
00057     if(!(*s < *xn)) goto S10;
00058     T1 = *s+1.0e0;
00059     T2 = *xn-*s;
00060     cumbet(pr,ompr,&T1,&T2,ccum,cum);
00061     goto S20;
00062 S10:
00063     *cum = 1.0e0;
00064     *ccum = 0.0e0;
00065 S20:
00066     return;
00067 } /* END */
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 2 of file cdf_27.c. Referenced by cdfchi(), cumchn(), and cumpoi(). 
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_28.c. References alngam(), cumchi(), fifidint(), and i. Referenced by cdfchn(). 
 00074 {
00075 #define dg(i) (*df+2.0e0*(double)(i))
00076 #define qsmall(xx) (int)(sum < 1.0e-20 || (xx) < eps*sum)
00077 #define qtired(i) (int)((i) > ntired)
00078 static double eps = 1.0e-5;
00079 static int ntired = 1000;
00080 static double adj,centaj,centwt,chid2,dfd2,lcntaj,lcntwt,lfact,pcent,pterm,sum,
00081     sumadj,term,wt,xnonc;
00082 static int i,icent,iterb,iterf;
00083 static double T1,T2,T3;
00084 /*
00085      ..
00086      .. Executable Statements ..
00087 */
00088     if(!(*x <= 0.0e0)) goto S10;
00089     *cum = 0.0e0;
00090     *ccum = 1.0e0;
00091     return;
00092 S10:
00093     if(!(*pnonc <= 1.0e-10)) goto S20;
00094 /*
00095      When non-centrality parameter is (essentially) zero,
00096      use cumulative chi-square distribution
00097 */
00098     cumchi(x,df,cum,ccum);
00099     return;
00100 S20:
00101     xnonc = *pnonc/2.0e0;
00102 /*
00103 **********************************************************************
00104      The following code calcualtes the weight, chi-square, and
00105      adjustment term for the central term in the infinite series.
00106      The central term is the one in which the poisson weight is
00107      greatest.  The adjustment term is the amount that must
00108      be subtracted from the chi-square to move up two degrees
00109      of freedom.
00110 **********************************************************************
00111 */
00112     icent = fifidint(xnonc);
00113     if(icent == 0) icent = 1;
00114     chid2 = *x/2.0e0;
00115 /*
00116      Calculate central weight term
00117 */
00118     T1 = (double)(icent+1);
00119     lfact = alngam(&T1);
00120     lcntwt = -xnonc+(double)icent*log(xnonc)-lfact;
00121     centwt = exp(lcntwt);
00122 /*
00123      Calculate central chi-square
00124 */
00125     T2 = dg(icent);
00126     cumchi(x,&T2,&pcent,ccum);
00127 /*
00128      Calculate central adjustment term
00129 */
00130     dfd2 = dg(icent)/2.0e0;
00131     T3 = 1.0e0+dfd2;
00132     lfact = alngam(&T3);
00133     lcntaj = dfd2*log(chid2)-chid2-lfact;
00134     centaj = exp(lcntaj);
00135     sum = centwt*pcent;
00136 /*
00137 **********************************************************************
00138      Sum backwards from the central term towards zero.
00139      Quit whenever either
00140      (1) the zero term is reached, or
00141      (2) the term gets small relative to the sum, or
00142      (3) More than NTIRED terms are totaled.
00143 **********************************************************************
00144 */
00145     iterb = 0;
00146     sumadj = 0.0e0;
00147     adj = centaj;
00148     wt = centwt;
00149     i = icent;
00150     goto S40;
00151 S30:
00152     if(qtired(iterb) || qsmall(term) || i == 0) goto S50;
00153 S40:
00154     dfd2 = dg(i)/2.0e0;
00155 /*
00156      Adjust chi-square for two fewer degrees of freedom.
00157      The adjusted value ends up in PTERM.
00158 */
00159     adj = adj*dfd2/chid2;
00160     sumadj += adj;
00161     pterm = pcent+sumadj;
00162 /*
00163      Adjust poisson weight for J decreased by one
00164 */
00165     wt *= ((double)i/xnonc);
00166     term = wt*pterm;
00167     sum += term;
00168     i -= 1;
00169     iterb += 1;
00170     goto S30;
00171 S50:
00172     iterf = 0;
00173 /*
00174 **********************************************************************
00175      Now sum forward from the central term towards infinity.
00176      Quit when either
00177      (1) the term gets small relative to the sum, or
00178      (2) More than NTIRED terms are totaled.
00179 **********************************************************************
00180 */
00181     sumadj = adj = centaj;
00182     wt = centwt;
00183     i = icent;
00184     goto S70;
00185 S60:
00186     if(qtired(iterf) || qsmall(term)) goto S80;
00187 S70:
00188 /*
00189      Update weights for next higher J
00190 */
00191     wt *= (xnonc/(double)(i+1));
00192 /*
00193      Calculate PTERM and add term to sum
00194 */
00195     pterm = pcent-sumadj;
00196     term = wt*pterm;
00197     sum += term;
00198 /*
00199      Update adjustment term for DF for next iteration
00200 */
00201     i += 1;
00202     dfd2 = dg(i)/2.0e0;
00203     adj = adj*chid2/dfd2;
00204     sumadj += adj;
00205     iterf += 1;
00206     goto S60;
00207 S80:
00208     *cum = sum;
00209     *ccum = 0.5e0+(0.5e0-*cum);
00210     return;
00211 #undef dg
00212 #undef qsmall
00213 #undef qtired
00214 } /* END */
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_29.c. References bratio(). Referenced by cdff(), and cumfnc(). 
 00050 {
00051 #define half 0.5e0
00052 #define done 1.0e0
00053 static double dsum,prod,xx,yy;
00054 static int ierr;
00055 static double T1,T2;
00056 /*
00057      ..
00058      .. Executable Statements ..
00059 */
00060     if(!(*f <= 0.0e0)) goto S10;
00061     *cum = 0.0e0;
00062     *ccum = 1.0e0;
00063     return;
00064 S10:
00065     prod = *dfn**f;
00066 /*
00067      XX is such that the incomplete beta with parameters
00068      DFD/2 and DFN/2 evaluated at XX is 1 - CUM or CCUM
00069      YY is 1 - XX
00070      Calculate the smaller of XX and YY accurately
00071 */
00072     dsum = *dfd+prod;
00073     xx = *dfd/dsum;
00074     if(xx > half) {
00075         yy = prod/dsum;
00076         xx = done-yy;
00077     }
00078     else  yy = done-xx;
00079     T1 = *dfd*half;
00080     T2 = *dfn*half;
00081     bratio(&T1,&T2,&xx,&yy,ccum,cum,&ierr);
00082     return;
00083 #undef half
00084 #undef done
00085 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_30.c. References alngam(), bratio(), cumf(), dummy, and i. Referenced by cdffnc(). 
 00065 {
00066 #define qsmall(x) (int)(sum < 1.0e-20 || (x) < eps*sum)
00067 #define half 0.5e0
00068 #define done 1.0e0
00069 static double eps = 1.0e-4;
00070 static double dsum,dummy,prod,xx,yy,adn,aup,b,betdn,betup,centwt,dnterm,sum,
00071     upterm,xmult,xnonc;
00072 static int i,icent,ierr;
00073 static double T1,T2,T3,T4,T5,T6;
00074 /*
00075      ..
00076      .. Executable Statements ..
00077 */
00078     if(!(*f <= 0.0e0)) goto S10;
00079     *cum = 0.0e0;
00080     *ccum = 1.0e0;
00081     return;
00082 S10:
00083     if(!(*pnonc < 1.0e-10)) goto S20;
00084 /*
00085      Handle case in which the non-centrality parameter is
00086      (essentially) zero.
00087 */
00088     cumf(f,dfn,dfd,cum,ccum);
00089     return;
00090 S20:
00091     xnonc = *pnonc/2.0e0;
00092 /*
00093      Calculate the central term of the poisson weighting factor.
00094 */
00095     icent = xnonc;
00096     if(icent == 0) icent = 1;
00097 /*
00098      Compute central weight term
00099 */
00100     T1 = (double)(icent+1);
00101     centwt = exp(-xnonc+(double)icent*log(xnonc)-alngam(&T1));
00102 /*
00103      Compute central incomplete beta term
00104      Assure that minimum of arg to beta and 1 - arg is computed
00105           accurately.
00106 */
00107     prod = *dfn**f;
00108     dsum = *dfd+prod;
00109     yy = *dfd/dsum;
00110     if(yy > half) {
00111         xx = prod/dsum;
00112         yy = done-xx;
00113     }
00114     else  xx = done-yy;
00115     T2 = *dfn*half+(double)icent;
00116     T3 = *dfd*half;
00117     bratio(&T2,&T3,&xx,&yy,&betdn,&dummy,&ierr);
00118     adn = *dfn/2.0e0+(double)icent;
00119     aup = adn;
00120     b = *dfd/2.0e0;
00121     betup = betdn;
00122     sum = centwt*betdn;
00123 /*
00124      Now sum terms backward from icent until convergence or all done
00125 */
00126     xmult = centwt;
00127     i = icent;
00128     T4 = adn+b;
00129     T5 = adn+1.0e0;
00130     dnterm = exp(alngam(&T4)-alngam(&T5)-alngam(&b)+adn*log(xx)+b*log(yy));
00131 S30:
00132     if(qsmall(xmult*betdn) || i <= 0) goto S40;
00133     xmult *= ((double)i/xnonc);
00134     i -= 1;
00135     adn -= 1.0;
00136     dnterm = (adn+1.0)/((adn+b)*xx)*dnterm;
00137     betdn += dnterm;
00138     sum += (xmult*betdn);
00139     goto S30;
00140 S40:
00141     i = icent+1;
00142 /*
00143      Now sum forwards until convergence
00144 */
00145     xmult = centwt;
00146     if(aup-1.0+b == 0) upterm = exp(-alngam(&aup)-alngam(&b)+(aup-1.0)*log(xx)+
00147       b*log(yy));
00148     else  {
00149         T6 = aup-1.0+b;
00150         upterm = exp(alngam(&T6)-alngam(&aup)-alngam(&b)+(aup-1.0)*log(xx)+b*
00151           log(yy));
00152     }
00153     goto S60;
00154 S50:
00155     if(qsmall(xmult*betup)) goto S70;
00156 S60:
00157     xmult *= (xnonc/(double)i);
00158     i += 1;
00159     aup += 1.0;
00160     upterm = (aup+b-2.0e0)*xx/(aup-1.0)*upterm;
00161     betup -= upterm;
00162     sum += (xmult*betup);
00163     goto S50;
00164 S70:
00165     *cum = sum;
00166     *ccum = 0.5e0+(0.5e0-*cum);
00167     return;
00168 #undef qsmall
00169 #undef half
00170 #undef done
00171 } /* END */
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 2 of file cdf_31.c. Referenced by cdfgam(), and cumchi(). 
 00044 {
00045 static int K1 = 0;
00046 /*
00047      ..
00048      .. Executable Statements ..
00049 */
00050     if(!(*x <= 0.0e0)) goto S10;
00051     *cum = 0.0e0;
00052     *ccum = 1.0e0;
00053     return;
00054 S10:
00055     gratio(a,x,cum,ccum,&K1);
00056 /*
00057      Call gratio routine
00058 */
00059     return;
00060 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_32.c. Referenced by cdfnbn(). 
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 2 of file cdf_33.c. References a, arg, c, fifdint(), i, p, q, and spmpar(). Referenced by cdfnor(), and dinvnr(). 
 00025 : 00026 00027 Cody, W.D. (1993). "ALGORITHM 715: SPECFUN - A Portabel FORTRAN 00028 Package of Special Function Routines and Test Drivers" 00029 acm Transactions on Mathematical Software. 19, 22-32. 00030 00031 with slight modifications to return ccum and to deal with 00032 machine constants. 00033 00034 ********************************************************************** 00035 Original Comments: 00036 ------------------------------------------------------------------ 00037 00038 This function evaluates the normal distribution function: 00039 00040 / x 00041 1 | -t*t/2 00042 P(x) = ----------- | e dt 00043 sqrt(2 pi) | 00044 /-oo 00045 00046 The main computation evaluates near-minimax approximations 00047 derived from those in "Rational Chebyshev approximations for 00048 the error function" by W. J. Cody, Math. Comp., 1969, 631-637. 00049 This transportable program uses rational functions that 00050 theoretically approximate the normal distribution function to 00051 at least 18 significant decimal digits. The accuracy achieved 00052 depends on the arithmetic system, the compiler, the intrinsic 00053 functions, and proper selection of the machine-dependent 00054 constants. 00055 00056 ******************************************************************* 00057 ******************************************************************* 00058 00059 Explanation of machine-dependent constants. 00060 00061 MIN = smallest machine representable number. 00062 00063 EPS = argument below which anorm(x) may be represented by 00064 0.5 and above which x*x will not underflow. 00065 A conservative value is the largest machine number X 00066 such that 1.0 + X = 1.0 to machine precision. 00067 ******************************************************************* 00068 ******************************************************************* 00069 00070 Error returns 00071 00072 The program returns ANORM = 0 for ARG .LE. XLOW. 00073 00074 00075 Intrinsic functions required are: 00076 00077 ABS, AINT, EXP 00078 00079 00080 Author: W. J. Cody 00081 Mathematics and Computer Science Division 00082 Argonne National Laboratory 00083 Argonne, IL 60439 00084 00085 Latest modification: March 15, 1992 00086 00087 ------------------------------------------------------------------ 00088 */ 00089 { 00090 static double a[5] = { 00091 2.2352520354606839287e00,1.6102823106855587881e02,1.0676894854603709582e03, 00092 1.8154981253343561249e04,6.5682337918207449113e-2 00093 }; 00094 static double b[4] = { 00095 4.7202581904688241870e01,9.7609855173777669322e02,1.0260932208618978205e04, 00096 4.5507789335026729956e04 00097 }; 00098 static double c[9] = { 00099 3.9894151208813466764e-1,8.8831497943883759412e00,9.3506656132177855979e01, 00100 5.9727027639480026226e02,2.4945375852903726711e03,6.8481904505362823326e03, 00101 1.1602651437647350124e04,9.8427148383839780218e03,1.0765576773720192317e-8 00102 }; 00103 static double d[8] = { 00104 2.2266688044328115691e01,2.3538790178262499861e02,1.5193775994075548050e03, 00105 6.4855582982667607550e03,1.8615571640885098091e04,3.4900952721145977266e04, 00106 3.8912003286093271411e04,1.9685429676859990727e04 00107 }; 00108 static double half = 0.5e0; 00109 static double p[6] = { 00110 2.1589853405795699e-1,1.274011611602473639e-1,2.2235277870649807e-2, 00111 1.421619193227893466e-3,2.9112874951168792e-5,2.307344176494017303e-2 00112 }; 00113 static double one = 1.0e0; 00114 static double q[5] = { 00115 1.28426009614491121e00,4.68238212480865118e-1,6.59881378689285515e-2, 00116 3.78239633202758244e-3,7.29751555083966205e-5 00117 }; 00118 static double sixten = 1.60e0; 00119 static double sqrpi = 3.9894228040143267794e-1; 00120 static double thrsh = 0.66291e0; 00121 static double root32 = 5.656854248e0; 00122 static double zero = 0.0e0; 00123 static int K1 = 1; 00124 static int K2 = 2; 00125 static int i; 00126 static double del,eps,temp,x,xden,xnum,y,xsq,min; 00127 /* 00128 ------------------------------------------------------------------ 00129 Machine dependent constants 00130 ------------------------------------------------------------------ 00131 */ 00132 eps = spmpar(&K1)*0.5e0; 00133 min = spmpar(&K2); 00134 x = *arg; 00135 y = fabs(x); 00136 if(y <= thrsh) { 00137 /* 00138 ------------------------------------------------------------------ 00139 Evaluate anorm for |X| <= 0.66291 00140 ------------------------------------------------------------------ 00141 */ 00142 xsq = zero; 00143 if(y > eps) xsq = x*x; 00144 xnum = a[4]*xsq; 00145 xden = xsq; 00146 for(i=0; i<3; i++) { 00147 xnum = (xnum+a[i])*xsq; 00148 xden = (xden+b[i])*xsq; 00149 } 00150 *result = x*(xnum+a[3])/(xden+b[3]); 00151 temp = *result; 00152 *result = half+temp; 00153 *ccum = half-temp; 00154 } 00155 /* 00156 ------------------------------------------------------------------ 00157 Evaluate anorm for 0.66291 <= |X| <= sqrt(32) 00158 ------------------------------------------------------------------ 00159 */ 00160 else if(y <= root32) { 00161 xnum = c[8]*y; 00162 xden = y; 00163 for(i=0; i<7; i++) { 00164 xnum = (xnum+c[i])*y; 00165 xden = (xden+d[i])*y; 00166 } 00167 *result = (xnum+c[7])/(xden+d[7]); 00168 xsq = fifdint(y*sixten)/sixten; 00169 del = (y-xsq)*(y+xsq); 00170 *result = exp(-(xsq*xsq*half))*exp(-(del*half))**result; 00171 *ccum = one-*result; 00172 if(x > zero) { 00173 temp = *result; 00174 *result = *ccum; 00175 *ccum = temp; 00176 } 00177 } 00178 /* 00179 ------------------------------------------------------------------ 00180 Evaluate anorm for |X| > sqrt(32) 00181 ------------------------------------------------------------------ 00182 */ 00183 else { 00184 *result = zero; 00185 xsq = one/(x*x); 00186 xnum = p[5]*xsq; 00187 xden = xsq; 00188 for(i=0; i<4; i++) { 00189 xnum = (xnum+p[i])*xsq; 00190 xden = (xden+q[i])*xsq; 00191 } 00192 *result = xsq*(xnum+p[4])/(xden+q[4]); 00193 *result = (sqrpi-*result)/y; 00194 xsq = fifdint(x*sixten)/sixten; 00195 del = (x-xsq)*(x+xsq); 00196 *result = exp(-(xsq*xsq*half))*exp(-(del*half))**result; 00197 *ccum = one-*result; 00198 if(x > zero) { 00199 temp = *result; 00200 *result = *ccum; 00201 *ccum = temp; 00202 } 00203 } 00204 if(*result < min) *result = 0.0e0; 00205 /* 00206 ------------------------------------------------------------------ 00207 Fix up for negative argument, erf, etc. 00208 ------------------------------------------------------------------ 00209 ----------Last card of ANORM ---------- 00210 */ 00211 if(*ccum < min) *ccum = 0.0e0; } /* END */ | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 2 of file cdf_34.c. References cumchi(). Referenced by cdfpoi(). 
 00042 {
00043 static double chi,df;
00044 /*
00045      ..
00046      .. Executable Statements ..
00047 */
00048     df = 2.0e0*(*s+1.0e0);
00049     chi = 2.0e0**xlam;
00050     cumchi(&chi,&df,ccum,cum);
00051     return;
00052 } /* END */
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 2 of file cdf_35.c. References a, cumbet(), and tt. Referenced by cdft(). 
 00041 {
00042 static double K2 = 0.5e0;
00043 static double xx,a,oma,tt,yy,dfptt,T1;
00044 /*
00045      ..
00046      .. Executable Statements ..
00047 */
00048     tt = *t**t;
00049     dfptt = *df+tt;
00050     xx = *df/dfptt;
00051     yy = tt/dfptt;
00052     T1 = 0.5e0**df;
00053     cumbet(&xx,&yy,&T1,&K2,&a,&oma);
00054     if(!(*t <= 0.0e0)) goto S10;
00055     *cum = 0.5e0*a;
00056     *ccum = oma+*cum;
00057     goto S20;
00058 S10:
00059     *ccum = 0.5e0*a;
00060     *cum = oma+*ccum;
00061 S20:
00062     return;
00063 } /* END */
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_36.c. References a, dbetrm(), dstrem(), fifdmax1(), and fifdmin1(). Referenced by dbetrm(). 
 00035 {
00036 static double dbetrm,T1,T2,T3;
00037 /*
00038      ..
00039      .. Executable Statements ..
00040 */
00041 /*
00042      Try to sum from smallest to largest
00043 */
00044     T1 = *a+*b;
00045     dbetrm = -dstrem(&T1);
00046     T2 = fifdmax1(*a,*b);
00047     dbetrm += dstrem(&T2);
00048     T3 = fifdmin1(*a,*b);
00049     dbetrm += dstrem(&T3);
00050     return dbetrm;
00051 } /* END */
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 2 of file cdf_37.c. References a, devlpl(), and i. Referenced by alngam(), devlpl(), dlanor(), dstrem(), dt1(), and stvaln(). 
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_38.c. References dexpm1(). Referenced by dexpm1(). 
 00020                                            :
00021  
00022      DiDinato, A. R. and Morris,  A.   H.  Algorithm 708: Significant
00023      Digit Computation of the Incomplete  Beta  Function Ratios.  ACM
00024      Trans. Math.  Softw. 18 (1993), 360-373.
00025  
00026 **********************************************************************
00027 */
00028 {
00029 static double p1 = .914041914819518e-09;
00030 static double p2 = .238082361044469e-01;
00031 static double q1 = -.499999999085958e+00;
00032 static double q2 = .107141568980644e+00;
00033 static double q3 = -.119041179760821e-01;
00034 static double q4 = .595130811860248e-03;
00035 static double dexpm1,w;
00036 /*
00037      ..
00038      .. Executable Statements ..
00039 */
00040     if(fabs(*x) > 0.15e0) goto S10;
00041     dexpm1 = *x*(((p2**x+p1)**x+1.0e0)/((((q4**x+q3)**x+q2)**x+q1)**x+1.0e0));
00042     return dexpm1;
00043 S10:
00044     w = exp(*x);
00045     if(*x > 0.0e0) goto S20;
00046     dexpm1 = w-0.5e0-0.5e0;
00047     return dexpm1;
00048 S20:
00049     dexpm1 = w*(0.5e0+(0.5e0-1.0e0/w));
00050     return dexpm1;
} /* END */
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_39.c. References cumnor(), dinvnr(), i, p, q, and stvaln(). Referenced by cdfnor(), dinvnr(), and dt1(). 
 00042 {
00043 #define maxit 100
00044 #define eps (1.0e-13)
00045 #define r2pi 0.3989422804014326e0
00046 #define nhalf (-0.5e0)
00047 #define dennor(x) (r2pi*exp(nhalf*(x)*(x)))
00048 static double dinvnr,strtx,xcur,cum,ccum,pp,dx;
00049 static int i;
00050 static unsigned long qporq;
00051 /*
00052      ..
00053      .. Executable Statements ..
00054 */
00055 /*
00056      FIND MINIMUM OF P AND Q
00057 */
00058     qporq = *p <= *q;
00059     if(!qporq) goto S10;
00060     pp = *p;
00061     goto S20;
00062 S10:
00063     pp = *q;
00064 S20:
00065 /*
00066      INITIALIZATION STEP
00067 */
00068     strtx = stvaln(&pp);
00069     xcur = strtx;
00070 /*
00071      NEWTON INTERATIONS
00072 */
00073     for(i=1; i<=maxit; i++) {
00074         cumnor(&xcur,&cum,&ccum);
00075         dx = (cum-pp)/dennor(xcur);
00076         xcur -= dx;
00077         if(fabs(dx/xcur) < eps) goto S40;
00078     }
00079     dinvnr = strtx;
00080 /*
00081      IF WE GET HERE, NEWTON HAS FAILED
00082 */
00083     if(!qporq) dinvnr = -dinvnr;
00084     return dinvnr;
00085 S40:
00086 /*
00087      IF WE GET HERE, NEWTON HAS SUCCEDED
00088 */
00089     dinvnr = xcur;
00090     if(!qporq) dinvnr = -dinvnr;
00091     return dinvnr;
00092 #undef maxit
00093 #undef eps
00094 #undef r2pi
00095 #undef nhalf
00096 #undef dennor
00097 } /* END */
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_41.c. References E0000(). Referenced by cdfbet(), cdfbin(), cdfchi(), cdfchn(), cdff(), cdffnc(), cdfgam(), cdfnbn(), cdfpoi(), and cdft(). 
 00064 {
00065     E0000(0,status,x,fx,qleft,qhi,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
00066 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_43.c. References devlpl(), dlanor(), dln1px(), and ftnstop(). Referenced by dlanor(). 
 00038 {
00039 #define dlsqpi 0.91893853320467274177e0
00040 static double coef[12] = {
00041     -1.0e0,3.0e0,-15.0e0,105.0e0,-945.0e0,10395.0e0,-135135.0e0,2027025.0e0,
00042     -34459425.0e0,654729075.0e0,-13749310575.e0,316234143225.0e0
00043 };
00044 static int K1 = 12;
00045 static double dlanor,approx,correc,xx,xx2,T2;
00046 /*
00047      ..
00048      .. Executable Statements ..
00049 */
00050     xx = fabs(*x);
00051     if(xx < 5.0e0) ftnstop(" Argument too small in DLANOR");
00052     approx = -dlsqpi-0.5e0*xx*xx-log(xx);
00053     xx2 = xx*xx;
00054     T2 = 1.0e0/xx2;
00055     correc = devlpl(coef,&K1,&T2)/xx2;
00056     correc = dln1px(&correc);
00057     dlanor = approx+correc;
00058     return dlanor;
00059 #undef dlsqpi
00060 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_44.c. References dln1mx(), and dln1px(). Referenced by dln1mx(). 
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_45.c. Referenced by dlanor(), dln1mx(), and dln1px(). 
 00029                         :
00030      DiDinato, A. R. and Morris,  A.   H.  Algorithm 708: Significant
00031      Digit Computation of the Incomplete  Beta  Function Ratios.  ACM
00032      Trans. Math.  Softw. 18 (1993), 360-373.
00033  
00034 **********************************************************************
00035 -----------------------------------------------------------------------
00036             EVALUATION OF THE FUNCTION LN(1 + A)
00037 -----------------------------------------------------------------------
00038 */
00039 {
00040 static double p1 = -.129418923021993e+01;
00041 static double p2 = .405303492862024e+00;
00042 static double p3 = -.178874546012214e-01;
00043 static double q1 = -.162752256355323e+01;
00044 static double q2 = .747811014037616e+00;
00045 static double q3 = -.845104217945565e-01;
00046 static double dln1px,t,t2,w,x;
00047 /*
00048      ..
00049      .. Executable Statements ..
00050 */
00051     if(fabs(*a) > 0.375e0) goto S10;
00052     t = *a/(*a+2.0e0);
00053     t2 = t*t;
00054     w = (((p3*t2+p2)*t2+p1)*t2+1.0e0)/(((q3*t2+q2)*t2+q1)*t2+1.0e0);
00055     dln1px = 2.0e0*t*w;
00056     return dln1px;
00057 S10:
00058     x = 1.e0+*a;
00059     dln1px = log(x);
00060     return dln1px;
} /* END */
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_46.c. References a, algdiv(), alnrel(), bcorr(), c, dlnbet(), fifdmax1(), fifdmin1(), gamln(), gsumln(), i, and v. Referenced by dlnbet(). 
 00029 : 00030 DiDinato, A. R. and Morris, A. H. Algorithm 708: Significant 00031 Digit Computation of the Incomplete Beta Function Ratios. ACM 00032 Trans. Math. Softw. 18 (1993), 360-373. 00033 00034 ********************************************************************** 00035 ----------------------------------------------------------------------- 00036 EVALUATION OF THE LOGARITHM OF THE BETA FUNCTION 00037 ----------------------------------------------------------------------- 00038 E = 0.5*LN(2*PI) 00039 -------------------------- 00040 */ 00041 { 00042 static double e = .918938533204673e0; 00043 static double dlnbet,a,b,c,h,u,v,w,z; 00044 static int i,n; 00045 static double T1; 00046 /* 00047 .. 00048 .. Executable Statements .. 00049 */ 00050 a = fifdmin1(*a0,*b0); 00051 b = fifdmax1(*a0,*b0); 00052 if(a >= 8.0e0) goto S100; 00053 if(a >= 1.0e0) goto S20; 00054 /* 00055 ----------------------------------------------------------------------- 00056 PROCEDURE WHEN A .LT. 1 00057 ----------------------------------------------------------------------- 00058 */ 00059 if(b >= 8.0e0) goto S10; 00060 T1 = a+b; 00061 dlnbet = gamln(&a)+(gamln(&b)-gamln(&T1)); 00062 return dlnbet; 00063 S10: 00064 dlnbet = gamln(&a)+algdiv(&a,&b); 00065 return dlnbet; 00066 S20: 00067 /* 00068 ----------------------------------------------------------------------- 00069 PROCEDURE WHEN 1 .LE. A .LT. 8 00070 ----------------------------------------------------------------------- 00071 */ 00072 if(a > 2.0e0) goto S40; 00073 if(b > 2.0e0) goto S30; 00074 dlnbet = gamln(&a)+gamln(&b)-gsumln(&a,&b); 00075 return dlnbet; 00076 S30: 00077 w = 0.0e0; 00078 if(b < 8.0e0) goto S60; 00079 dlnbet = gamln(&a)+algdiv(&a,&b); 00080 return dlnbet; 00081 S40: 00082 /* 00083 REDUCTION OF A WHEN B .LE. 1000 00084 */ 00085 if(b > 1000.0e0) goto S80; 00086 n = a-1.0e0; 00087 w = 1.0e0; 00088 for(i=1; i<=n; i++) { 00089 a -= 1.0e0; 00090 h = a/b; 00091 w *= (h/(1.0e0+h)); 00092 } 00093 w = log(w); 00094 if(b < 8.0e0) goto S60; 00095 dlnbet = w+gamln(&a)+algdiv(&a,&b); 00096 return dlnbet; 00097 S60: 00098 /* 00099 REDUCTION OF B WHEN B .LT. 8 00100 */ 00101 n = b-1.0e0; 00102 z = 1.0e0; 00103 for(i=1; i<=n; i++) { 00104 b -= 1.0e0; 00105 z *= (b/(a+b)); 00106 } 00107 dlnbet = w+log(z)+(gamln(&a)+(gamln(&b)-gsumln(&a,&b))); 00108 return dlnbet; 00109 S80: 00110 /* 00111 REDUCTION OF A WHEN B .GT. 1000 00112 */ 00113 n = a-1.0e0; 00114 w = 1.0e0; 00115 for(i=1; i<=n; i++) { 00116 a -= 1.0e0; 00117 w *= (a/(1.0e0+a/b)); 00118 } 00119 dlnbet = log(w)-(double)n*log(b)+(gamln(&a)+algdiv(&a,&b)); 00120 return dlnbet; 00121 S100: 00122 /* 00123 ----------------------------------------------------------------------- 00124 PROCEDURE WHEN A .GE. 8 00125 ----------------------------------------------------------------------- 00126 */ 00127 w = bcorr(&a,&b); 00128 h = a/b; 00129 c = h/(1.0e0+h); 00130 u = -((a-0.5e0)*log(c)); 00131 v = b*alnrel(&h); 00132 if(u <= v) goto S110; 00133 dlnbet = -(0.5e0*log(b))+e+w-v-u; 00134 return dlnbet; 00135 S110: 00136 dlnbet = -(0.5e0*log(b))+e+w-u-v; 00137 return dlnbet; } /* END */ | 
| 
 | 
| 
 Definition at line 2 of file cdf_47.c. References a, dlngam(), gamln1(), and i. Referenced by dlngam(), and dstrem(). 
 00026 : 00027 DiDinato, A. R. and Morris, A. H. Algorithm 708: Significant 00028 Digit Computation of the Incomplete Beta Function Ratios. ACM 00029 Trans. Math. Softw. 18 (1993), 360-373. 00030 00031 ********************************************************************** 00032 ----------------------------------------------------------------------- 00033 EVALUATION OF LN(GAMMA(A)) FOR POSITIVE A 00034 ----------------------------------------------------------------------- 00035 WRITTEN BY ALFRED H. MORRIS 00036 NAVAL SURFACE WARFARE CENTER 00037 DAHLGREN, VIRGINIA 00038 -------------------------- 00039 D = 0.5*(LN(2*PI) - 1) 00040 -------------------------- 00041 */ 00042 { 00043 static double c0 = .833333333333333e-01; 00044 static double c1 = -.277777777760991e-02; 00045 static double c2 = .793650666825390e-03; 00046 static double c3 = -.595202931351870e-03; 00047 static double c4 = .837308034031215e-03; 00048 static double c5 = -.165322962780713e-02; 00049 static double d = .418938533204673e0; 00050 static double dlngam,t,w; 00051 static int i,n; 00052 static double T1; 00053 /* 00054 .. 00055 .. Executable Statements .. 00056 */ 00057 if(*a > 0.8e0) goto S10; 00058 dlngam = gamln1(a)-log(*a); 00059 return dlngam; 00060 S10: 00061 if(*a > 2.25e0) goto S20; 00062 t = *a-0.5e0-0.5e0; 00063 dlngam = gamln1(&t); 00064 return dlngam; 00065 S20: 00066 if(*a >= 10.0e0) goto S40; 00067 n = *a-1.25e0; 00068 t = *a; 00069 w = 1.0e0; 00070 for(i=1; i<=n; i++) { 00071 t -= 1.0e0; 00072 w = t*w; 00073 } 00074 T1 = t-1.0e0; 00075 dlngam = gamln1(&T1)+log(w); 00076 return dlngam; 00077 S40: 00078 t = pow(1.0e0/ *a,2.0); 00079 w = (((((c5*t+c4)*t+c3)*t+c2)*t+c1)*t+c0)/ *a; 00080 dlngam = d+w+(*a-0.5e0)*(log(*a)-1.0e0); 00081 return dlngam; } /* END */ | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_42.c. References E0000(). Referenced by cdfbet(), cdfbin(), cdfchi(), cdfchn(), cdff(), cdffnc(), cdfgam(), cdfnbn(), cdfpoi(), and cdft(). 
 00069 {
00070     E0000(1,NULL,NULL,NULL,NULL,NULL,zabsst,zabsto,zbig,zrelst,zrelto,zsmall,
00071     zstpmu);
00072 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_48.c. References devlpl(), dlngam(), dstrem(), and ftnstop(). Referenced by dbetrm(), and dstrem(). 
 00003 {
00004 /*
00005 **********************************************************************
00006      double dstrem(double *z)
00007              Double precision Sterling Remainder
00008                               Function
00009      Returns   Log(Gamma(Z))  -  Sterling(Z)  where   Sterling(Z)  is
00010      Sterling's Approximation to Log(Gamma(Z))
00011      Sterling(Z) = LOG( SQRT( 2*PI ) ) + ( Z-0.5 ) * LOG( Z ) - Z
00012                               Arguments
00013      Z --> Value at which Sterling remainder calculated
00014            Must be positive.
00015                   DOUBLE PRECISION Z
00016                               Method
00017      If Z >= 6 uses 9 terms of series in Bernoulli numbers
00018      (Values calculated using Maple)
00019      Otherwise computes difference explicitly
00020 **********************************************************************
00021 */
00022 #define hln2pi 0.91893853320467274178e0
00023 #define ncoef 10
00024 static double coef[ncoef] = {
00025     0.0e0,0.0833333333333333333333333333333e0,
00026     -0.00277777777777777777777777777778e0,0.000793650793650793650793650793651e0,
00027     -0.000595238095238095238095238095238e0,
00028     0.000841750841750841750841750841751e0,-0.00191752691752691752691752691753e0,
00029     0.00641025641025641025641025641026e0,-0.0295506535947712418300653594771e0,
00030     0.179644372368830573164938490016e0
00031 };
00032 static int K1 = 10;
00033 static double dstrem,sterl,T2;
00034 /*
00035      ..
00036      .. Executable Statements ..
00037 */
00038 /*
00039     For information, here are the next 11 coefficients of the
00040     remainder term in Sterling's formula
00041             -1.39243221690590111642743221691
00042             13.4028640441683919944789510007
00043             -156.848284626002017306365132452
00044             2193.10333333333333333333333333
00045             -36108.7712537249893571732652192
00046             691472.268851313067108395250776
00047             -0.152382215394074161922833649589D8
00048             0.382900751391414141414141414141D9
00049             -0.108822660357843910890151491655D11
00050             0.347320283765002252252252252252D12
00051             -0.123696021422692744542517103493D14
00052 */
00053     if(*z <= 0.0e0) ftnstop("Zero or negative argument in DSTREM");
00054     if(!(*z > 6.0e0)) goto S10;
00055     T2 = 1.0e0/pow(*z,2.0);
00056     dstrem = devlpl(coef,&K1,&T2)**z;
00057     goto S20;
00058 S10:
00059     sterl = hln2pi+(*z-0.5e0)*log(*z)-*z;
00060     dstrem = dlngam(z)-sterl;
00061 S20:
00062     return dstrem;
00063 #undef hln2pi
00064 #undef ncoef
00065 } /* END */
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 2 of file cdf_52.c. References E0001(). Referenced by cdfbet(), cdfbin(), cdfnbn(), and E0000(). 
 00046 {
00047     E0001(1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,zabstl,zreltl,zxhi,zxlo);
00048 } /* END */
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 2 of file cdf_49.c. References devlpl(), dinvnr(), dt1(), i, p, and q. Referenced by cdft(), and dt1(). 
 00034 {
00035 static double coef[4][5] = {
00036     1.0e0,1.0e0,0.0e0,0.0e0,0.0e0,3.0e0,16.0e0,5.0e0,0.0e0,0.0e0,-15.0e0,17.0e0,
00037     19.0e0,3.0e0,0.0e0,-945.0e0,-1920.0e0,1482.0e0,776.0e0,79.0e0
00038 };
00039 static double denom[4] = {
00040     4.0e0,96.0e0,384.0e0,92160.0e0
00041 };
00042 static int ideg[4] = {
00043     2,3,4,5
00044 };
00045 static double dt1,denpow,sum,term,x,xp,xx;
00046 static int i;
00047 /*
00048      ..
00049      .. Executable Statements ..
00050 */
00051     x = fabs(dinvnr(p,q));
00052     xx = x*x;
00053     sum = x;
00054     denpow = 1.0e0;
00055     for(i=0; i<4; i++) {
00056         term = devlpl(&coef[i][0],&ideg[i],&xx)*x;
00057         denpow *= *df;
00058         sum += (term/(denpow*denom[i]));
00059     }
00060     if(!(*p >= 0.5e0)) goto S20;
00061     xp = sum;
00062     goto S30;
00063 S20:
00064     xp = -sum;
00065 S30:
00066     dt1 = xp;
00067     return dt1;
00068 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_51.c. References E0001(). Referenced by cdfbet(), cdfbin(), cdfnbn(), and E0000(). 
 00067 {
00068     E0001(0,status,x,fx,xlo,xhi,qleft,qhi,NULL,NULL,NULL,NULL);
00069 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_40.c. References dstzr(), dzror(), fifdmax1(), fifdmin1(), and ftnstop(). Referenced by dinvr(), and dstinv(). 
 00006 {
00007 #define qxmon(zx,zy,zz) (int)((zx) <= (zy) && (zy) <= (zz))
00008 static double absstp,abstol,big,fbig,fsmall,relstp,reltol,small,step,stpmul,xhi,
00009     xlb,xlo,xsave,xub,yy;
00010 static int i99999;
00011 static unsigned long qbdd,qcond,qdum1,qdum2,qincr,qlim,qok,qup;
00012     switch(IENTRY){case 0: goto DINVR; case 1: goto DSTINV;}
00013 DINVR:
00014     if(*status > 0) goto S310;
00015     qcond = !qxmon(small,*x,big);
00016     if(qcond) ftnstop(" SMALL, X, BIG not monotone in INVR");
00017     xsave = *x;
00018 /*
00019      See that SMALL and BIG bound the zero and set QINCR
00020 */
00021     *x = small;
00022 /*
00023      GET-FUNCTION-VALUE
00024 */
00025     i99999 = 1;
00026     goto S300;
00027 S10:
00028     fsmall = *fx;
00029     *x = big;
00030 /*
00031      GET-FUNCTION-VALUE
00032 */
00033     i99999 = 2;
00034     goto S300;
00035 S20:
00036     fbig = *fx;
00037     qincr = fbig > fsmall;
00038     if(!qincr) goto S50;
00039     if(fsmall <= 0.0e0) goto S30;
00040     *status = -1;
00041     *qleft = *qhi = 1;
00042     return;
00043 S30:
00044     if(fbig >= 0.0e0) goto S40;
00045     *status = -1;
00046     *qleft = *qhi = 0;
00047     return;
00048 S40:
00049     goto S80;
00050 S50:
00051     if(fsmall >= 0.0e0) goto S60;
00052     *status = -1;
00053     *qleft = 1;
00054     *qhi = 0;
00055     return;
00056 S60:
00057     if(fbig <= 0.0e0) goto S70;
00058     *status = -1;
00059     *qleft = 0;
00060     *qhi = 1;
00061     return;
00062 S80:
00063 S70:
00064     *x = xsave;
00065     step = fifdmax1(absstp,relstp*fabs(*x));
00066 /*
00067       YY = F(X) - Y
00068      GET-FUNCTION-VALUE
00069 */
00070     i99999 = 3;
00071     goto S300;
00072 S90:
00073     yy = *fx;
00074     if(!(yy == 0.0e0)) goto S100;
00075     *status = 0;
00076     qok = 1;
00077     return;
00078 S100:
00079     qup = qincr && yy < 0.0e0 || !qincr && yy > 0.0e0;
00080 /*
00081 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00082      HANDLE CASE IN WHICH WE MUST STEP HIGHER
00083 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00084 */
00085     if(!qup) goto S170;
00086     xlb = xsave;
00087     xub = fifdmin1(xlb+step,big);
00088     goto S120;
00089 S110:
00090     if(qcond) goto S150;
00091 S120:
00092 /*
00093       YY = F(XUB) - Y
00094 */
00095     *x = xub;
00096 /*
00097      GET-FUNCTION-VALUE
00098 */
00099     i99999 = 4;
00100     goto S300;
00101 S130:
00102     yy = *fx;
00103     qbdd = qincr && yy >= 0.0e0 || !qincr && yy <= 0.0e0;
00104     qlim = xub >= big;
00105     qcond = qbdd || qlim;
00106     if(qcond) goto S140;
00107     step = stpmul*step;
00108     xlb = xub;
00109     xub = fifdmin1(xlb+step,big);
00110 S140:
00111     goto S110;
00112 S150:
00113     if(!(qlim && !qbdd)) goto S160;
00114     *status = -1;
00115     *qleft = 0;
00116     *qhi = !qincr;
00117     *x = big;
00118     return;
00119 S160:
00120     goto S240;
00121 S170:
00122 /*
00123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00124      HANDLE CASE IN WHICH WE MUST STEP LOWER
00125 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00126 */
00127     xub = xsave;
00128     xlb = fifdmax1(xub-step,small);
00129     goto S190;
00130 S180:
00131     if(qcond) goto S220;
00132 S190:
00133 /*
00134       YY = F(XLB) - Y
00135 */
00136     *x = xlb;
00137 /*
00138      GET-FUNCTION-VALUE
00139 */
00140     i99999 = 5;
00141     goto S300;
00142 S200:
00143     yy = *fx;
00144     qbdd = qincr && yy <= 0.0e0 || !qincr && yy >= 0.0e0;
00145     qlim = xlb <= small;
00146     qcond = qbdd || qlim;
00147     if(qcond) goto S210;
00148     step = stpmul*step;
00149     xub = xlb;
00150     xlb = fifdmax1(xub-step,small);
00151 S210:
00152     goto S180;
00153 S220:
00154     if(!(qlim && !qbdd)) goto S230;
00155     *status = -1;
00156     *qleft = 1;
00157     *qhi = qincr;
00158     *x = small;
00159     return;
00160 S240:
00161 S230:
00162     dstzr(&xlb,&xub,&abstol,&reltol);
00163 /*
00164 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00165      IF WE REACH HERE, XLB AND XUB BOUND THE ZERO OF F.
00166 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00167 */
00168     *status = 0;
00169     goto S260;
00170 S250:
00171     if(!(*status == 1)) goto S290;
00172 S260:
00173     dzror(status,x,fx,&xlo,&xhi,&qdum1,&qdum2);
00174     if(!(*status == 1)) goto S280;
00175 /*
00176      GET-FUNCTION-VALUE
00177 */
00178     i99999 = 6;
00179     goto S300;
00180 S280:
00181 S270:
00182     goto S250;
00183 S290:
00184     *x = xlo;
00185     *status = 0;
00186     return;
00187 DSTINV:
00188     small = *zsmall;
00189     big = *zbig;
00190     absstp = *zabsst;
00191     relstp = *zrelst;
00192     stpmul = *zstpmu;
00193     abstol = *zabsto;
00194     reltol = *zrelto;
00195     return;
00196 S300:
00197 /*
00198      TO GET-FUNCTION-VALUE
00199 */
00200     *status = 1;
00201     return;
00202 S310:
00203     switch((int)i99999){case 1: goto S10;case 2: goto S20;case 3: goto S90;case 
00204       4: goto S130;case 5: goto S200;case 6: goto S270;default: break;}
00205 #undef qxmon
00206 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_50.c. References a, c, fa, fb, fd, fifdsign(), p, and q. Referenced by dstzr(), and dzror(). 
 00006 {
00007 #define ftol(zx) (0.5e0*fifdmax1(abstol,reltol*fabs((zx))))
00008 static double a,abstol,b,c,d,fa,fb,fc,fd,fda,fdb,m,mb,p,q,reltol,tol,w,xxhi,xxlo;
00009 static int ext,i99999;
00010 static unsigned long first,qrzero;
00011     switch(IENTRY){case 0: goto DZROR; case 1: goto DSTZR;}
00012 DZROR:
00013     if(*status > 0) goto S280;
00014     *xlo = xxlo;
00015     *xhi = xxhi;
00016     b = *x = *xlo;
00017 /*
00018      GET-FUNCTION-VALUE
00019 */
00020     i99999 = 1;
00021     goto S270;
00022 S10:
00023     fb = *fx;
00024     *xlo = *xhi;
00025     a = *x = *xlo;
00026 /*
00027      GET-FUNCTION-VALUE
00028 */
00029     i99999 = 2;
00030     goto S270;
00031 S20:
00032 /*
00033      Check that F(ZXLO) < 0 < F(ZXHI)  or
00034                 F(ZXLO) > 0 > F(ZXHI)
00035 */
00036     if(!(fb < 0.0e0)) goto S40;
00037     if(!(*fx < 0.0e0)) goto S30;
00038     *status = -1;
00039     *qleft = *fx < fb;
00040     *qhi = 0;
00041     return;
00042 S40:
00043 S30:
00044     if(!(fb > 0.0e0)) goto S60;
00045     if(!(*fx > 0.0e0)) goto S50;
00046     *status = -1;
00047     *qleft = *fx > fb;
00048     *qhi = 1;
00049     return;
00050 S60:
00051 S50:
00052     fa = *fx;
00053     first = 1;
00054 S70:
00055     c = a;
00056     fc = fa;
00057     ext = 0;
00058 S80:
00059     if(!(fabs(fc) < fabs(fb))) goto S100;
00060     if(!(c != a)) goto S90;
00061     d = a;
00062     fd = fa;
00063 S90:
00064     a = b;
00065     fa = fb;
00066     *xlo = c;
00067     b = *xlo;
00068     fb = fc;
00069     c = a;
00070     fc = fa;
00071 S100:
00072     tol = ftol(*xlo);
00073     m = (c+b)*.5e0;
00074     mb = m-b;
00075     if(!(fabs(mb) > tol)) goto S240;
00076     if(!(ext > 3)) goto S110;
00077     w = mb;
00078     goto S190;
00079 S110:
00080     tol = fifdsign(tol,mb);
00081     p = (b-a)*fb;
00082     if(!first) goto S120;
00083     q = fa-fb;
00084     first = 0;
00085     goto S130;
00086 S120:
00087     fdb = (fd-fb)/(d-b);
00088     fda = (fd-fa)/(d-a);
00089     p = fda*p;
00090     q = fdb*fa-fda*fb;
00091 S130:
00092     if(!(p < 0.0e0)) goto S140;
00093     p = -p;
00094     q = -q;
00095 S140:
00096     if(ext == 3) p *= 2.0e0;
00097     if(!(p*1.0e0 == 0.0e0 || p <= q*tol)) goto S150;
00098     w = tol;
00099     goto S180;
00100 S150:
00101     if(!(p < mb*q)) goto S160;
00102     w = p/q;
00103     goto S170;
00104 S160:
00105     w = mb;
00106 S190:
00107 S180:
00108 S170:
00109     d = a;
00110     fd = fa;
00111     a = b;
00112     fa = fb;
00113     b += w;
00114     *xlo = b;
00115     *x = *xlo;
00116 /*
00117      GET-FUNCTION-VALUE
00118 */
00119     i99999 = 3;
00120     goto S270;
00121 S200:
00122     fb = *fx;
00123     if(!(fc*fb >= 0.0e0)) goto S210;
00124     goto S70;
00125 S210:
00126     if(!(w == mb)) goto S220;
00127     ext = 0;
00128     goto S230;
00129 S220:
00130     ext += 1;
00131 S230:
00132     goto S80;
00133 S240:
00134     *xhi = c;
00135     qrzero = fc >= 0.0e0 && fb <= 0.0e0 || fc < 0.0e0 && fb >= 0.0e0;
00136     if(!qrzero) goto S250;
00137     *status = 0;
00138     goto S260;
00139 S250:
00140     *status = -1;
00141 S260:
00142     return;
00143 DSTZR:
00144     xxlo = *zxlo;
00145     xxhi = *zxhi;
00146     abstol = *zabstl;
00147     reltol = *zreltl;
00148     return;
00149 S270:
00150 /*
00151      TO GET-FUNCTION-VALUE
00152 */
00153     *status = 1;
00154     return;
00155 S280:
00156     switch((int)i99999){case 1: goto S10;case 2: goto S20;case 3: goto S200;
00157       default: break;}
00158 #undef ftol
00159 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_53.c. References a, c, erf1(), fifdsign(), p, q, r, top, and x2. Referenced by erf1(), grat1(), and gratio(). 
 00008 {
00009 static double c = .564189583547756e0;
00010 static double a[5] = {
00011     .771058495001320e-04,-.133733772997339e-02,.323076579225834e-01,
00012     .479137145607681e-01,.128379167095513e+00
00013 };
00014 static double b[3] = {
00015     .301048631703895e-02,.538971687740286e-01,.375795757275549e+00
00016 };
00017 static double p[8] = {
00018     -1.36864857382717e-07,5.64195517478974e-01,7.21175825088309e+00,
00019     4.31622272220567e+01,1.52989285046940e+02,3.39320816734344e+02,
00020     4.51918953711873e+02,3.00459261020162e+02
00021 };
00022 static double q[8] = {
00023     1.00000000000000e+00,1.27827273196294e+01,7.70001529352295e+01,
00024     2.77585444743988e+02,6.38980264465631e+02,9.31354094850610e+02,
00025     7.90950925327898e+02,3.00459260956983e+02
00026 };
00027 static double r[5] = {
00028     2.10144126479064e+00,2.62370141675169e+01,2.13688200555087e+01,
00029     4.65807828718470e+00,2.82094791773523e-01
00030 };
00031 static double s[4] = {
00032     9.41537750555460e+01,1.87114811799590e+02,9.90191814623914e+01,
00033     1.80124575948747e+01
00034 };
00035 static double erf1,ax,bot,t,top,x2;
00036 /*
00037      ..
00038      .. Executable Statements ..
00039 */
00040     ax = fabs(*x);
00041     if(ax > 0.5e0) goto S10;
00042     t = *x**x;
00043     top = (((a[0]*t+a[1])*t+a[2])*t+a[3])*t+a[4]+1.0e0;
00044     bot = ((b[0]*t+b[1])*t+b[2])*t+1.0e0;
00045     erf1 = *x*(top/bot);
00046     return erf1;
00047 S10:
00048     if(ax > 4.0e0) goto S20;
00049     top = ((((((p[0]*ax+p[1])*ax+p[2])*ax+p[3])*ax+p[4])*ax+p[5])*ax+p[6])*ax+p[
00050       7];
00051     bot = ((((((q[0]*ax+q[1])*ax+q[2])*ax+q[3])*ax+q[4])*ax+q[5])*ax+q[6])*ax+q[
00052       7];
00053     erf1 = 0.5e0+(0.5e0-exp(-(*x**x))*top/bot);
00054     if(*x < 0.0e0) erf1 = -erf1;
00055     return erf1;
00056 S20:
00057     if(ax >= 5.8e0) goto S30;
00058     x2 = *x**x;
00059     t = 1.0e0/x2;
00060     top = (((r[0]*t+r[1])*t+r[2])*t+r[3])*t+r[4];
00061     bot = (((s[0]*t+s[1])*t+s[2])*t+s[3])*t+1.0e0;
00062     erf1 = (c-top/(x2*bot))/ax;
00063     erf1 = 0.5e0+(0.5e0-exp(-x2)*erf1);
00064     if(*x < 0.0e0) erf1 = -erf1;
00065     return erf1;
00066 S30:
00067     erf1 = fifdsign(1.0e0,*x);
00068     return erf1;
00069 } /* END */
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_54.c. References a, c, erfc1(), exparg(), ind, p, q, r, and top. Referenced by basym(), erfc1(), grat1(), and gratio(). 
 00011 {
00012 static double c = .564189583547756e0;
00013 static double a[5] = {
00014     .771058495001320e-04,-.133733772997339e-02,.323076579225834e-01,
00015     .479137145607681e-01,.128379167095513e+00
00016 };
00017 static double b[3] = {
00018     .301048631703895e-02,.538971687740286e-01,.375795757275549e+00
00019 };
00020 static double p[8] = {
00021     -1.36864857382717e-07,5.64195517478974e-01,7.21175825088309e+00,
00022     4.31622272220567e+01,1.52989285046940e+02,3.39320816734344e+02,
00023     4.51918953711873e+02,3.00459261020162e+02
00024 };
00025 static double q[8] = {
00026     1.00000000000000e+00,1.27827273196294e+01,7.70001529352295e+01,
00027     2.77585444743988e+02,6.38980264465631e+02,9.31354094850610e+02,
00028     7.90950925327898e+02,3.00459260956983e+02
00029 };
00030 static double r[5] = {
00031     2.10144126479064e+00,2.62370141675169e+01,2.13688200555087e+01,
00032     4.65807828718470e+00,2.82094791773523e-01
00033 };
00034 static double s[4] = {
00035     9.41537750555460e+01,1.87114811799590e+02,9.90191814623914e+01,
00036     1.80124575948747e+01
00037 };
00038 static int K1 = 1;
00039 static double erfc1,ax,bot,e,t,top,w;
00040 /*
00041      ..
00042      .. Executable Statements ..
00043 */
00044 /*
00045                      ABS(X) .LE. 0.5
00046 */
00047     ax = fabs(*x);
00048     if(ax > 0.5e0) goto S10;
00049     t = *x**x;
00050     top = (((a[0]*t+a[1])*t+a[2])*t+a[3])*t+a[4]+1.0e0;
00051     bot = ((b[0]*t+b[1])*t+b[2])*t+1.0e0;
00052     erfc1 = 0.5e0+(0.5e0-*x*(top/bot));
00053     if(*ind != 0) erfc1 = exp(t)*erfc1;
00054     return erfc1;
00055 S10:
00056 /*
00057                   0.5 .LT. ABS(X) .LE. 4
00058 */
00059     if(ax > 4.0e0) goto S20;
00060     top = ((((((p[0]*ax+p[1])*ax+p[2])*ax+p[3])*ax+p[4])*ax+p[5])*ax+p[6])*ax+p[
00061       7];
00062     bot = ((((((q[0]*ax+q[1])*ax+q[2])*ax+q[3])*ax+q[4])*ax+q[5])*ax+q[6])*ax+q[
00063       7];
00064     erfc1 = top/bot;
00065     goto S40;
00066 S20:
00067 /*
00068                       ABS(X) .GT. 4
00069 */
00070     if(*x <= -5.6e0) goto S60;
00071     if(*ind != 0) goto S30;
00072     if(*x > 100.0e0) goto S70;
00073     if(*x**x > -exparg(&K1)) goto S70;
00074 S30:
00075     t = pow(1.0e0/ *x,2.0);
00076     top = (((r[0]*t+r[1])*t+r[2])*t+r[3])*t+r[4];
00077     bot = (((s[0]*t+s[1])*t+s[2])*t+s[3])*t+1.0e0;
00078     erfc1 = (c-t*top/bot)/ax;
00079 S40:
00080 /*
00081                       FINAL ASSEMBLY
00082 */
00083     if(*ind == 0) goto S50;
00084     if(*x < 0.0e0) erfc1 = 2.0e0*exp(*x**x)-erfc1;
00085     return erfc1;
00086 S50:
00087     w = *x**x;
00088     t = w;
00089     e = w-t;
00090     erfc1 = (0.5e0+(0.5e0-e))*exp(-t)*erfc1;
00091     if(*x < 0.0e0) erfc1 = 2.0e0-erfc1;
00092     return erfc1;
00093 S60:
00094 /*
00095              LIMIT VALUE FOR LARGE NEGATIVE X
00096 */
00097     erfc1 = 2.0e0;
00098     if(*ind != 0) erfc1 = 2.0e0*exp(*x**x);
00099     return erfc1;
00100 S70:
00101 /*
00102              LIMIT VALUE FOR LARGE POSITIVE X
00103                        WHEN IND = 0
00104 */
00105     erfc1 = 0.0e0;
00106     return erfc1;
00107 } /* END */
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_55.c. References esum(). Referenced by brcmp1(), and esum(). 
 00008 {
00009 static double esum,w;
00010 /*
00011      ..
00012      .. Executable Statements ..
00013 */
00014     if(*x > 0.0e0) goto S10;
00015     if(*mu < 0) goto S20;
00016     w = (double)*mu+*x;
00017     if(w > 0.0e0) goto S20;
00018     esum = exp(w);
00019     return esum;
00020 S10:
00021     if(*mu > 0) goto S20;
00022     w = (double)*mu+*x;
00023     if(w < 0.0e0) goto S20;
00024     esum = exp(w);
00025     return esum;
00026 S20:
00027     w = *mu;
00028     esum = exp(w)*exp(*x);
00029     return esum;
00030 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_56.c. References exparg(), ipmpar(), and l. Referenced by bup(), erfc1(), exparg(), fpser(), and Xgamm(). 
 00014 {
00015 static int K1 = 4;
00016 static int K2 = 9;
00017 static int K3 = 10;
00018 static double exparg,lnb;
00019 static int b,m;
00020 /*
00021      ..
00022      .. Executable Statements ..
00023 */
00024     b = ipmpar(&K1);
00025     if(b != 2) goto S10;
00026     lnb = .69314718055995e0;
00027     goto S40;
00028 S10:
00029     if(b != 8) goto S20;
00030     lnb = 2.0794415416798e0;
00031     goto S40;
00032 S20:
00033     if(b != 16) goto S30;
00034     lnb = 2.7725887222398e0;
00035     goto S40;
00036 S30:
00037     lnb = log((double)b);
00038 S40:
00039     if(*l == 0) goto S50;
00040     m = ipmpar(&K2)-1;
00041     exparg = 0.99999e0*((double)m*lnb);
00042     return exparg;
00043 S50:
00044     m = ipmpar(&K3);
00045     exparg = 0.99999e0*((double)m*lnb);
00046     return exparg;
00047 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_73.c. References a. Referenced by cumnor(). 
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_74.c. References a. Referenced by bcorr(), betaln(), bpser(), bratio(), brcmp1(), brcomp(), dbetrm(), dlnbet(), E0000(), gaminv(), and gratio(). 
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_75.c. References a. Referenced by bcorr(), betaln(), bpser(), bratio(), brcmp1(), brcomp(), dbetrm(), dlnbet(), E0000(), and psi(). 
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_76.c. Referenced by E0001(), and erf1(). 
 00004 : 00005 transfers the sign of the variable "sign" to the variable "mag" 00006 ************************************************************************/ 00007 /* mag - magnitude */ 00008 /* sign - sign to be transfered */ 00009 { 00010 if (mag < 0) mag = -mag; 00011 if (sign < 0) mag = -mag; 00012 return mag; 00013 } /* END */ | 
| 
 | 
| 
 Definition at line 2 of file cdf_77.c. References a. Referenced by alngam(), cumchn(), gratio(), psi(), and Xgamm(). 
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_78.c. References a. Referenced by Xgamm(). 
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 2 of file cdf_57.c. References a, c, exparg(), and fpser(). Referenced by bratio(), and fpser(). 
 00015 {
00016 static int K1 = 1;
00017 static double fpser,an,c,s,t,tol;
00018 /*
00019      ..
00020      .. Executable Statements ..
00021 */
00022     fpser = 1.0e0;
00023     if(*a <= 1.e-3**eps) goto S10;
00024     fpser = 0.0e0;
00025     t = *a*log(*x);
00026     if(t < exparg(&K1)) return fpser;
00027     fpser = exp(t);
00028 S10:
00029 /*
00030                 NOTE THAT 1/B(A,B) = B
00031 */
00032     fpser = *b/ *a*fpser;
00033     tol = *eps/ *a;
00034     an = *a+1.0e0;
00035     t = *x;
00036     s = t/an;
00037 S20:
00038     an += 1.0e0;
00039     t = *x*t;
00040     c = t/an;
00041     s += c;
00042     if(fabs(c) > tol) goto S20;
00043     fpser *= (1.0e0+*a*s);
00044     return fpser;
00045 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_79.c. Referenced by dlanor(), dstrem(), and E0000(). 
 00004 : 00005 Prints msg to standard error and then exits 00006 ************************************************************************/ 00007 /* msg - error message */ 00008 { 00009 if (msg != NULL) fprintf(stderr,"%s\n",msg); 00010 exit(1); } /* END */ | 
| 
 | 
| 
 Definition at line 2 of file cdf_58.c. References a, gam1(), p, q, r, s2, and top. Referenced by bgrat(), bpser(), brcmp1(), brcomp(), gam1(), grat1(), gratio(), and rcomp(). 
 00008 {
00009 static double s1 = .273076135303957e+00;
00010 static double s2 = .559398236957378e-01;
00011 static double p[7] = {
00012     .577215664901533e+00,-.409078193005776e+00,-.230975380857675e+00,
00013     .597275330452234e-01,.766968181649490e-02,-.514889771323592e-02,
00014     .589597428611429e-03
00015 };
00016 static double q[5] = {
00017     .100000000000000e+01,.427569613095214e+00,.158451672430138e+00,
00018     .261132021441447e-01,.423244297896961e-02
00019 };
00020 static double r[9] = {
00021     -.422784335098468e+00,-.771330383816272e+00,-.244757765222226e+00,
00022     .118378989872749e+00,.930357293360349e-03,-.118290993445146e-01,
00023     .223047661158249e-02,.266505979058923e-03,-.132674909766242e-03
00024 };
00025 static double gam1,bot,d,t,top,w,T1;
00026 /*
00027      ..
00028      .. Executable Statements ..
00029 */
00030     t = *a;
00031     d = *a-0.5e0;
00032     if(d > 0.0e0) t = d-0.5e0;
00033     T1 = t;
00034     if(T1 < 0) goto S40;
00035     else if(T1 == 0) goto S10;
00036     else  goto S20;
00037 S10:
00038     gam1 = 0.0e0;
00039     return gam1;
00040 S20:
00041     top = (((((p[6]*t+p[5])*t+p[4])*t+p[3])*t+p[2])*t+p[1])*t+p[0];
00042     bot = (((q[4]*t+q[3])*t+q[2])*t+q[1])*t+1.0e0;
00043     w = top/bot;
00044     if(d > 0.0e0) goto S30;
00045     gam1 = *a*w;
00046     return gam1;
00047 S30:
00048     gam1 = t/ *a*(w-0.5e0-0.5e0);
00049     return gam1;
00050 S40:
00051     top = (((((((r[8]*t+r[7])*t+r[6])*t+r[5])*t+r[4])*t+r[3])*t+r[2])*t+r[1])*t+
00052       r[0];
00053     bot = (s2*t+s1)*t+1.0e0;
00054     w = top/bot;
00055     if(d > 0.0e0) goto S50;
00056     gam1 = *a*(w+0.5e0+0.5e0);
00057     return gam1;
00058 S50:
00059     gam1 = t*w/ *a;
00060     return gam1;
00061 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_59.c. References a, a2, alnrel(), amax, c, fifdmax1(), gamln(), gamln1(), gratio(), p, q, r, rcomp(), s2, spmpar(), x0, Xgamm(), and xn. Referenced by cdfgam(). 
 00057 {
00058 static double a0 = 3.31125922108741e0;
00059 static double a1 = 11.6616720288968e0;
00060 static double a2 = 4.28342155967104e0;
00061 static double a3 = .213623493715853e0;
00062 static double b1 = 6.61053765625462e0;
00063 static double b2 = 6.40691597760039e0;
00064 static double b3 = 1.27364489782223e0;
00065 static double b4 = .036117081018842e0;
00066 static double c = .577215664901533e0;
00067 static double ln10 = 2.302585e0;
00068 static double tol = 1.e-5;
00069 static double amin[2] = {
00070     500.0e0,100.0e0
00071 };
00072 static double bmin[2] = {
00073     1.e-28,1.e-13
00074 };
00075 static double dmin[2] = {
00076     1.e-06,1.e-04
00077 };
00078 static double emin[2] = {
00079     2.e-03,6.e-03
00080 };
00081 static double eps0[2] = {
00082     1.e-10,1.e-08
00083 };
00084 static int K1 = 1;
00085 static int K2 = 2;
00086 static int K3 = 3;
00087 static int K8 = 0;
00088 static double am1,amax,ap1,ap2,ap3,apn,b,c1,c2,c3,c4,c5,d,e,e2,eps,g,h,pn,qg,qn,
00089     r,rta,s,s2,sum,t,u,w,xmax,xmin,xn,y,z;
00090 static int iop;
00091 static double T4,T5,T6,T7,T9;
00092 /*
00093      ..
00094      .. Executable Statements ..
00095 */
00096 /*
00097      ****** E, XMIN, AND XMAX ARE MACHINE DEPENDENT CONSTANTS.
00098             E IS THE SMALLEST NUMBER FOR WHICH 1.0 + E .GT. 1.0.
00099             XMIN IS THE SMALLEST POSITIVE NUMBER AND XMAX IS THE
00100             LARGEST POSITIVE NUMBER.
00101 */
00102     e = spmpar(&K1);
00103     xmin = spmpar(&K2);
00104     xmax = spmpar(&K3);
00105     *x = 0.0e0;
00106     if(*a <= 0.0e0) goto S300;
00107     t = *p+*q-1.e0;
00108     if(fabs(t) > e) goto S320;
00109     *ierr = 0;
00110     if(*p == 0.0e0) return;
00111     if(*q == 0.0e0) goto S270;
00112     if(*a == 1.0e0) goto S280;
00113     e2 = 2.0e0*e;
00114     amax = 0.4e-10/(e*e);
00115     iop = 1;
00116     if(e > 1.e-10) iop = 2;
00117     eps = eps0[iop-1];
00118     xn = *x0;
00119     if(*x0 > 0.0e0) goto S160;
00120 /*
00121         SELECTION OF THE INITIAL APPROXIMATION XN OF X
00122                        WHEN A .LT. 1
00123 */
00124     if(*a > 1.0e0) goto S80;
00125     T4 = *a+1.0e0;
00126     g = Xgamm(&T4);
00127     qg = *q*g;
00128     if(qg == 0.0e0) goto S360;
00129     b = qg/ *a;
00130     if(qg > 0.6e0**a) goto S40;
00131     if(*a >= 0.30e0 || b < 0.35e0) goto S10;
00132     t = exp(-(b+c));
00133     u = t*exp(t);
00134     xn = t*exp(u);
00135     goto S160;
00136 S10:
00137     if(b >= 0.45e0) goto S40;
00138     if(b == 0.0e0) goto S360;
00139     y = -log(b);
00140     s = 0.5e0+(0.5e0-*a);
00141     z = log(y);
00142     t = y-s*z;
00143     if(b < 0.15e0) goto S20;
00144     xn = y-s*log(t)-log(1.0e0+s/(t+1.0e0));
00145     goto S220;
00146 S20:
00147     if(b <= 0.01e0) goto S30;
00148     u = ((t+2.0e0*(3.0e0-*a))*t+(2.0e0-*a)*(3.0e0-*a))/((t+(5.0e0-*a))*t+2.0e0);
00149     xn = y-s*log(t)-log(u);
00150     goto S220;
00151 S30:
00152     c1 = -(s*z);
00153     c2 = -(s*(1.0e0+c1));
00154     c3 = s*((0.5e0*c1+(2.0e0-*a))*c1+(2.5e0-1.5e0**a));
00155     c4 = -(s*(((c1/3.0e0+(2.5e0-1.5e0**a))*c1+((*a-6.0e0)**a+7.0e0))*c1+(
00156       (11.0e0**a-46.0)**a+47.0e0)/6.0e0));
00157     c5 = -(s*((((-(c1/4.0e0)+(11.0e0**a-17.0e0)/6.0e0)*c1+((-(3.0e0**a)+13.0e0)*
00158       *a-13.0e0))*c1+0.5e0*(((2.0e0**a-25.0e0)**a+72.0e0)**a-61.0e0))*c1+((
00159       (25.0e0**a-195.0e0)**a+477.0e0)**a-379.0e0)/12.0e0));
00160     xn = (((c5/y+c4)/y+c3)/y+c2)/y+c1+y;
00161     if(*a > 1.0e0) goto S220;
00162     if(b > bmin[iop-1]) goto S220;
00163     *x = xn;
00164     return;
00165 S40:
00166     if(b**q > 1.e-8) goto S50;
00167     xn = exp(-(*q/ *a+c));
00168     goto S70;
00169 S50:
00170     if(*p <= 0.9e0) goto S60;
00171     T5 = -*q;
00172     xn = exp((alnrel(&T5)+gamln1(a))/ *a);
00173     goto S70;
00174 S60:
00175     xn = exp(log(*p*g)/ *a);
00176 S70:
00177     if(xn == 0.0e0) goto S310;
00178     t = 0.5e0+(0.5e0-xn/(*a+1.0e0));
00179     xn /= t;
00180     goto S160;
00181 S80:
00182 /*
00183         SELECTION OF THE INITIAL APPROXIMATION XN OF X
00184                        WHEN A .GT. 1
00185 */
00186     if(*q <= 0.5e0) goto S90;
00187     w = log(*p);
00188     goto S100;
00189 S90:
00190     w = log(*q);
00191 S100:
00192     t = sqrt(-(2.0e0*w));
00193     s = t-(((a3*t+a2)*t+a1)*t+a0)/((((b4*t+b3)*t+b2)*t+b1)*t+1.0e0);
00194     if(*q > 0.5e0) s = -s;
00195     rta = sqrt(*a);
00196     s2 = s*s;
00197     xn = *a+s*rta+(s2-1.0e0)/3.0e0+s*(s2-7.0e0)/(36.0e0*rta)-((3.0e0*s2+7.0e0)*
00198       s2-16.0e0)/(810.0e0**a)+s*((9.0e0*s2+256.0e0)*s2-433.0e0)/(38880.0e0**a*
00199       rta);
00200     xn = fifdmax1(xn,0.0e0);
00201     if(*a < amin[iop-1]) goto S110;
00202     *x = xn;
00203     d = 0.5e0+(0.5e0-*x/ *a);
00204     if(fabs(d) <= dmin[iop-1]) return;
00205 S110:
00206     if(*p <= 0.5e0) goto S130;
00207     if(xn < 3.0e0**a) goto S220;
00208     y = -(w+gamln(a));
00209     d = fifdmax1(2.0e0,*a*(*a-1.0e0));
00210     if(y < ln10*d) goto S120;
00211     s = 1.0e0-*a;
00212     z = log(y);
00213     goto S30;
00214 S120:
00215     t = *a-1.0e0;
00216     T6 = -(t/(xn+1.0e0));
00217     xn = y+t*log(xn)-alnrel(&T6);
00218     T7 = -(t/(xn+1.0e0));
00219     xn = y+t*log(xn)-alnrel(&T7);
00220     goto S220;
00221 S130:
00222     ap1 = *a+1.0e0;
00223     if(xn > 0.70e0*ap1) goto S170;
00224     w += gamln(&ap1);
00225     if(xn > 0.15e0*ap1) goto S140;
00226     ap2 = *a+2.0e0;
00227     ap3 = *a+3.0e0;
00228     *x = exp((w+*x)/ *a);
00229     *x = exp((w+*x-log(1.0e0+*x/ap1*(1.0e0+*x/ap2)))/ *a);
00230     *x = exp((w+*x-log(1.0e0+*x/ap1*(1.0e0+*x/ap2)))/ *a);
00231     *x = exp((w+*x-log(1.0e0+*x/ap1*(1.0e0+*x/ap2*(1.0e0+*x/ap3))))/ *a);
00232     xn = *x;
00233     if(xn > 1.e-2*ap1) goto S140;
00234     if(xn <= emin[iop-1]*ap1) return;
00235     goto S170;
00236 S140:
00237     apn = ap1;
00238     t = xn/apn;
00239     sum = 1.0e0+t;
00240 S150:
00241     apn += 1.0e0;
00242     t *= (xn/apn);
00243     sum += t;
00244     if(t > 1.e-4) goto S150;
00245     t = w-log(sum);
00246     xn = exp((xn+t)/ *a);
00247     xn *= (1.0e0-(*a*log(xn)-xn-t)/(*a-xn));
00248     goto S170;
00249 S160:
00250 /*
00251                  SCHRODER ITERATION USING P
00252 */
00253     if(*p > 0.5e0) goto S220;
00254 S170:
00255     if(*p <= 1.e10*xmin) goto S350;
00256     am1 = *a-0.5e0-0.5e0;
00257 S180:
00258     if(*a <= amax) goto S190;
00259     d = 0.5e0+(0.5e0-xn/ *a);
00260     if(fabs(d) <= e2) goto S350;
00261 S190:
00262     if(*ierr >= 20) goto S330;
00263     *ierr += 1;
00264     gratio(a,&xn,&pn,&qn,&K8);
00265     if(pn == 0.0e0 || qn == 0.0e0) goto S350;
00266     r = rcomp(a,&xn);
00267     if(r == 0.0e0) goto S350;
00268     t = (pn-*p)/r;
00269     w = 0.5e0*(am1-xn);
00270     if(fabs(t) <= 0.1e0 && fabs(w*t) <= 0.1e0) goto S200;
00271     *x = xn*(1.0e0-t);
00272     if(*x <= 0.0e0) goto S340;
00273     d = fabs(t);
00274     goto S210;
00275 S200:
00276     h = t*(1.0e0+w*t);
00277     *x = xn*(1.0e0-h);
00278     if(*x <= 0.0e0) goto S340;
00279     if(fabs(w) >= 1.0e0 && fabs(w)*t*t <= eps) return;
00280     d = fabs(h);
00281 S210:
00282     xn = *x;
00283     if(d > tol) goto S180;
00284     if(d <= eps) return;
00285     if(fabs(*p-pn) <= tol**p) return;
00286     goto S180;
00287 S220:
00288 /*
00289                  SCHRODER ITERATION USING Q
00290 */
00291     if(*q <= 1.e10*xmin) goto S350;
00292     am1 = *a-0.5e0-0.5e0;
00293 S230:
00294     if(*a <= amax) goto S240;
00295     d = 0.5e0+(0.5e0-xn/ *a);
00296     if(fabs(d) <= e2) goto S350;
00297 S240:
00298     if(*ierr >= 20) goto S330;
00299     *ierr += 1;
00300     gratio(a,&xn,&pn,&qn,&K8);
00301     if(pn == 0.0e0 || qn == 0.0e0) goto S350;
00302     r = rcomp(a,&xn);
00303     if(r == 0.0e0) goto S350;
00304     t = (*q-qn)/r;
00305     w = 0.5e0*(am1-xn);
00306     if(fabs(t) <= 0.1e0 && fabs(w*t) <= 0.1e0) goto S250;
00307     *x = xn*(1.0e0-t);
00308     if(*x <= 0.0e0) goto S340;
00309     d = fabs(t);
00310     goto S260;
00311 S250:
00312     h = t*(1.0e0+w*t);
00313     *x = xn*(1.0e0-h);
00314     if(*x <= 0.0e0) goto S340;
00315     if(fabs(w) >= 1.0e0 && fabs(w)*t*t <= eps) return;
00316     d = fabs(h);
00317 S260:
00318     xn = *x;
00319     if(d > tol) goto S230;
00320     if(d <= eps) return;
00321     if(fabs(*q-qn) <= tol**q) return;
00322     goto S230;
00323 S270:
00324 /*
00325                        SPECIAL CASES
00326 */
00327     *x = xmax;
00328     return;
00329 S280:
00330     if(*q < 0.9e0) goto S290;
00331     T9 = -*p;
00332     *x = -alnrel(&T9);
00333     return;
00334 S290:
00335     *x = -log(*q);
00336     return;
00337 S300:
00338 /*
00339                        ERROR RETURN
00340 */
00341     *ierr = -2;
00342     return;
00343 S310:
00344     *ierr = -3;
00345     return;
00346 S320:
00347     *ierr = -4;
00348     return;
00349 S330:
00350     *ierr = -6;
00351     return;
00352 S340:
00353     *ierr = -7;
00354     return;
00355 S350:
00356     *x = xn;
00357     *ierr = -8;
00358     return;
00359 S360:
00360     *x = xmax;
00361     *ierr = -8;
00362     return;
00363 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_60.c. References a, gamln(), gamln1(), and i. Referenced by betaln(), dlnbet(), gaminv(), and gamln(). 
 00014 {
00015 static double c0 = .833333333333333e-01;
00016 static double c1 = -.277777777760991e-02;
00017 static double c2 = .793650666825390e-03;
00018 static double c3 = -.595202931351870e-03;
00019 static double c4 = .837308034031215e-03;
00020 static double c5 = -.165322962780713e-02;
00021 static double d = .418938533204673e0;
00022 static double gamln,t,w;
00023 static int i,n;
00024 static double T1;
00025 /*
00026      ..
00027      .. Executable Statements ..
00028 */
00029     if(*a > 0.8e0) goto S10;
00030     gamln = gamln1(a)-log(*a);
00031     return gamln;
00032 S10:
00033     if(*a > 2.25e0) goto S20;
00034     t = *a-0.5e0-0.5e0;
00035     gamln = gamln1(&t);
00036     return gamln;
00037 S20:
00038     if(*a >= 10.0e0) goto S40;
00039     n = *a-1.25e0;
00040     t = *a;
00041     w = 1.0e0;
00042     for(i=1; i<=n; i++) {
00043         t -= 1.0e0;
00044         w = t*w;
00045     }
00046     T1 = t-1.0e0;
00047     gamln = gamln1(&T1)+log(w);
00048     return gamln;
00049 S40:
00050     t = pow(1.0e0/ *a,2.0);
00051     w = (((((c5*t+c4)*t+c3)*t+c2)*t+c1)*t+c0)/ *a;
00052     gamln = d+w+(*a-0.5e0)*(log(*a)-1.0e0);
00053     return gamln;
00054 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_61.c. References a, gamln1(), and s2. Referenced by bpser(), brcmp1(), brcomp(), dlngam(), gaminv(), gamln(), gamln1(), and gsumln(). 
 00008 {
00009 static double p0 = .577215664901533e+00;
00010 static double p1 = .844203922187225e+00;
00011 static double p2 = -.168860593646662e+00;
00012 static double p3 = -.780427615533591e+00;
00013 static double p4 = -.402055799310489e+00;
00014 static double p5 = -.673562214325671e-01;
00015 static double p6 = -.271935708322958e-02;
00016 static double q1 = .288743195473681e+01;
00017 static double q2 = .312755088914843e+01;
00018 static double q3 = .156875193295039e+01;
00019 static double q4 = .361951990101499e+00;
00020 static double q5 = .325038868253937e-01;
00021 static double q6 = .667465618796164e-03;
00022 static double r0 = .422784335098467e+00;
00023 static double r1 = .848044614534529e+00;
00024 static double r2 = .565221050691933e+00;
00025 static double r3 = .156513060486551e+00;
00026 static double r4 = .170502484022650e-01;
00027 static double r5 = .497958207639485e-03;
00028 static double s1 = .124313399877507e+01;
00029 static double s2 = .548042109832463e+00;
00030 static double s3 = .101552187439830e+00;
00031 static double s4 = .713309612391000e-02;
00032 static double s5 = .116165475989616e-03;
00033 static double gamln1,w,x;
00034 /*
00035      ..
00036      .. Executable Statements ..
00037 */
00038     if(*a >= 0.6e0) goto S10;
00039     w = ((((((p6**a+p5)**a+p4)**a+p3)**a+p2)**a+p1)**a+p0)/((((((q6**a+q5)**a+
00040       q4)**a+q3)**a+q2)**a+q1)**a+1.0e0);
00041     gamln1 = -(*a*w);
00042     return gamln1;
00043 S10:
00044     x = *a-0.5e0-0.5e0;
00045     w = (((((r5*x+r4)*x+r3)*x+r2)*x+r1)*x+r0)/(((((s5*x+s4)*x+s3)*x+s2)*x+s1)*x
00046       +1.0e0);
00047     gamln1 = x*w;
00048     return gamln1;
00049 } /* END */
 | 
| 
 | ||||||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_63.c. References a, c, erf1(), erfc1(), gam1(), l, p, q, r, and rexp(). Referenced by bgrat(). 
 00004 {
00005 static int K2 = 0;
00006 static double a2n,a2nm1,am0,an,an0,b2n,b2nm1,c,cma,g,h,j,l,sum,t,tol,w,z,T1,T3;
00007 /*
00008      ..
00009      .. Executable Statements ..
00010 */
00011 /*
00012 -----------------------------------------------------------------------
00013         EVALUATION OF THE INCOMPLETE GAMMA RATIO FUNCTIONS
00014                       P(A,X) AND Q(A,X)
00015      IT IS ASSUMED THAT A .LE. 1.  EPS IS THE TOLERANCE TO BE USED.
00016      THE INPUT ARGUMENT R HAS THE VALUE E**(-X)*X**A/GAMMA(A).
00017 -----------------------------------------------------------------------
00018 */
00019     if(*a**x == 0.0e0) goto S120;
00020     if(*a == 0.5e0) goto S100;
00021     if(*x < 1.1e0) goto S10;
00022     goto S60;
00023 S10:
00024 /*
00025              TAYLOR SERIES FOR P(A,X)/X**A
00026 */
00027     an = 3.0e0;
00028     c = *x;
00029     sum = *x/(*a+3.0e0);
00030     tol = 0.1e0**eps/(*a+1.0e0);
00031 S20:
00032     an += 1.0e0;
00033     c = -(c*(*x/an));
00034     t = c/(*a+an);
00035     sum += t;
00036     if(fabs(t) > tol) goto S20;
00037     j = *a**x*((sum/6.0e0-0.5e0/(*a+2.0e0))**x+1.0e0/(*a+1.0e0));
00038     z = *a*log(*x);
00039     h = gam1(a);
00040     g = 1.0e0+h;
00041     if(*x < 0.25e0) goto S30;
00042     if(*a < *x/2.59e0) goto S50;
00043     goto S40;
00044 S30:
00045     if(z > -.13394e0) goto S50;
00046 S40:
00047     w = exp(z);
00048     *p = w*g*(0.5e0+(0.5e0-j));
00049     *q = 0.5e0+(0.5e0-*p);
00050     return;
00051 S50:
00052     l = rexp(&z);
00053     w = 0.5e0+(0.5e0+l);
00054     *q = (w*j-l)*g-h;
00055     if(*q < 0.0e0) goto S90;
00056     *p = 0.5e0+(0.5e0-*q);
00057     return;
00058 S60:
00059 /*
00060               CONTINUED FRACTION EXPANSION
00061 */
00062     a2nm1 = a2n = 1.0e0;
00063     b2nm1 = *x;
00064     b2n = *x+(1.0e0-*a);
00065     c = 1.0e0;
00066 S70:
00067     a2nm1 = *x*a2n+c*a2nm1;
00068     b2nm1 = *x*b2n+c*b2nm1;
00069     am0 = a2nm1/b2nm1;
00070     c += 1.0e0;
00071     cma = c-*a;
00072     a2n = a2nm1+cma*a2n;
00073     b2n = b2nm1+cma*b2n;
00074     an0 = a2n/b2n;
00075     if(fabs(an0-am0) >= *eps*an0) goto S70;
00076     *q = *r*an0;
00077     *p = 0.5e0+(0.5e0-*q);
00078     return;
00079 S80:
00080 /*
00081                 SPECIAL CASES
00082 */
00083     *p = 0.0e0;
00084     *q = 1.0e0;
00085     return;
00086 S90:
00087     *p = 1.0e0;
00088     *q = 0.0e0;
00089     return;
00090 S100:
00091     if(*x >= 0.25e0) goto S110;
00092     T1 = sqrt(*x);
00093     *p = erf1(&T1);
00094     *q = 0.5e0+(0.5e0-*p);
00095     return;
00096 S110:
00097     T3 = sqrt(*x);
00098     *q = erfc1(&K2,&T3);
00099     *p = 0.5e0+(0.5e0-*q);
00100     return;
00101 S120:
00102     if(*x <= *a) goto S80;
00103     goto S90;
00104 } /* END */
 | 
| 
 | ||||||||||||||||||||||||
| 
 Definition at line 2 of file cdf_64.c. References a, c, erf1(), erfc1(), fifdmax1(), fifidint(), gam1(), i, ind, l, r, rexp(), rlog(), spmpar(), x0, x00, and Xgamm(). Referenced by cumgam(), and gaminv(). 
 00032 {
00033 static double alog10 = 2.30258509299405e0;
00034 static double d10 = -.185185185185185e-02;
00035 static double d20 = .413359788359788e-02;
00036 static double d30 = .649434156378601e-03;
00037 static double d40 = -.861888290916712e-03;
00038 static double d50 = -.336798553366358e-03;
00039 static double d60 = .531307936463992e-03;
00040 static double d70 = .344367606892378e-03;
00041 static double rt2pin = .398942280401433e0;
00042 static double rtpi = 1.77245385090552e0;
00043 static double third = .333333333333333e0;
00044 static double acc0[3] = {
00045     5.e-15,5.e-7,5.e-4
00046 };
00047 static double big[3] = {
00048     20.0e0,14.0e0,10.0e0
00049 };
00050 static double d0[13] = {
00051     .833333333333333e-01,-.148148148148148e-01,.115740740740741e-02,
00052     .352733686067019e-03,-.178755144032922e-03,.391926317852244e-04,
00053     -.218544851067999e-05,-.185406221071516e-05,.829671134095309e-06,
00054     -.176659527368261e-06,.670785354340150e-08,.102618097842403e-07,
00055     -.438203601845335e-08
00056 };
00057 static double d1[12] = {
00058     -.347222222222222e-02,.264550264550265e-02,-.990226337448560e-03,
00059     .205761316872428e-03,-.401877572016461e-06,-.180985503344900e-04,
00060     .764916091608111e-05,-.161209008945634e-05,.464712780280743e-08,
00061     .137863344691572e-06,-.575254560351770e-07,.119516285997781e-07
00062 };
00063 static double d2[10] = {
00064     -.268132716049383e-02,.771604938271605e-03,.200938786008230e-05,
00065     -.107366532263652e-03,.529234488291201e-04,-.127606351886187e-04,
00066     .342357873409614e-07,.137219573090629e-05,-.629899213838006e-06,
00067     .142806142060642e-06
00068 };
00069 static double d3[8] = {
00070     .229472093621399e-03,-.469189494395256e-03,.267720632062839e-03,
00071     -.756180167188398e-04,-.239650511386730e-06,.110826541153473e-04,
00072     -.567495282699160e-05,.142309007324359e-05
00073 };
00074 static double d4[6] = {
00075     .784039221720067e-03,-.299072480303190e-03,-.146384525788434e-05,
00076     .664149821546512e-04,-.396836504717943e-04,.113757269706784e-04
00077 };
00078 static double d5[4] = {
00079     -.697281375836586e-04,.277275324495939e-03,-.199325705161888e-03,
00080     .679778047793721e-04
00081 };
00082 static double d6[2] = {
00083     -.592166437353694e-03,.270878209671804e-03
00084 };
00085 static double e00[3] = {
00086     .25e-3,.25e-1,.14e0
00087 };
00088 static double x00[3] = {
00089     31.0e0,17.0e0,9.7e0
00090 };
00091 static int K1 = 1;
00092 static int K2 = 0;
00093 static double a2n,a2nm1,acc,am0,amn,an,an0,apn,b2n,b2nm1,c,c0,c1,c2,c3,c4,c5,c6,
00094     cma,e,e0,g,h,j,l,r,rta,rtx,s,sum,t,t1,tol,twoa,u,w,x0,y,z;
00095 static int i,iop,m,max,n;
00096 static double wk[20],T3;
00097 static int T4,T5;
00098 static double T6,T7;
00099 /*
00100      ..
00101      .. Executable Statements ..
00102 */
00103 /*
00104      --------------------
00105      ****** E IS A MACHINE DEPENDENT CONSTANT. E IS THE SMALLEST
00106             FLOATING POINT NUMBER FOR WHICH 1.0 + E .GT. 1.0 .
00107 */
00108     e = spmpar(&K1);
00109     if(*a < 0.0e0 || *x < 0.0e0) goto S430;
00110     if(*a == 0.0e0 && *x == 0.0e0) goto S430;
00111     if(*a**x == 0.0e0) goto S420;
00112     iop = *ind+1;
00113     if(iop != 1 && iop != 2) iop = 3;
00114     acc = fifdmax1(acc0[iop-1],e);
00115     e0 = e00[iop-1];
00116     x0 = x00[iop-1];
00117 /*
00118             SELECT THE APPROPRIATE ALGORITHM
00119 */
00120     if(*a >= 1.0e0) goto S10;
00121     if(*a == 0.5e0) goto S390;
00122     if(*x < 1.1e0) goto S160;
00123     t1 = *a*log(*x)-*x;
00124     u = *a*exp(t1);
00125     if(u == 0.0e0) goto S380;
00126     r = u*(1.0e0+gam1(a));
00127     goto S250;
00128 S10:
00129     if(*a >= big[iop-1]) goto S30;
00130     if(*a > *x || *x >= x0) goto S20;
00131     twoa = *a+*a;
00132     m = fifidint(twoa);
00133     if(twoa != (double)m) goto S20;
00134     i = m/2;
00135     if(*a == (double)i) goto S210;
00136     goto S220;
00137 S20:
00138     t1 = *a*log(*x)-*x;
00139     r = exp(t1)/Xgamm(a);
00140     goto S40;
00141 S30:
00142     l = *x/ *a;
00143     if(l == 0.0e0) goto S370;
00144     s = 0.5e0+(0.5e0-l);
00145     z = rlog(&l);
00146     if(z >= 700.0e0/ *a) goto S410;
00147     y = *a*z;
00148     rta = sqrt(*a);
00149     if(fabs(s) <= e0/rta) goto S330;
00150     if(fabs(s) <= 0.4e0) goto S270;
00151     t = pow(1.0e0/ *a,2.0);
00152     t1 = (((0.75e0*t-1.0e0)*t+3.5e0)*t-105.0e0)/(*a*1260.0e0);
00153     t1 -= y;
00154     r = rt2pin*rta*exp(t1);
00155 S40:
00156     if(r == 0.0e0) goto S420;
00157     if(*x <= fifdmax1(*a,alog10)) goto S50;
00158     if(*x < x0) goto S250;
00159     goto S100;
00160 S50:
00161 /*
00162                  TAYLOR SERIES FOR P/R
00163 */
00164     apn = *a+1.0e0;
00165     t = *x/apn;
00166     wk[0] = t;
00167     for(n=2; n<=20; n++) {
00168         apn += 1.0e0;
00169         t *= (*x/apn);
00170         if(t <= 1.e-3) goto S70;
00171         wk[n-1] = t;
00172     }
00173     n = 20;
00174 S70:
00175     sum = t;
00176     tol = 0.5e0*acc;
00177 S80:
00178     apn += 1.0e0;
00179     t *= (*x/apn);
00180     sum += t;
00181     if(t > tol) goto S80;
00182     max = n-1;
00183     for(m=1; m<=max; m++) {
00184         n -= 1;
00185         sum += wk[n-1];
00186     }
00187     *ans = r/ *a*(1.0e0+sum);
00188     *qans = 0.5e0+(0.5e0-*ans);
00189     return;
00190 S100:
00191 /*
00192                  ASYMPTOTIC EXPANSION
00193 */
00194     amn = *a-1.0e0;
00195     t = amn/ *x;
00196     wk[0] = t;
00197     for(n=2; n<=20; n++) {
00198         amn -= 1.0e0;
00199         t *= (amn/ *x);
00200         if(fabs(t) <= 1.e-3) goto S120;
00201         wk[n-1] = t;
00202     }
00203     n = 20;
00204 S120:
00205     sum = t;
00206 S130:
00207     if(fabs(t) <= acc) goto S140;
00208     amn -= 1.0e0;
00209     t *= (amn/ *x);
00210     sum += t;
00211     goto S130;
00212 S140:
00213     max = n-1;
00214     for(m=1; m<=max; m++) {
00215         n -= 1;
00216         sum += wk[n-1];
00217     }
00218     *qans = r/ *x*(1.0e0+sum);
00219     *ans = 0.5e0+(0.5e0-*qans);
00220     return;
00221 S160:
00222 /*
00223              TAYLOR SERIES FOR P(A,X)/X**A
00224 */
00225     an = 3.0e0;
00226     c = *x;
00227     sum = *x/(*a+3.0e0);
00228     tol = 3.0e0*acc/(*a+1.0e0);
00229 S170:
00230     an += 1.0e0;
00231     c = -(c*(*x/an));
00232     t = c/(*a+an);
00233     sum += t;
00234     if(fabs(t) > tol) goto S170;
00235     j = *a**x*((sum/6.0e0-0.5e0/(*a+2.0e0))**x+1.0e0/(*a+1.0e0));
00236     z = *a*log(*x);
00237     h = gam1(a);
00238     g = 1.0e0+h;
00239     if(*x < 0.25e0) goto S180;
00240     if(*a < *x/2.59e0) goto S200;
00241     goto S190;
00242 S180:
00243     if(z > -.13394e0) goto S200;
00244 S190:
00245     w = exp(z);
00246     *ans = w*g*(0.5e0+(0.5e0-j));
00247     *qans = 0.5e0+(0.5e0-*ans);
00248     return;
00249 S200:
00250     l = rexp(&z);
00251     w = 0.5e0+(0.5e0+l);
00252     *qans = (w*j-l)*g-h;
00253     if(*qans < 0.0e0) goto S380;
00254     *ans = 0.5e0+(0.5e0-*qans);
00255     return;
00256 S210:
00257 /*
00258              FINITE SUMS FOR Q WHEN A .GE. 1
00259                  AND 2*A IS AN INTEGER
00260 */
00261     sum = exp(-*x);
00262     t = sum;
00263     n = 1;
00264     c = 0.0e0;
00265     goto S230;
00266 S220:
00267     rtx = sqrt(*x);
00268     sum = erfc1(&K2,&rtx);
00269     t = exp(-*x)/(rtpi*rtx);
00270     n = 0;
00271     c = -0.5e0;
00272 S230:
00273     if(n == i) goto S240;
00274     n += 1;
00275     c += 1.0e0;
00276     t = *x*t/c;
00277     sum += t;
00278     goto S230;
00279 S240:
00280     *qans = sum;
00281     *ans = 0.5e0+(0.5e0-*qans);
00282     return;
00283 S250:
00284 /*
00285               CONTINUED FRACTION EXPANSION
00286 */
00287     tol = fifdmax1(5.0e0*e,acc);
00288     a2nm1 = a2n = 1.0e0;
00289     b2nm1 = *x;
00290     b2n = *x+(1.0e0-*a);
00291     c = 1.0e0;
00292 S260:
00293     a2nm1 = *x*a2n+c*a2nm1;
00294     b2nm1 = *x*b2n+c*b2nm1;
00295     am0 = a2nm1/b2nm1;
00296     c += 1.0e0;
00297     cma = c-*a;
00298     a2n = a2nm1+cma*a2n;
00299     b2n = b2nm1+cma*b2n;
00300     an0 = a2n/b2n;
00301     if(fabs(an0-am0) >= tol*an0) goto S260;
00302     *qans = r*an0;
00303     *ans = 0.5e0+(0.5e0-*qans);
00304     return;
00305 S270:
00306 /*
00307                 GENERAL TEMME EXPANSION
00308 */
00309     if(fabs(s) <= 2.0e0*e && *a*e*e > 3.28e-3) goto S430;
00310     c = exp(-y);
00311     T3 = sqrt(y);
00312     w = 0.5e0*erfc1(&K1,&T3);
00313     u = 1.0e0/ *a;
00314     z = sqrt(z+z);
00315     if(l < 1.0e0) z = -z;
00316     T4 = iop-2;
00317     if(T4 < 0) goto S280;
00318     else if(T4 == 0) goto S290;
00319     else  goto S300;
00320 S280:
00321     if(fabs(s) <= 1.e-3) goto S340;
00322     c0 = ((((((((((((d0[12]*z+d0[11])*z+d0[10])*z+d0[9])*z+d0[8])*z+d0[7])*z+d0[
00323       6])*z+d0[5])*z+d0[4])*z+d0[3])*z+d0[2])*z+d0[1])*z+d0[0])*z-third;
00324     c1 = (((((((((((d1[11]*z+d1[10])*z+d1[9])*z+d1[8])*z+d1[7])*z+d1[6])*z+d1[5]
00325       )*z+d1[4])*z+d1[3])*z+d1[2])*z+d1[1])*z+d1[0])*z+d10;
00326     c2 = (((((((((d2[9]*z+d2[8])*z+d2[7])*z+d2[6])*z+d2[5])*z+d2[4])*z+d2[3])*z+
00327       d2[2])*z+d2[1])*z+d2[0])*z+d20;
00328     c3 = (((((((d3[7]*z+d3[6])*z+d3[5])*z+d3[4])*z+d3[3])*z+d3[2])*z+d3[1])*z+
00329       d3[0])*z+d30;
00330     c4 = (((((d4[5]*z+d4[4])*z+d4[3])*z+d4[2])*z+d4[1])*z+d4[0])*z+d40;
00331     c5 = (((d5[3]*z+d5[2])*z+d5[1])*z+d5[0])*z+d50;
00332     c6 = (d6[1]*z+d6[0])*z+d60;
00333     t = ((((((d70*u+c6)*u+c5)*u+c4)*u+c3)*u+c2)*u+c1)*u+c0;
00334     goto S310;
00335 S290:
00336     c0 = (((((d0[5]*z+d0[4])*z+d0[3])*z+d0[2])*z+d0[1])*z+d0[0])*z-third;
00337     c1 = (((d1[3]*z+d1[2])*z+d1[1])*z+d1[0])*z+d10;
00338     c2 = d2[0]*z+d20;
00339     t = (c2*u+c1)*u+c0;
00340     goto S310;
00341 S300:
00342     t = ((d0[2]*z+d0[1])*z+d0[0])*z-third;
00343 S310:
00344     if(l < 1.0e0) goto S320;
00345     *qans = c*(w+rt2pin*t/rta);
00346     *ans = 0.5e0+(0.5e0-*qans);
00347     return;
00348 S320:
00349     *ans = c*(w-rt2pin*t/rta);
00350     *qans = 0.5e0+(0.5e0-*ans);
00351     return;
00352 S330:
00353 /*
00354                TEMME EXPANSION FOR L = 1
00355 */
00356     if(*a*e*e > 3.28e-3) goto S430;
00357     c = 0.5e0+(0.5e0-y);
00358     w = (0.5e0-sqrt(y)*(0.5e0+(0.5e0-y/3.0e0))/rtpi)/c;
00359     u = 1.0e0/ *a;
00360     z = sqrt(z+z);
00361     if(l < 1.0e0) z = -z;
00362     T5 = iop-2;
00363     if(T5 < 0) goto S340;
00364     else if(T5 == 0) goto S350;
00365     else  goto S360;
00366 S340:
00367     c0 = ((((((d0[6]*z+d0[5])*z+d0[4])*z+d0[3])*z+d0[2])*z+d0[1])*z+d0[0])*z-
00368       third;
00369     c1 = (((((d1[5]*z+d1[4])*z+d1[3])*z+d1[2])*z+d1[1])*z+d1[0])*z+d10;
00370     c2 = ((((d2[4]*z+d2[3])*z+d2[2])*z+d2[1])*z+d2[0])*z+d20;
00371     c3 = (((d3[3]*z+d3[2])*z+d3[1])*z+d3[0])*z+d30;
00372     c4 = (d4[1]*z+d4[0])*z+d40;
00373     c5 = (d5[1]*z+d5[0])*z+d50;
00374     c6 = d6[0]*z+d60;
00375     t = ((((((d70*u+c6)*u+c5)*u+c4)*u+c3)*u+c2)*u+c1)*u+c0;
00376     goto S310;
00377 S350:
00378     c0 = (d0[1]*z+d0[0])*z-third;
00379     c1 = d1[0]*z+d10;
00380     t = (d20*u+c1)*u+c0;
00381     goto S310;
00382 S360:
00383     t = d0[0]*z-third;
00384     goto S310;
00385 S370:
00386 /*
00387                      SPECIAL CASES
00388 */
00389     *ans = 0.0e0;
00390     *qans = 1.0e0;
00391     return;
00392 S380:
00393     *ans = 1.0e0;
00394     *qans = 0.0e0;
00395     return;
00396 S390:
00397     if(*x >= 0.25e0) goto S400;
00398     T6 = sqrt(*x);
00399     *ans = erf1(&T6);
00400     *qans = 0.5e0+(0.5e0-*ans);
00401     return;
00402 S400:
00403     T7 = sqrt(*x);
00404     *qans = erfc1(&K2,&T7);
00405     *ans = 0.5e0+(0.5e0-*qans);
00406     return;
00407 S410:
00408     if(fabs(s) <= 2.0e0*e) goto S430;
00409 S420:
00410     if(*x <= *a) goto S370;
00411     goto S380;
00412 S430:
00413 /*
00414                      ERROR RETURN
00415 */
00416     *ans = 2.0e0;
00417     return;
00418 } /* END */
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_65.c. References a, alnrel(), gamln1(), and gsumln(). Referenced by betaln(), dlnbet(), and gsumln(). 
 00009 {
00010 static double gsumln,x,T1,T2;
00011 /*
00012      ..
00013      .. Executable Statements ..
00014 */
00015     x = *a+*b-2.e0;
00016     if(x > 0.25e0) goto S10;
00017     T1 = 1.0e0+x;
00018     gsumln = gamln1(&T1);
00019     return gsumln;
00020 S10:
00021     if(x > 1.25e0) goto S20;
00022     gsumln = gamln1(&x)+alnrel(&x);
00023     return gsumln;
00024 S20:
00025     T2 = x-1.0e0;
00026     gsumln = gamln1(&T2)+log(x*(1.0e0+x));
00027     return gsumln;
00028 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_80.c. References i. Referenced by exparg(), psi(), and spmpar(). 
 00059 : at this time, the IEEE parameters are enabled. 00060 00061 ----------------------------------------------------------------------- 00062 00063 IPMPAR IS AN ADAPTATION OF THE FUNCTION I1MACH, WRITTEN BY 00064 P.A. FOX, A.D. HALL, AND N.L. SCHRYER (BELL LABORATORIES). 00065 IPMPAR WAS FORMED BY A.H. MORRIS (NSWC). THE CONSTANTS ARE 00066 FROM BELL LABORATORIES, NSWC, AND OTHER SOURCES. 00067 00068 ----------------------------------------------------------------------- 00069 .. Scalar Arguments .. 00070 */ 00071 { 00072 static int imach[11]; 00073 static int outval ; 00074 /* MACHINE CONSTANTS FOR AMDAHL MACHINES. */ 00075 /* 00076 imach[1] = 2; 00077 imach[2] = 31; 00078 imach[3] = 2147483647; 00079 imach[4] = 16; 00080 imach[5] = 6; 00081 imach[6] = -64; 00082 imach[7] = 63; 00083 imach[8] = 14; 00084 imach[9] = -64; 00085 imach[10] = 63; 00086 */ 00087 /* MACHINE CONSTANTS FOR THE AT&T 3B SERIES, AT&T 00088 PC 7300, AND AT&T 6300. */ 00089 /* 00090 imach[1] = 2; 00091 imach[2] = 31; 00092 imach[3] = 2147483647; 00093 imach[4] = 2; 00094 imach[5] = 24; 00095 imach[6] = -125; 00096 imach[7] = 128; 00097 imach[8] = 53; 00098 imach[9] = -1021; 00099 imach[10] = 1024; 00100 */ 00101 /* MACHINE CONSTANTS FOR THE BURROUGHS 1700 SYSTEM. */ 00102 /* 00103 imach[1] = 2; 00104 imach[2] = 33; 00105 imach[3] = 8589934591; 00106 imach[4] = 2; 00107 imach[5] = 24; 00108 imach[6] = -256; 00109 imach[7] = 255; 00110 imach[8] = 60; 00111 imach[9] = -256; 00112 imach[10] = 255; 00113 */ 00114 /* MACHINE CONSTANTS FOR THE BURROUGHS 5700 SYSTEM. */ 00115 /* 00116 imach[1] = 2; 00117 imach[2] = 39; 00118 imach[3] = 549755813887; 00119 imach[4] = 8; 00120 imach[5] = 13; 00121 imach[6] = -50; 00122 imach[7] = 76; 00123 imach[8] = 26; 00124 imach[9] = -50; 00125 imach[10] = 76; 00126 */ 00127 /* MACHINE CONSTANTS FOR THE BURROUGHS 6700/7700 SYSTEMS. */ 00128 /* 00129 imach[1] = 2; 00130 imach[2] = 39; 00131 imach[3] = 549755813887; 00132 imach[4] = 8; 00133 imach[5] = 13; 00134 imach[6] = -50; 00135 imach[7] = 76; 00136 imach[8] = 26; 00137 imach[9] = -32754; 00138 imach[10] = 32780; 00139 */ 00140 /* MACHINE CONSTANTS FOR THE CDC 6000/7000 SERIES 00141 60 BIT ARITHMETIC, AND THE CDC CYBER 995 64 BIT 00142 ARITHMETIC (NOS OPERATING SYSTEM). */ 00143 /* 00144 imach[1] = 2; 00145 imach[2] = 48; 00146 imach[3] = 281474976710655; 00147 imach[4] = 2; 00148 imach[5] = 48; 00149 imach[6] = -974; 00150 imach[7] = 1070; 00151 imach[8] = 95; 00152 imach[9] = -926; 00153 imach[10] = 1070; 00154 */ 00155 /* MACHINE CONSTANTS FOR THE CDC CYBER 995 64 BIT 00156 ARITHMETIC (NOS/VE OPERATING SYSTEM). */ 00157 /* 00158 imach[1] = 2; 00159 imach[2] = 63; 00160 imach[3] = 9223372036854775807; 00161 imach[4] = 2; 00162 imach[5] = 48; 00163 imach[6] = -4096; 00164 imach[7] = 4095; 00165 imach[8] = 96; 00166 imach[9] = -4096; 00167 imach[10] = 4095; 00168 */ 00169 /* MACHINE CONSTANTS FOR THE CRAY 1, XMP, 2, AND 3. */ 00170 /* 00171 imach[1] = 2; 00172 imach[2] = 63; 00173 imach[3] = 9223372036854775807; 00174 imach[4] = 2; 00175 imach[5] = 47; 00176 imach[6] = -8189; 00177 imach[7] = 8190; 00178 imach[8] = 94; 00179 imach[9] = -8099; 00180 imach[10] = 8190; 00181 */ 00182 /* MACHINE CONSTANTS FOR THE DATA GENERAL ECLIPSE S/200. */ 00183 /* 00184 imach[1] = 2; 00185 imach[2] = 15; 00186 imach[3] = 32767; 00187 imach[4] = 16; 00188 imach[5] = 6; 00189 imach[6] = -64; 00190 imach[7] = 63; 00191 imach[8] = 14; 00192 imach[9] = -64; 00193 imach[10] = 63; 00194 */ 00195 /* MACHINE CONSTANTS FOR THE HARRIS 220. */ 00196 /* 00197 imach[1] = 2; 00198 imach[2] = 23; 00199 imach[3] = 8388607; 00200 imach[4] = 2; 00201 imach[5] = 23; 00202 imach[6] = -127; 00203 imach[7] = 127; 00204 imach[8] = 38; 00205 imach[9] = -127; 00206 imach[10] = 127; 00207 */ 00208 /* MACHINE CONSTANTS FOR THE HONEYWELL 600/6000 00209 AND DPS 8/70 SERIES. */ 00210 /* 00211 imach[1] = 2; 00212 imach[2] = 35; 00213 imach[3] = 34359738367; 00214 imach[4] = 2; 00215 imach[5] = 27; 00216 imach[6] = -127; 00217 imach[7] = 127; 00218 imach[8] = 63; 00219 imach[9] = -127; 00220 imach[10] = 127; 00221 */ 00222 /* MACHINE CONSTANTS FOR THE HP 2100 00223 3 WORD DOUBLE PRECISION OPTION WITH FTN4 */ 00224 /* 00225 imach[1] = 2; 00226 imach[2] = 15; 00227 imach[3] = 32767; 00228 imach[4] = 2; 00229 imach[5] = 23; 00230 imach[6] = -128; 00231 imach[7] = 127; 00232 imach[8] = 39; 00233 imach[9] = -128; 00234 imach[10] = 127; 00235 */ 00236 /* MACHINE CONSTANTS FOR THE HP 2100 00237 4 WORD DOUBLE PRECISION OPTION WITH FTN4 */ 00238 /* 00239 imach[1] = 2; 00240 imach[2] = 15; 00241 imach[3] = 32767; 00242 imach[4] = 2; 00243 imach[5] = 23; 00244 imach[6] = -128; 00245 imach[7] = 127; 00246 imach[8] = 55; 00247 imach[9] = -128; 00248 imach[10] = 127; 00249 */ 00250 /* MACHINE CONSTANTS FOR THE HP 9000. */ 00251 /* 00252 imach[1] = 2; 00253 imach[2] = 31; 00254 imach[3] = 2147483647; 00255 imach[4] = 2; 00256 imach[5] = 24; 00257 imach[6] = -126; 00258 imach[7] = 128; 00259 imach[8] = 53; 00260 imach[9] = -1021; 00261 imach[10] = 1024; 00262 */ 00263 /* MACHINE CONSTANTS FOR THE IBM 360/370 SERIES, 00264 THE ICL 2900, THE ITEL AS/6, THE XEROX SIGMA 00265 5/7/9 AND THE SEL SYSTEMS 85/86. */ 00266 /* 00267 imach[1] = 2; 00268 imach[2] = 31; 00269 imach[3] = 2147483647; 00270 imach[4] = 16; 00271 imach[5] = 6; 00272 imach[6] = -64; 00273 imach[7] = 63; 00274 imach[8] = 14; 00275 imach[9] = -64; 00276 imach[10] = 63; 00277 */ 00278 /* MACHINE CONSTANTS FOR THE IBM PC. */ 00279 /* 00280 imach[1] = 2; 00281 imach[2] = 31; 00282 imach[3] = 2147483647; 00283 imach[4] = 2; 00284 imach[5] = 24; 00285 imach[6] = -125; 00286 imach[7] = 128; 00287 imach[8] = 53; 00288 imach[9] = -1021; 00289 imach[10] = 1024; 00290 */ 00291 /* MACHINE CONSTANTS FOR THE MACINTOSH II - ABSOFT 00292 MACFORTRAN II. */ 00293 /* 00294 imach[1] = 2; 00295 imach[2] = 31; 00296 imach[3] = 2147483647; 00297 imach[4] = 2; 00298 imach[5] = 24; 00299 imach[6] = -125; 00300 imach[7] = 128; 00301 imach[8] = 53; 00302 imach[9] = -1021; 00303 imach[10] = 1024; 00304 */ 00305 /* MACHINE CONSTANTS FOR THE MICROVAX - VMS FORTRAN. */ 00306 /* 00307 imach[1] = 2; 00308 imach[2] = 31; 00309 imach[3] = 2147483647; 00310 imach[4] = 2; 00311 imach[5] = 24; 00312 imach[6] = -127; 00313 imach[7] = 127; 00314 imach[8] = 56; 00315 imach[9] = -127; 00316 imach[10] = 127; 00317 */ 00318 /* MACHINE CONSTANTS FOR THE PDP-10 (KA PROCESSOR). */ 00319 /* 00320 imach[1] = 2; 00321 imach[2] = 35; 00322 imach[3] = 34359738367; 00323 imach[4] = 2; 00324 imach[5] = 27; 00325 imach[6] = -128; 00326 imach[7] = 127; 00327 imach[8] = 54; 00328 imach[9] = -101; 00329 imach[10] = 127; 00330 */ 00331 /* MACHINE CONSTANTS FOR THE PDP-10 (KI PROCESSOR). */ 00332 /* 00333 imach[1] = 2; 00334 imach[2] = 35; 00335 imach[3] = 34359738367; 00336 imach[4] = 2; 00337 imach[5] = 27; 00338 imach[6] = -128; 00339 imach[7] = 127; 00340 imach[8] = 62; 00341 imach[9] = -128; 00342 imach[10] = 127; 00343 */ 00344 /* MACHINE CONSTANTS FOR THE PDP-11 FORTRAN SUPPORTING 00345 32-BIT INTEGER ARITHMETIC. */ 00346 /* 00347 imach[1] = 2; 00348 imach[2] = 31; 00349 imach[3] = 2147483647; 00350 imach[4] = 2; 00351 imach[5] = 24; 00352 imach[6] = -127; 00353 imach[7] = 127; 00354 imach[8] = 56; 00355 imach[9] = -127; 00356 imach[10] = 127; 00357 */ 00358 /* MACHINE CONSTANTS FOR THE SEQUENT BALANCE 8000. */ 00359 /* 00360 imach[1] = 2; 00361 imach[2] = 31; 00362 imach[3] = 2147483647; 00363 imach[4] = 2; 00364 imach[5] = 24; 00365 imach[6] = -125; 00366 imach[7] = 128; 00367 imach[8] = 53; 00368 imach[9] = -1021; 00369 imach[10] = 1024; 00370 */ 00371 /* MACHINE CONSTANTS FOR THE SILICON GRAPHICS IRIS-4D 00372 SERIES (MIPS R3000 PROCESSOR). */ 00373 /* 00374 imach[1] = 2; 00375 imach[2] = 31; 00376 imach[3] = 2147483647; 00377 imach[4] = 2; 00378 imach[5] = 24; 00379 imach[6] = -125; 00380 imach[7] = 128; 00381 imach[8] = 53; 00382 imach[9] = -1021; 00383 imach[10] = 1024; 00384 */ 00385 /* MACHINE CONSTANTS FOR IEEE ARITHMETIC MACHINES, SUCH AS THE AT&T 00386 3B SERIES, MOTOROLA 68000 BASED MACHINES (E.G. SUN 3 AND AT&T 00387 PC 7300), AND 8087 BASED MICROS (E.G. IBM PC AND AT&T 6300). */ 00388 00389 imach[1] = 2; 00390 imach[2] = 31; 00391 imach[3] = 2147483647; 00392 imach[4] = 2; 00393 imach[5] = 24; 00394 imach[6] = -125; 00395 imach[7] = 128; 00396 imach[8] = 53; 00397 imach[9] = -1021; 00398 imach[10] = 1024; 00399 00400 /* MACHINE CONSTANTS FOR THE UNIVAC 1100 SERIES. */ 00401 /* 00402 imach[1] = 2; 00403 imach[2] = 35; 00404 imach[3] = 34359738367; 00405 imach[4] = 2; 00406 imach[5] = 27; 00407 imach[6] = -128; 00408 imach[7] = 127; 00409 imach[8] = 60; 00410 imach[9] = -1024; 00411 imach[10] = 1023; 00412 */ 00413 /* MACHINE CONSTANTS FOR THE VAX 11/780. */ 00414 /* 00415 imach[1] = 2; 00416 imach[2] = 31; 00417 imach[3] = 2147483647; 00418 imach[4] = 2; 00419 imach[5] = 24; 00420 imach[6] = -127; 00421 imach[7] = 127; 00422 imach[8] = 56; 00423 imach[9] = -127; 00424 imach[10] = 127; 00425 */ 00426 outval = imach[*i]; 00427 return outval ; 00428 } | 
| 
 | 
| 
 Definition at line 2 of file cdf_66.c. References fifdmin1(), fifidint(), i, ipmpar(), psi(), and spmpar(). Referenced by apser(), and psi(). 
 00023 {
00024 static double dx0 = 1.461632144968362341262659542325721325e0;
00025 static double piov4 = .785398163397448e0;
00026 static double p1[7] = {
00027     .895385022981970e-02,.477762828042627e+01,.142441585084029e+03,
00028     .118645200713425e+04,.363351846806499e+04,.413810161269013e+04,
00029     .130560269827897e+04
00030 };
00031 static double p2[4] = {
00032     -.212940445131011e+01,-.701677227766759e+01,-.448616543918019e+01,
00033     -.648157123766197e+00
00034 };
00035 static double q1[6] = {
00036     .448452573429826e+02,.520752771467162e+03,.221000799247830e+04,
00037     .364127349079381e+04,.190831076596300e+04,.691091682714533e-05
00038 };
00039 static double q2[4] = {
00040     .322703493791143e+02,.892920700481861e+02,.546117738103215e+02,
00041     .777788548522962e+01
00042 };
00043 static int K1 = 3;
00044 static int K2 = 1;
00045 static double psi,aug,den,sgn,upper,w,x,xmax1,xmx0,xsmall,z;
00046 static int i,m,n,nq;
00047 /*
00048      ..
00049      .. Executable Statements ..
00050 */
00051 /*
00052 ---------------------------------------------------------------------
00053      MACHINE DEPENDENT CONSTANTS ...
00054         XMAX1  = THE SMALLEST POSITIVE FLOATING POINT CONSTANT
00055                  WITH ENTIRELY INTEGER REPRESENTATION.  ALSO USED
00056                  AS NEGATIVE OF LOWER BOUND ON ACCEPTABLE NEGATIVE
00057                  ARGUMENTS AND AS THE POSITIVE ARGUMENT BEYOND WHICH
00058                  PSI MAY BE REPRESENTED AS ALOG(X).
00059         XSMALL = ABSOLUTE ARGUMENT BELOW WHICH PI*COTAN(PI*X)
00060                  MAY BE REPRESENTED BY 1/X.
00061 ---------------------------------------------------------------------
00062 */
00063     xmax1 = ipmpar(&K1);
00064     xmax1 = fifdmin1(xmax1,1.0e0/spmpar(&K2));
00065     xsmall = 1.e-9;
00066     x = *xx;
00067     aug = 0.0e0;
00068     if(x >= 0.5e0) goto S50;
00069 /*
00070 ---------------------------------------------------------------------
00071      X .LT. 0.5,  USE REFLECTION FORMULA
00072      PSI(1-X) = PSI(X) + PI * COTAN(PI*X)
00073 ---------------------------------------------------------------------
00074 */
00075     if(fabs(x) > xsmall) goto S10;
00076     if(x == 0.0e0) goto S100;
00077 /*
00078 ---------------------------------------------------------------------
00079      0 .LT. ABS(X) .LE. XSMALL.  USE 1/X AS A SUBSTITUTE
00080      FOR  PI*COTAN(PI*X)
00081 ---------------------------------------------------------------------
00082 */
00083     aug = -(1.0e0/x);
00084     goto S40;
00085 S10:
00086 /*
00087 ---------------------------------------------------------------------
00088      REDUCTION OF ARGUMENT FOR COTAN
00089 ---------------------------------------------------------------------
00090 */
00091     w = -x;
00092     sgn = piov4;
00093     if(w > 0.0e0) goto S20;
00094     w = -w;
00095     sgn = -sgn;
00096 S20:
00097 /*
00098 ---------------------------------------------------------------------
00099      MAKE AN ERROR EXIT IF X .LE. -XMAX1
00100 ---------------------------------------------------------------------
00101 */
00102     if(w >= xmax1) goto S100;
00103     nq = fifidint(w);
00104     w -= (double)nq;
00105     nq = fifidint(w*4.0e0);
00106     w = 4.0e0*(w-(double)nq*.25e0);
00107 /*
00108 ---------------------------------------------------------------------
00109      W IS NOW RELATED TO THE FRACTIONAL PART OF  4.0 * X.
00110      ADJUST ARGUMENT TO CORRESPOND TO VALUES IN FIRST
00111      QUADRANT AND DETERMINE SIGN
00112 ---------------------------------------------------------------------
00113 */
00114     n = nq/2;
00115     if(n+n != nq) w = 1.0e0-w;
00116     z = piov4*w;
00117     m = n/2;
00118     if(m+m != n) sgn = -sgn;
00119 /*
00120 ---------------------------------------------------------------------
00121      DETERMINE FINAL VALUE FOR  -PI*COTAN(PI*X)
00122 ---------------------------------------------------------------------
00123 */
00124     n = (nq+1)/2;
00125     m = n/2;
00126     m += m;
00127     if(m != n) goto S30;
00128 /*
00129 ---------------------------------------------------------------------
00130      CHECK FOR SINGULARITY
00131 ---------------------------------------------------------------------
00132 */
00133     if(z == 0.0e0) goto S100;
00134 /*
00135 ---------------------------------------------------------------------
00136      USE COS/SIN AS A SUBSTITUTE FOR COTAN, AND
00137      SIN/COS AS A SUBSTITUTE FOR TAN
00138 ---------------------------------------------------------------------
00139 */
00140     aug = sgn*(cos(z)/sin(z)*4.0e0);
00141     goto S40;
00142 S30:
00143     aug = sgn*(sin(z)/cos(z)*4.0e0);
00144 S40:
00145     x = 1.0e0-x;
00146 S50:
00147     if(x > 3.0e0) goto S70;
00148 /*
00149 ---------------------------------------------------------------------
00150      0.5 .LE. X .LE. 3.0
00151 ---------------------------------------------------------------------
00152 */
00153     den = x;
00154     upper = p1[0]*x;
00155     for(i=1; i<=5; i++) {
00156         den = (den+q1[i-1])*x;
00157         upper = (upper+p1[i+1-1])*x;
00158     }
00159     den = (upper+p1[6])/(den+q1[5]);
00160     xmx0 = x-dx0;
00161     psi = den*xmx0+aug;
00162     return psi;
00163 S70:
00164 /*
00165 ---------------------------------------------------------------------
00166      IF X .GE. XMAX1, PSI = LN(X)
00167 ---------------------------------------------------------------------
00168 */
00169     if(x >= xmax1) goto S90;
00170 /*
00171 ---------------------------------------------------------------------
00172      3.0 .LT. X .LT. XMAX1
00173 ---------------------------------------------------------------------
00174 */
00175     w = 1.0e0/(x*x);
00176     den = w;
00177     upper = p2[0]*w;
00178     for(i=1; i<=3; i++) {
00179         den = (den+q2[i-1])*w;
00180         upper = (upper+p2[i+1-1])*w;
00181     }
00182     aug = upper/(den+q2[3])-0.5e0/x+aug;
00183 S90:
00184     psi = aug+log(x);
00185     return psi;
00186 S100:
00187 /*
00188 ---------------------------------------------------------------------
00189      ERROR RETURN
00190 ---------------------------------------------------------------------
00191 */
00192     psi = 0.0e0;
00193     return psi;
00194 } /* END */
 | 
| 
 | ||||||||||||
| 
 Definition at line 2 of file cdf_67.c. References a, gam1(), rcomp(), rlog(), and Xgamm(). Referenced by gaminv(), and rcomp(). 
 00010 {
00011 static double rt2pin = .398942280401433e0;
00012 static double rcomp,t,t1,u;
00013 /*
00014      ..
00015      .. Executable Statements ..
00016 */
00017     rcomp = 0.0e0;
00018     if(*a >= 20.0e0) goto S20;
00019     t = *a*log(*x)-*x;
00020     if(*a >= 1.0e0) goto S10;
00021     rcomp = *a*exp(t)*(1.0e0+gam1(a));
00022     return rcomp;
00023 S10:
00024     rcomp = exp(t)/Xgamm(a);
00025     return rcomp;
00026 S20:
00027     u = *x/ *a;
00028     if(u == 0.0e0) return rcomp;
00029     t = pow(1.0e0/ *a,2.0);
00030     t1 = (((0.75e0*t-1.0e0)*t+3.5e0)*t-105.0e0)/(*a*1260.0e0);
00031     t1 -= (*a*rlog(&u));
00032     rcomp = rt2pin*sqrt(*a)*exp(t1);
00033     return rcomp;
00034 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_68.c. References rexp(). Referenced by grat1(), gratio(), and rexp(). 
 00008 {
00009 static double p1 = .914041914819518e-09;
00010 static double p2 = .238082361044469e-01;
00011 static double q1 = -.499999999085958e+00;
00012 static double q2 = .107141568980644e+00;
00013 static double q3 = -.119041179760821e-01;
00014 static double q4 = .595130811860248e-03;
00015 static double rexp,w;
00016 /*
00017      ..
00018      .. Executable Statements ..
00019 */
00020     if(fabs(*x) > 0.15e0) goto S10;
00021     rexp = *x*(((p2**x+p1)**x+1.0e0)/((((q4**x+q3)**x+q2)**x+q1)**x+1.0e0));
00022     return rexp;
00023 S10:
00024     w = exp(*x);
00025     if(*x > 0.0e0) goto S20;
00026     rexp = w-0.5e0-0.5e0;
00027     return rexp;
00028 S20:
00029     rexp = w*(0.5e0+(0.5e0-1.0e0/w));
00030     return rexp;
00031 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_69.c. Referenced by gratio(), rcomp(), and rlog(). 
 00008 {
00009 static double a = .566749439387324e-01;
00010 static double b = .456512608815524e-01;
00011 static double p0 = .333333333333333e+00;
00012 static double p1 = -.224696413112536e+00;
00013 static double p2 = .620886815375787e-02;
00014 static double q1 = -.127408923933623e+01;
00015 static double q2 = .354508718369557e+00;
00016 static double rlog,r,t,u,w,w1;
00017 /*
00018      ..
00019      .. Executable Statements ..
00020 */
00021     if(*x < 0.61e0 || *x > 1.57e0) goto S40;
00022     if(*x < 0.82e0) goto S10;
00023     if(*x > 1.18e0) goto S20;
00024 /*
00025               ARGUMENT REDUCTION
00026 */
00027     u = *x-0.5e0-0.5e0;
00028     w1 = 0.0e0;
00029     goto S30;
00030 S10:
00031     u = *x-0.7e0;
00032     u /= 0.7e0;
00033     w1 = a-u*0.3e0;
00034     goto S30;
00035 S20:
00036     u = 0.75e0**x-1.e0;
00037     w1 = b+u/3.0e0;
00038 S30:
00039 /*
00040                SERIES EXPANSION
00041 */
00042     r = u/(u+2.0e0);
00043     t = r*r;
00044     w = ((p2*t+p1)*t+p0)/((q2*t+q1)*t+1.0e0);
00045     rlog = 2.0e0*t*(1.0e0/(1.0e0-r)-r*w)+w1;
00046     return rlog;
00047 S40:
00048     r = *x-0.5e0-0.5e0;
00049     rlog = r-log(*x);
00050     return rlog;
00051 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_70.c. Referenced by basym(), brcmp1(), brcomp(), and rlog1(). 
 00008 {
00009 static double a = .566749439387324e-01;
00010 static double b = .456512608815524e-01;
00011 static double p0 = .333333333333333e+00;
00012 static double p1 = -.224696413112536e+00;
00013 static double p2 = .620886815375787e-02;
00014 static double q1 = -.127408923933623e+01;
00015 static double q2 = .354508718369557e+00;
00016 static double rlog1,h,r,t,w,w1;
00017 /*
00018      ..
00019      .. Executable Statements ..
00020 */
00021     if(*x < -0.39e0 || *x > 0.57e0) goto S40;
00022     if(*x < -0.18e0) goto S10;
00023     if(*x > 0.18e0) goto S20;
00024 /*
00025               ARGUMENT REDUCTION
00026 */
00027     h = *x;
00028     w1 = 0.0e0;
00029     goto S30;
00030 S10:
00031     h = *x+0.3e0;
00032     h /= 0.7e0;
00033     w1 = a-h*0.3e0;
00034     goto S30;
00035 S20:
00036     h = 0.75e0**x-0.25e0;
00037     w1 = b+h/3.0e0;
00038 S30:
00039 /*
00040                SERIES EXPANSION
00041 */
00042     r = h/(h+2.0e0);
00043     t = r*r;
00044     w = ((p2*t+p1)*t+p0)/((q2*t+q1)*t+1.0e0);
00045     rlog1 = 2.0e0*t*(1.0e0/(1.0e0-r)-r*w)+w1;
00046     return rlog1;
00047 S40:
00048     w = *x+0.5e0+0.5e0;
00049     rlog1 = *x-log(w);
00050     return rlog1;
00051 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_71.c. References i, ibeta(), ipmpar(), and spmpar(). Referenced by bratio(), cdfbet(), cdfbin(), cdfchi(), cdff(), cdfgam(), cdfnbn(), cdfnor(), cdfpoi(), cdft(), cumnor(), gaminv(), gratio(), psi(), spmpar(), and Xgamm(). 
 00030 {
00031 static int K1 = 4;
00032 static int K2 = 8;
00033 static int K3 = 9;
00034 static int K4 = 10;
00035 static double spmpar,b,binv,bm1,one,w,z;
00036 static int emax,emin,ibeta,m;
00037 /*
00038      ..
00039      .. Executable Statements ..
00040 */
00041     if(*i > 1) goto S10;
00042     b = ipmpar(&K1);
00043     m = ipmpar(&K2);
00044     spmpar = pow(b,(double)(1-m));
00045     return spmpar;
00046 S10:
00047     if(*i > 2) goto S20;
00048     b = ipmpar(&K1);
00049     emin = ipmpar(&K3);
00050     one = 1.0;
00051     binv = one/b;
00052     w = pow(b,(double)(emin+2));
00053     spmpar = w*binv*binv*binv;
00054     return spmpar;
00055 S20:
00056     ibeta = ipmpar(&K1);
00057     m = ipmpar(&K2);
00058     emax = ipmpar(&K4);
00059     b = ibeta;
00060     bm1 = ibeta-1;
00061     one = 1.0;
00062     z = pow(b,(double)(m-1));
00063     w = ((z-one)*b+bm1)/(b*z);
00064     z = pow(b,(double)(emax-2));
00065     spmpar = w*z*b*b;
00066     return spmpar;
00067 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_72.c. References devlpl(), p, and stvaln(). Referenced by dinvnr(), and stvaln(). 
 00033 {
00034 static double xden[5] = {
00035     0.993484626060e-1,0.588581570495e0,0.531103462366e0,0.103537752850e0,
00036     0.38560700634e-2
00037 };
00038 static double xnum[5] = {
00039     -0.322232431088e0,-1.000000000000e0,-0.342242088547e0,-0.204231210245e-1,
00040     -0.453642210148e-4
00041 };
00042 static int K1 = 5;
00043 static double stvaln,sign,y,z;
00044 /*
00045      ..
00046      .. Executable Statements ..
00047 */
00048     if(!(*p <= 0.5e0)) goto S10;
00049     sign = -1.0e0;
00050     z = *p;
00051     goto S20;
00052 S10:
00053     sign = 1.0e0;
00054     z = 1.0e0-*p;
00055 S20:
00056     y = sqrt(-(2.0e0*log(z)));
00057     stvaln = y+devlpl(xnum,&K1,&y)/devlpl(xden,&K1,&y);
00058     stvaln = sign*stvaln;
00059     return stvaln;
00060 } /* END */
 | 
| 
 | 
| 
 Definition at line 2 of file cdf_62.c. References a, exparg(), fifidint(), fifmod(), i, p, q, spmpar(), top, and Xgamm(). Referenced by gaminv(), gratio(), rcomp(), and Xgamm(). 
 00019 {
00020 static double d = .41893853320467274178e0;
00021 static double pi = 3.1415926535898e0;
00022 static double r1 = .820756370353826e-03;
00023 static double r2 = -.595156336428591e-03;
00024 static double r3 = .793650663183693e-03;
00025 static double r4 = -.277777777770481e-02;
00026 static double r5 = .833333333333333e-01;
00027 static double p[7] = {
00028     .539637273585445e-03,.261939260042690e-02,.204493667594920e-01,
00029     .730981088720487e-01,.279648642639792e+00,.553413866010467e+00,1.0e0
00030 };
00031 static double q[7] = {
00032     -.832979206704073e-03,.470059485860584e-02,.225211131035340e-01,
00033     -.170458969313360e+00,-.567902761974940e-01,.113062953091122e+01,1.0e0
00034 };
00035 static int K2 = 3;
00036 static int K3 = 0;
00037 static double Xgamm,bot,g,lnx,s,t,top,w,x,z;
00038 static int i,j,m,n,T1;
00039 /*
00040      ..
00041      .. Executable Statements ..
00042 */
00043     Xgamm = 0.0e0;
00044     x = *a;
00045     if(fabs(*a) >= 15.0e0) goto S110;
00046 /*
00047 -----------------------------------------------------------------------
00048             EVALUATION OF GAMMA(A) FOR ABS(A) .LT. 15
00049 -----------------------------------------------------------------------
00050 */
00051     t = 1.0e0;
00052     m = fifidint(*a)-1;
00053 /*
00054      LET T BE THE PRODUCT OF A-J WHEN A .GE. 2
00055 */
00056     T1 = m;
00057     if(T1 < 0) goto S40;
00058     else if(T1 == 0) goto S30;
00059     else  goto S10;
00060 S10:
00061     for(j=1; j<=m; j++) {
00062         x -= 1.0e0;
00063         t = x*t;
00064     }
00065 S30:
00066     x -= 1.0e0;
00067     goto S80;
00068 S40:
00069 /*
00070      LET T BE THE PRODUCT OF A+J WHEN A .LT. 1
00071 */
00072     t = *a;
00073     if(*a > 0.0e0) goto S70;
00074     m = -m-1;
00075     if(m == 0) goto S60;
00076     for(j=1; j<=m; j++) {
00077         x += 1.0e0;
00078         t = x*t;
00079     }
00080 S60:
00081     x += (0.5e0+0.5e0);
00082     t = x*t;
00083     if(t == 0.0e0) return Xgamm;
00084 S70:
00085 /*
00086      THE FOLLOWING CODE CHECKS IF 1/T CAN OVERFLOW. THIS
00087      CODE MAY BE OMITTED IF DESIRED.
00088 */
00089     if(fabs(t) >= 1.e-30) goto S80;
00090     if(fabs(t)*spmpar(&K2) <= 1.0001e0) return Xgamm;
00091     Xgamm = 1.0e0/t;
00092     return Xgamm;
00093 S80:
00094 /*
00095      COMPUTE GAMMA(1 + X) FOR  0 .LE. X .LT. 1
00096 */
00097     top = p[0];
00098     bot = q[0];
00099     for(i=1; i<7; i++) {
00100         top = p[i]+x*top;
00101         bot = q[i]+x*bot;
00102     }
00103     Xgamm = top/bot;
00104 /*
00105      TERMINATION
00106 */
00107     if(*a < 1.0e0) goto S100;
00108     Xgamm *= t;
00109     return Xgamm;
00110 S100:
00111     Xgamm /= t;
00112     return Xgamm;
00113 S110:
00114 /*
00115 -----------------------------------------------------------------------
00116             EVALUATION OF GAMMA(A) FOR ABS(A) .GE. 15
00117 -----------------------------------------------------------------------
00118 */
00119     if(fabs(*a) >= 1.e3) return Xgamm;
00120     if(*a > 0.0e0) goto S120;
00121     x = -*a;
00122     n = x;
00123     t = x-(double)n;
00124     if(t > 0.9e0) t = 1.0e0-t;
00125     s = sin(pi*t)/pi;
00126     if(fifmod(n,2) == 0) s = -s;
00127     if(s == 0.0e0) return Xgamm;
00128 S120:
00129 /*
00130      COMPUTE THE MODIFIED ASYMPTOTIC SUM
00131 */
00132     t = 1.0e0/(x*x);
00133     g = ((((r1*t+r2)*t+r3)*t+r4)*t+r5)/x;
00134 /*
00135      ONE MAY REPLACE THE NEXT STATEMENT WITH  LNX = ALOG(X)
00136      BUT LESS ACCURACY WILL NORMALLY BE OBTAINED.
00137 */
00138     lnx = log(x);
00139 /*
00140      FINAL ASSEMBLY
00141 */
00142     z = x;
00143     g = d+g+(z-0.5e0)*(lnx-1.e0);
00144     w = g;
00145     t = g-w;
00146     if(w > 0.99999e0*exparg(&K3)) return Xgamm;
00147     Xgamm = exp(w)*(1.0e0+t);
00148     if(*a < 0.0e0) Xgamm = 1.0e0/(Xgamm*s)/x;
00149     return Xgamm;
00150 } /* END */
 | 
 
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
 
 
 
 
       
	   
	   
	   
	  