Math-CDF
view release on metacpan or search on metacpan
cdflib/doc/README view on Meta::CPAN
indicates that the answer was apparently higher than the upper bound
on the search interval. A return code of 3 indicates that P and Q did
not sum to 1. Other positive codes are routine specific.
BOUND is not set if status is returned as 0. If STATUS is -I then
BOUND is the bound illegally exceeded by input parameter I, where
WHICH is counted as 1, P as 2, Q as 3, X as 4, etc. If STATUS is
returned as 1 or 2 then bound is returned as the lower or upper bound
on the search interval respectively.
BOUNDS
Below are the rules that we used in determining bounds on quantities
to be calculated. Those who don't care can find a summary of the
bounds in dcdflib.chs. Input bounds are checked for legality of
input. The search range is the range of values searched for an
answer.
Input Bounds
Bounds on input parameters are checked by the cdf* routines. These
bounds were set according to the following rules.
P: If the domain of the cdf (X) extends to -infinity then P must be
greater than 0 otherwise P must be greater than or equal to 0. P must
always be less than or equal to 1.
Q: If the domain of the cdf (X) extends to +infinity then Q must be
greater than 0 otherwise Q must be greater than or equal to 0. Q must
always be less than or equal to 1.
Further, P and Q must sum to 1. The smaller of the two P and Q will be
used in calculations to increase accuracy
X: If the domain is infinite in either the positive or negative
direction, no check is performed in that direction. If the left end
of the domain is 0, then X is checked to assure non-negativity.
DF, SD, etc.: Some auxiliary parameters must be positive. The lowest
input values accepted for these parameters is 1E-100.
Search Bounds
These are the ranges searched for an answer. If the domain of the
parameter in the cdf is closed at some finite value, e.g., 0, then
this value is the same endpoint of the search range. If the domain is
open at some finite endpoint (which only occurs for 0 -- some
parameters must be strictly positive) then the endpoint is 1E-100. If
the domain is infinite in either direction then +/- 1E100 is used as
the endpoint of the search range.
HOW THE ROUTINES WORK
The cumulative distribution functions are computed directly. The
normal, gamma, and beta functions use the code from the references
cited. Other cdfs are calculated by relating them to one of these
distributions. For example, the binomial and negative binomial cdfs
can be converted to a beta cdf. This is how fractional observations
are handled. The formula from Abramowitz and Stegun for converting
the cdfs is cited in the fdoc file. (We think the formula for the
negative binomial in A&S is wrong, but there is a correct one which we
used.)
The inverse normal and gamma are also taken from the references. For
all other parameters, a search is made for the value that provides the
desired P. Initial values are chosen crudely for the search (e.g.,
5). If the domain of the cdf for the parameter being calculated is
infinite, a step doubling strategy is used to bound the desired value
then the zero finder is employed to refine the answer. The zero
finder attempts to obtain the answer accurately to about eight decimal
places.
( run in 2.898 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )