1
SUBROUTINE cdffnc(which,p,q,f,dfn,dfd,phonc,status,bound)
2
C**********************************************************************
4
C SUBROUTINE CDFFNC( WHICH, P, Q, F, DFN, DFD, PNONC, STATUS, BOUND )
5
C Cumulative Distribution Function
6
C Non-central F distribution
12
C Calculates any one parameter of the Non-central F
13
C distribution given values for the others.
19
C WHICH --> Integer indicating which of the next five argument
20
C values is to be calculated from the others.
22
C iwhich = 1 : Calculate P and Q from F,DFN,DFD and PNONC
23
C iwhich = 2 : Calculate F from P,Q,DFN,DFD and PNONC
24
C iwhich = 3 : Calculate DFN from P,Q,F,DFD and PNONC
25
C iwhich = 4 : Calculate DFD from P,Q,F,DFN and PNONC
26
C iwhich = 5 : Calculate PNONC from P,Q,F,DFN and DFD
29
C P <--> The integral from 0 to F of the non-central f-density.
30
C Input range: [0,1-1E-16).
34
C Q is not used by this subroutine and is only included
35
C for similarity with other cdf* routines.
38
C F <--> Upper limit of integration of the non-central f-density.
39
C Input range: [0, +infinity).
40
C Search range: [0,1E100]
43
C DFN < --> Degrees of freedom of the numerator sum of squares.
44
C Input range: (0, +infinity).
45
C Search range: [ 1E-100, 1E100]
46
C DOUBLE PRECISION DFN
48
C DFD < --> Degrees of freedom of the denominator sum of squares.
49
C Must be in range: (0, +infinity).
50
C Input range: (0, +infinity).
51
C Search range: [ 1E-100, 1E100]
52
C DOUBLE PRECISION DFD
54
C PNONC <-> The non-centrality parameter
55
C Input range: [0,infinity)
56
C Search range: [0,1E4]
57
C DOUBLE PRECISION PHONC
59
C STATUS <-- 0 if calculation completed correctly
60
C -I if input parameter number I is out of range
61
C 1 if answer appears to be lower than lowest
63
C 2 if answer appears to be higher than greatest
68
C BOUND <-- Undefined if STATUS is 0
70
C Bound exceeded by parameter number I if STATUS
73
C Lower search bound if STATUS is 1.
75
C Upper search bound if STATUS is 2.
81
C Formula 26.6.20 of Abramowitz and Stegun, Handbook of
82
C Mathematical Functions (1966) is used to compute the cumulative
83
C distribution function.
85
C Computation of other parameters involve a seach for a value that
86
C produces the desired value of P. The search relies on the
87
C monotinicity of P with the other parameter.
91
C The computation time required for this routine is proportional
92
C to the noncentrality parameter (PNONC). Very large values of
93
C this parameter can consume immense computer resources. This is
94
C why the search range is bounded by 10,000.
98
C The value of the cumulative noncentral F distribution is not
99
C necessarily monotone in either degrees of freedom. There thus
100
C may be two values that provide a given CDF value. This routine
101
C assumes monotonicity and will find an arbitrary one of the two
104
C**********************************************************************
106
DOUBLE PRECISION tent4
107
PARAMETER (tent4=1.0D4)
109
PARAMETER (tol=1.0D-8)
110
DOUBLE PRECISION atol
111
PARAMETER (atol=1.0D-50)
112
DOUBLE PRECISION zero,one,inf
113
PARAMETER (zero=1.0D-100,one=1.0D0-1.0D-16,inf=1.0D100)
115
C .. Scalar Arguments ..
116
DOUBLE PRECISION bound,dfd,dfn,f,p,phonc,q
119
C .. Local Scalars ..
120
DOUBLE PRECISION ccum,cum,fx
123
C .. External Subroutines ..
124
EXTERNAL cumfnc,dinvr,dstinv
126
IF (.NOT. ((which.LT.1).OR. (which.GT.5))) GO TO 30
127
IF (.NOT. (which.LT.1)) GO TO 10
135
30 IF (which.EQ.1) GO TO 70
136
IF (.NOT. ((p.LT.0.0D0).OR. (p.GT.one))) GO TO 60
137
IF (.NOT. (p.LT.0.0D0)) GO TO 40
146
70 IF (which.EQ.2) GO TO 90
147
IF (.NOT. (f.LT.0.0D0)) GO TO 80
153
90 IF (which.EQ.3) GO TO 110
154
IF (.NOT. (dfn.LE.0.0D0)) GO TO 100
160
110 IF (which.EQ.4) GO TO 130
161
IF (.NOT. (dfd.LE.0.0D0)) GO TO 120
167
130 IF (which.EQ.5) GO TO 150
168
IF (.NOT. (phonc.LT.0.0D0)) GO TO 140
174
150 IF ((1).EQ. (which)) THEN
175
CALL cumfnc(f,dfn,dfd,phonc,p,q)
178
ELSE IF ((2).EQ. (which)) THEN
180
CALL dstinv(0.0D0,inf,0.5D0,0.5D0,5.0D0,atol,tol)
182
CALL dinvr(status,f,fx,qleft,qhi)
183
160 IF (.NOT. (status.EQ.1)) GO TO 170
184
CALL cumfnc(f,dfn,dfd,phonc,cum,ccum)
186
CALL dinvr(status,f,fx,qleft,qhi)
189
170 IF (.NOT. (status.EQ.-1)) GO TO 200
190
IF (.NOT. (qleft)) GO TO 180
200
ELSE IF ((3).EQ. (which)) THEN
202
CALL dstinv(zero,inf,0.5D0,0.5D0,5.0D0,atol,tol)
204
CALL dinvr(status,dfn,fx,qleft,qhi)
205
210 IF (.NOT. (status.EQ.1)) GO TO 220
206
CALL cumfnc(f,dfn,dfd,phonc,cum,ccum)
208
CALL dinvr(status,dfn,fx,qleft,qhi)
211
220 IF (.NOT. (status.EQ.-1)) GO TO 250
212
IF (.NOT. (qleft)) GO TO 230
222
ELSE IF ((4).EQ. (which)) THEN
224
CALL dstinv(zero,inf,0.5D0,0.5D0,5.0D0,atol,tol)
226
CALL dinvr(status,dfd,fx,qleft,qhi)
227
260 IF (.NOT. (status.EQ.1)) GO TO 270
228
CALL cumfnc(f,dfn,dfd,phonc,cum,ccum)
230
CALL dinvr(status,dfd,fx,qleft,qhi)
233
270 IF (.NOT. (status.EQ.-1)) GO TO 300
234
IF (.NOT. (qleft)) GO TO 280
244
ELSE IF ((5).EQ. (which)) THEN
246
CALL dstinv(0.0D0,tent4,0.5D0,0.5D0,5.0D0,atol,tol)
248
CALL dinvr(status,phonc,fx,qleft,qhi)
249
310 IF (.NOT. (status.EQ.1)) GO TO 320
250
CALL cumfnc(f,dfn,dfd,phonc,cum,ccum)
252
CALL dinvr(status,phonc,fx,qleft,qhi)
255
320 IF (.NOT. (status.EQ.-1)) GO TO 350
256
IF (.NOT. (qleft)) GO TO 330