This function evaluates the inverse of a general continuous cumulative distribution function given in a subprogram.
GFNIN The
inverse of the function F at the point P.
(Output)
F(GFNIN) is close to
P.
F User-supplied
FUNCTION to be
inverted. F must
be continuous and strictly monotone. The form is F(X),
where
X The argument to the function.
(Input)
F The value of the function at X.
(Output)
F
must be declared EXTERNAL in the
calling program.
P The point at which the inverse of F is desired. (Input)
GUESS An initial estimate of the inverse of F at P. (Input)
EPS Convergence
criterion. (Input)
When the relative change in GFNIN from one
iteration to the next is less than EPS, convergence is
assumed. A common value for EPS is 0.0001. Another
common value is 100 times the machine epsilon.
Default: EPS = 100 times
the machine epsilon.
Generic: GFNIN (F, P, GUESS [, ])
Specific: The specific interface names are S_GFNIN and D_GFNIN.
Single: GFNIN (F, P, EPS, GUESS)
Double: The double precision name is DGFNIN.
Function GFNIN evaluates the inverse of a continuous, strictly monotone function. Its most obvious use is in evaluating inverses of continuous distribution functions that can be defined by a FORTRAN function. If the distribution function cannot be specified in a FORTRAN function, but the density function can be evaluated at a number of points, then routine GCIN can be used.
Function GFNIN uses regula falsi and/or bisection, possibly with the Illinois modification (see Dahlquist and Bjorck 1974). A maximum of 100 iterations are performed.
1. Informational errors
Type Code
4 1 After 100 attempts, a bound for the inverse cannot be determined. Try again with a different initial estimate.
4 2 No unique inverse exists.
4 3 Over 100 iterations have occurred without convergence. Convergence is assumed.
2. The function to be inverted need not be a distribution function, it can be any continuous, monotonic function.
In this example, we find the 99th percentage point for an F random variable with 1 and 7 degrees of freedom. (This problem could be solved easily using routine FIN. Compare the example for FIN). The function to be inverted is the F distribution function, for which we use routine FDF. Since FDF requires the degrees of freedom in addition to the point at which the function is evaluated, we write another function F that receives the degrees of freedom via a common block and then calls FDF. The starting point (initial guess) is taken as two standard deviations above the mean (since this would be a good guess for a normal distribution). It is not necessary to supply such a good guess. In this particular case, an initial estimate of 1.0, for example, yields the same answer in essentially the same number of iterations. (In fact, since the F distribution is skewed, the initial guess, 7.0, is really not that close to the final answer.)
REAL DFD, DFN, F, F0, GUESS, P, SQRT
! Compute GUESS as two standard
GUESS = DFD/(DFD-2.0) + 2.0*SQRT(2.0*DFD*DFD*(DFN+DFD-2.0)/(DFN* &
99999 FORMAT (' The F(1,7) 0.01 critical value is ', F6.3)
The F(1,7) 0.01 critical value is 12.246
|
Visual Numerics, Inc. PHONE: 713.784.3131 FAX:713.781.9260 |