Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

cdf_17.c File Reference

#include "cdflib.h"

Go to the source code of this file.


Defines

#define tent4   1.0e4
#define tol   (1.0e-8)
#define atol   (1.0e-50)
#define zero   (1.0e-300)
#define one   (1.0e0-1.0e-16)
#define inf   1.0e300

Functions

void cdfchn (int *which, double *p, double *q, double *x, double *df, double *pnonc, int *status, double *bound)

Define Documentation

#define atol   (1.0e-50)
 

#define inf   1.0e300
 

#define one   (1.0e0-1.0e-16)
 

#define tent4   1.0e4
 

#define tol   (1.0e-8)
 

#define zero   (1.0e-300)
 


Function Documentation

void cdfchn int *    which,
double *    p,
double *    q,
double *    x,
double *    df,
double *    pnonc,
int *    status,
double *    bound
 

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 */
 

Powered by Plone

This site conforms to the following standards: