Math-CDF

 view release on metacpan or  search on metacpan

cdflib/dcdflib.c  view on Meta::CPAN

 
                              Method
 
 
     If X .le. 6.0, then use recursion to get X below 3
     then apply rational approximation number 5236 of
     Hart et al, Computer Approximations, John Wiley and
     Sons, NY, 1968.
 
     If X .gt. 6.0, then use recursion to get X to at least 12 and
     then use formula 5423 of the same source.
 
**********************************************************************
*/
{
#define hln2pi 0.91893853320467274178e0
static double coef[5] = {
    0.83333333333333023564e-1,-0.27777777768818808e-2,0.79365006754279e-3,
    -0.594997310889e-3,0.8065880899e-3
};
static double scoefd[4] = {

cdflib/dcdflib.c  view on Meta::CPAN

     is used to calulate the  cumulative standard normal distribution.

     The rational functions from pages  90-95  of Kennedy and Gentle,
     Statistical  Computing,  Marcel  Dekker, NY,  1980 are  used  as
     starting values to Newton's Iterations which compute the inverse
     standard normal.  Therefore no  searches  are necessary for  any
     parameter.

     For X < -15, the asymptotic expansion for the normal is used  as
     the starting value in finding the inverse standard normal.
     This is formula 26.2.12 of Abramowitz and Stegun.


                              Note


      The normal density is proportional to
      exp( - 0.5 * (( X - MEAN)/SD)**2)

**********************************************************************/
{

cdflib/dcdflib.c  view on Meta::CPAN

                Bound exceeded by parameter number I if STATUS
                is negative.
 
                Lower search bound if STATUS is 1.
 
                Upper search bound if STATUS is 2.
 
                                 Method
 
      Upper tail    of  the  cumulative  noncentral t is calculated usin
      formulae  from page 532  of Johnson, Kotz,  Balakrishnan, Coninuou
      Univariate Distributions, Vol 2, 2nd Edition.  Wiley (1995)
 
      Computation of other parameters involve a seach for a value that
      produces  the desired  value  of P.   The search relies  on  the
      monotinicity of P with the other parameter.
 
**********************************************************************/
{
#define tent4 1.0e4
#define tol 1.0e-8

cdflib/dcdflib.c  view on Meta::CPAN

     PNONC   --> Non-centrality parameter of the non-central
                 chi-square distribution.
 
     CUM <-- Cumulative non-central chi-square distribution.
 
     CCUM <-- Compliment of Cumulative non-central chi-square distribut
 
 
                                Method
 
     Uses  formula  26.4.25   of  Abramowitz  and  Stegun, Handbook  of
     Mathematical    Functions,  US   NBS   (1966)    to calculate  the
     non-central chi-square.
 
                                Variables
 
     EPS     --- Convergence criterion.  The sum stops when a
                 term is less than EPS*SUM.
 
     CCUM <-- Compliment of Cumulative non-central
              chi-square distribution.

cdflib/dcdflib.c  view on Meta::CPAN

     CUM <-- Cumulative poisson distribution.
                                        CUM is DOUBLE PRECISION
 
     CCUM <-- Compliment of Cumulative poisson distribution.
                                                  CCUM is DOUBLE PRECIS
 
 
                              Method
 
 
     Uses formula  26.4.21   of   Abramowitz and  Stegun,  Handbook  of
     Mathematical   Functions  to reduce   the   cumulative Poisson  to
     the cumulative chi-square distribution.
 
**********************************************************************
*/
{
static double chi,df;
/*
     ..
     .. Executable Statements ..

cdflib/dcdflib.c  view on Meta::CPAN

      PNONC --> Non-centrality parameter of the non-central t distibutio
 
      CUM <-- Cumulative t-distribution.
 
      CCUM <-- Compliment of Cumulative t-distribution.
 
 
                               Method
 
      Upper tail    of  the  cumulative  noncentral t   using
      formulae from page 532  of Johnson, Kotz,  Balakrishnan, Coninuous
      Univariate Distributions, Vol 2, 2nd Edition.  Wiley (1995)
 
      This implementation starts the calculation at i = lambda,
      which is near the largest Di.  It then sums forward and backward.
**********************************************************************/
{
#define one 1.0e0
#define zero 0.0e0
#define half 0.5e0
#define two 2.0e0

cdflib/doc/README  view on Meta::CPAN

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

cdflib/doc/dcdflib.fdoc  view on Meta::CPAN

     is used to calulate the  cumulative standard normal distribution.

     The rational functions from pages  90-95  of Kennedy and Gentle,
     Statistical  Computing,  Marcel  Dekker, NY,  1980 are  used  as
     starting values to Newton's Iterations which compute the inverse
     standard normal.  Therefore no  searches  are necessary for  any
     parameter.

     For X < -15, the asymptotic expansion for the normal is used  as
     the starting value in finding the inverse standard normal.
     This is formula 26.2.12 of Abramowitz and Stegun.


                              Note


      The normal density is proportional to
      exp( - 0.5 * (( X - MEAN)/SD)**2)

**********************************************************************/
/**********************************************************************

cdflib/doc/dcdflib.fdoc  view on Meta::CPAN

                Bound exceeded by parameter number I if STATUS
                is negative.
 
                Lower search bound if STATUS is 1.
 
                Upper search bound if STATUS is 2.
 
                                 Method
 
      Upper tail    of  the  cumulative  noncentral t is calculated usin
      formulae  from page 532  of Johnson, Kotz,  Balakrishnan, Coninuou
      Univariate Distributions, Vol 2, 2nd Edition.  Wiley (1995)
 
      Computation of other parameters involve a seach for a value that
      produces  the desired  value  of P.   The search relies  on  the
      monotinicity of P with the other parameter.
 
**********************************************************************/



( run in 0.273 second using v1.01-cache-2.11-cpan-26ccb49234f )