GCDF
This function evaluates a general continuous cumulative distribution function given ordinates of the density.
Function Return Value
GCDF — Function value, the probability that a random variable whose density is given in F takes a value less than or equal to X0. (Output)
Required Arguments
X0 —Point at which the cumulative distribution function is to be evaluated. (Input)
X — Array containing the abscissas or the endpoints. (Input)
If IOPT = 1 or 3, X is of length 2. If IOPT = 2 or 4, X is of length M. For IOPT = 1 or 3, X(1) contains the lower endpoint of the support of the distribution and X(2) is the upper endpoint. For IOPT = 2 or 4, X contains, in strictly increasing order, the abscissas such that X(I) corresponds to F(I).
F — Vector of length M containing the probability density ordinates corresponding to increasing abscissas. (Input)
If IOPT = 1 or 3, for I = 1, 2, , MF(I) corresponds to X(1) + (I  1) * (X(2)   X(1))/(M  1); otherwise, F and X correspond one for one.
Optional Arguments
IOPT — Indicator of the method of interpolation. (Input)
Default: IOPT = 1.
IOPT
Interpolation Method
1
Linear interpolation with equally spaced abscissas.
2
Linear interpolation with possibly unequally spaced abscissas.
3
A cubic spline is fitted to equally spaced abscissas.
4
A cubic spline is fitted to possibly unequally spaced abscissas.
M —Number of ordinates of the density supplied. (Input)
M must be greater than 1 for linear interpolation (IOPT = 1 or 2) and greater than 3 if a curve is fitted through the ordinates (IOPT = 3 or 4).
Default: M = size (F,1).
FORTRAN 90 Interface
Generic: GCDF (X0, X, F [])
Specific: The specific interface names are S_GCDF and D_GCDF.
FORTRAN 77 Interface
Single: GCDF (X0, IOPT, M, X, F)
Double: The double precision name is DGCDF.
Description
Function GCDF evaluates a continuous distribution function, given ordinates of the probability density function. It requires that the range of the distribution be specified in X. For distributions with infinite ranges, endpoints must be chosen so that most of the probability content is included. The function GCDF first fits a curve to the points given in X and F with either a piecewise linear interpolant or a C 1 cubic spline interpolant based on a method by Akima (1970). Function GCDF then determines the area, A, under the curve. (If the distribution were of finite range and if the fit were exact, this area would be 1.0.) Using the same fitted curve, GCDF next determines the area up to the point x0 (= X0). The value returned is the area up to x0 divided by A. Because of the scaling by A, it is not assumed that the integral of the density defined by X and F is 1.0. For most distributions, it is likely that better approximations to the distribution function are obtained when IOPT equals 3 or 4, that is, when a cubic spline is used to approximate the function. It is also likely that better approximations can be obtained when the abscissas are chosen more densely over regions where the density and its derivatives (when they exist) are varying greatly.
Comments
1. If IOPT = 3, automatic workspace usage is:
GCDF* M units, or
DGCDF 11 * M units.
2. If IOPT = 4, automatic workspace usage is
GCDF* M units, or
DGCDF* M units.
3. Workspace may be explicitly provided, if desired, by the use of G4DF/DG4DF. The reference is:
G4DF (P, IOPT, M, X, F, WK, IWK)
The arguments in addition to those of GCDF are:
WK — Work vector of length 5 * M if IOPT = 3, and of length 4 * M if IOPT = 4.
IWK — Work vector of length M.
Example
In this example, we evaluate the beta distribution function at the point 0.6. The probability density function of a beta random variable with parameters p and q is
where Γ() is the gamma function. The density is equal to 0 outside the interval [0, 1]. We compute a constant multiple (we can ignore the constant gamma functions) of the density at 300 equally spaced points and input this information in X and F. Knowing that the probability density of this distribution is very peaked in the vicinity of 0.5, we could perhaps get a better fit by using unequally spaced abscissas, but we will keep it simple. Note that this is the same example as one used in the description of routine BETDF. The result from BETDF would be expected to be more accurate than that from GCDF since BETDF is designed specifically for this distribution.
 
USE UMACH_INT
USE GCDF_INT
IMPLICIT NONE
INTEGER M
PARAMETER (M=300)
!
INTEGER I, IOPT, NOUT
REAL F(M), H, P, PIN1, QIN1, X(2), X0, XI
!
CALL UMACH (2, NOUT)
X0 = 0.6
IOPT = 3
! Initializations for a beta(12,12)
! distribution.
PIN1 = 11.0
QIN1 = 11.0
XI = 0.0
H = 1.0/(M-1.0)
X(1) = XI
F(1) = 0.0
XI = XI + H
! Compute ordinates of the probability
! density function.
DO 10 I=2, M - 1
F(I) = XI**PIN1*(1.0-XI)**QIN1
XI = XI + H
10 CONTINUE
X(2) = 1.0
F(M) = 0.0
P = GCDF(X0, X, F, IOPT=IOPT)
WRITE (NOUT,99999) P
99999 FORMAT (' The probability that X is less than 0.6 is ', F6.4)
END
Output
 
The probability that X is less than 0.6 is 0.8364