Previous Next Contents

17  Cumulative Distribution Functions, Inverses, Random variables

17.1   cdfbet cumulative distribution function Beta distribution




CALLING SEQUENCE :

[P,Q]=cdfbet("PQ",X,Y,A,B)
[X,Y]=cdfbet("XY",A,B,P,Q)
[A]=cdfbet("A",B,P,Q,X,Y)
[B]=cdfbet("B",P,Q,X,Y,A)



PARAMETERS :




DESCRIPTION :

Calculates any one parameter of the beta distribution given values for the others (The beta density is proportional to t^(A-1) * (1-t)^(B-1).

Cumulative distribution function (P) is calculated directly by code associated with the following reference.

DiDinato, A. R. and Morris, A. H. Algorithm 708: Significant Digit Computation of the Incomplete Beta Function Ratios. ACM Trans. Math. Softw. 18 (1993), 360-373.

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.

From DCDFLIB: Library of Fortran Routines for Cumulative Distribution Functions, Inverses, and Other Parameters (February, 1994) Barry W. Brown, James Lovato and Kathy Russell. The University of Texas.



17.2   cdfbin cumulative distribution function Binomial distribution




CALLING SEQUENCE :

[P,Q]=cdfbin("PQ",S,Xn,Pr,Ompr)
[S]=cdfbin("S",Xn,Pr,Ompr,P,Q)
[Xn]=cdfbin("Xn",Pr,Ompr,P,Q,S)
[Pr,Ompr]=cdfbin("PrOmpr",P,Q,S,Xn)



PARAMETERS :




DESCRIPTION :

Calculates any one parameter of the binomial distribution given values for the others.

Formula 26.5.24 of Abramowitz and Stegun, Handbook of Mathematical Functions (1966) is used to reduce the binomial distribution to the cumulative incomplete beta distribution.

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.

From DCDFLIB: Library of Fortran Routines for Cumulative Distribution Functions, Inverses, and Other Parameters (February, 1994) Barry W. Brown, James Lovato and Kathy Russell. The University of Texas.



17.3   cdfchi cumulative distribution function chi-square distribution




CALLING SEQUENCE :

[P,Q]=cdfchi("PQ",X,Df)
[X]=cdfchi("X",Df,P,Q);
[Df]=cdfchi("Df",P,Q,X)



PARAMETERS :




DESCRIPTION :

Calculates any one parameter of the chi-square distribution given values for the others.

Formula 26.4.19 of Abramowitz and Stegun, Handbook of Mathematical Functions (1966) is used to reduce the chisqure distribution to the incomplete distribution.

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.

From DCDFLIB: Library of Fortran Routines for Cumulative Distribution Functions, Inverses, and Other Parameters (February, 1994) Barry W. Brown, James Lovato and Kathy Russell. The University of Texas.



17.4   cdfchn cumulative distribution function non-central chi-square distribution




CALLING SEQUENCE :

[P,Q]=cdfchn("PQ",X,Df,Pnonc)
[X]=cdfchn("X",Df,Pnonc,P,Q);
[Df]=cdfchn("Df",Pnonc,P,Q,X)
[Pnonc]=cdfchn("Pnonc",P,Q,X,Df)



PARAMETERS :




DESCRIPTION :

Calculates any one parameter of the non-central chi-square distribution given values for the others.

Formula 26.4.25 of Abramowitz and Stegun, Handbook of Mathematical Functions (1966) is used to compute the cumulative distribution function.

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.

The computation time required for this routine is proportional to the noncentrality parameter (PNONC). Very large values of this parameter can consume immense computer resources. This is why the search range is bounded by 10,000.

From DCDFLIB: Library of Fortran Routines for Cumulative Distribution Functions, Inverses, and Other Parameters (February, 1994) Barry W. Brown, James Lovato and Kathy Russell. The University of Texas.



17.5   cdff cumulative distribution function F distribution




CALLING SEQUENCE :

[P,Q]=cdff("PQ",F,Dfn,Dfd)
[F]=cdff("F",Dfn,Dfd,P,Q);
[Dfn]=cdff("Dfn",Dfd,P,Q,F);
[Dfd]=cdff("Dfd",P,Q,F,Dfn)



PARAMETERS :




DESCRIPTION :

Calculates any one parameter of the F distribution given values for the others.

Formula 26.6.2 of Abramowitz and Stegun, Handbook of Mathematical Functions (1966) is used to reduce the computation of the cumulative distribution function for the F variate to that of an incomplete beta.

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.

The value of the cumulative F distribution is not necessarily monotone in either degrees of freedom. There thus may be two values that provide a given CDF value. This routine assumes monotonicity and will find an arbitrary one of the two values.

From DCDFLIB: Library of Fortran Routines for Cumulative Distribution Functions, Inverses, and Other Parameters (February, 1994) Barry W. Brown, James Lovato and Kathy Russell. The University of Texas.



17.6   cdffnc cumulative distribution function non-central f-distribution




CALLING SEQUENCE :

[P,Q]=cdffnc("PQ",F,Dfn,Dfd,Pnonc)
[F]=cdffnc("F",Dfn,Dfd,Pnonc,P,Q);
[Dfn]=cdffnc("Dfn",Dfd,Pnonc,P,Q,F);
[Dfd]=cdffnc("Dfd",Pnonc,P,Q,F,Dfn)
[Pnonc]=cdffnc("Pnonc",P,Q,F,Dfn,Dfd);



PARAMETERS :




DESCRIPTION :

Calculates any one parameter of the Non-central F distribution given values for the others.

Formula 26.6.20 of Abramowitz and Stegun, Handbook of Mathematical Functions (1966) is used to compute the cumulative distribution function.

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.

The computation time required for this routine is proportional to the noncentrality parameter (PNONC). Very large values of this parameter can consume immense computer resources. This is why the search range is bounded by 10,000.

The value of the cumulative noncentral F distribution is not necessarily monotone in either degrees of freedom. There thus may be two values that provide a given CDF value. This routine assumes monotonicity and will find an arbitrary one of the two values.

From DCDFLIB: Library of Fortran Routines for Cumulative Distribution Functions, Inverses, and Other Parameters (February, 1994) Barry W. Brown, James Lovato and Kathy Russell. The University of Texas.



17.7   cdfgam cumulative distribution function gamma distribution




CALLING SEQUENCE :

[P,Q]=cdfgam("PQ",X,Shape,Scale)
[X]=cdfgam("X",Shape,Scale,P,Q)
[Shape]=cdfgam("Shape",Scale,P,Q,X)
[Scale]=cdfgam("Scale",P,Q,X,Shape)



PARAMETERS :




DESCRIPTION :

Calculates any one parameter of the gamma distribution given values for the others.

Cumulative distribution function (P) is calculated directly by the code associated with:

DiDinato, A. R. and Morris, A. H. Computation of the incomplete gamma function ratios and their inverse. ACM Trans. Math. Softw. 12 (1986), 377-393.

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.

The gamma density is proportional to T**(SHAPE - 1) * EXP(- SCALE * T)


From DCDFLIB: Library of Fortran Routines for Cumulative Distribution Functions, Inverses, and Other Parameters (February, 1994) Barry W. Brown, James Lovato and Kathy Russell. The University of Texas.



17.8   cdfnbn cumulative distribution function negative binomial distribution




CALLING SEQUENCE :

[P,Q]=cdfnbn("PQ",S,Xn,Pr,Ompr)
[S]=cdfnbn("S",Xn,Pr,Ompr,P,Q)
[Xn]=cdfnbn("Xn",Pr,Ompr,P,Q,S)
[Pr,Ompr]=cdfnbn("PrOmpr",P,Q,S,Xn)



PARAMETERS :




DESCRIPTION :

Calculates any one parameter of the negative binomial distribution given values for the others.

The cumulative negative binomial distribution returns the probability that there will be F or fewer failures before the XNth success in binomial trials each of which has probability of success PR.

The individual term of the negative binomial is the probability of S failures before XN successes and is Choose( S, XN+S-1 ) * PR^(XN) * (1-PR)^S

Formula 26.5.26 of Abramowitz and Stegun, Handbook of Mathematical Functions (1966) is used to reduce calculation of the cumulative distribution function to that of an incomplete beta.

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.

From DCDFLIB: Library of Fortran Routines for Cumulative Distribution Functions, Inverses, and Other Parameters (February, 1994) Barry W. Brown, James Lovato and Kathy Russell. The University of Texas.



17.9   cdfnor cumulative distribution function normal distribution




CALLING SEQUENCE :

[P,Q]=cdfnor("PQ",X,Mean,Std)
[X]=cdfnor("X",Mean,Std,P,Q)
[Mean]=cdfnor("Mean",Std,P,Q,X)
[Std]=cdfnor("Std",P,Q,X,Mean)



PARAMETERS :




DESCRIPTION :

Calculates any one parameter of the normal distribution given values for the others.

A slightly modified version of ANORM from Cody, W.D. (1993). "ALGORITHM 715: SPECFUN - A Portabel FORTRAN Package of Special Function Routines and Test Drivers" acm Transactions on Mathematical Software. 19, 22-32. 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.

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

From DCDFLIB: Library of Fortran Routines for Cumulative Distribution Functions, Inverses, and Other Parameters (February, 1994) Barry W. Brown, James Lovato and Kathy Russell. The University of Texas.



17.10   cdfpoi cumulative distribution function poisson distribution




CALLING SEQUENCE :

[P,Q]=cdfpoi("PQ",S,Xlam)
[S]=cdfpoi("S",Xlam,P,Q)
[Xlam]=cdfpoi("Xlam",P,Q,S);



PARAMETERS :




DESCRIPTION :

Calculates any one parameter of the Poisson distribution given values for the others.

Formula 26.4.21 of Abramowitz and Stegun, Handbook of Mathematical Functions (1966) is used to reduce the computation of the cumulative distribution function to that of computing a chi-square, hence an incomplete gamma function.

Cumulative distribution function (P) is calculated directly. 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.

From DCDFLIB: Library of Fortran Routines for Cumulative Distribution Functions, Inverses, and Other Parameters (February, 1994) Barry W. Brown, James Lovato and Kathy Russell. The University of Texas.



17.11   cdft cumulative distribution function Student's T distribution




CALLING SEQUENCE :

[P,Q]=cdft("PQ",T,Df)
[T]=cdft("T",Df,P,Q)
[Df]=cdft("Df",P,Q,T)



PARAMETERS :




DESCRIPTION :

Calculates any one parameter of the T distribution given values for the others.

Formula 26.5.27 of Abramowitz and Stegun, Handbook of Mathematical Functions (1966) is used to reduce the computation of the cumulative distribution function to that of an incomplete beta.

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.



17.12   grand Random number generator




CALLING SEQUENCE :

Y=grand(m,n,'option' [,arg1,..,argn])
Y=grand(x,'option' [,arg1,....,argn])
Y=grand('option')
Y=grand('option'  [,arg1,....,argn])



PARAMETERS :




DESCRIPTION  :

Interface fo Library of Fortran Routines for Random Number Generation (Barry W. Brown and James Lovato, Department of Biomathematics, The University of Texas, Houston)

This set of programs contains 32 virtual random number generators. Each generator can provide 1,048,576 blocks of numbers, and each block is of length 1,073,741,824. Any generator can be set to the beginning or end of the current block or to its starting value. The methods are from the paper cited immediately below, and most of the code is a transliteration from the Pascal of the paper into Fortran.

P. L'Ecuyer and S. Cote. Implementing a Random Number Package with Splitting Facilities. ACM Transactions on Mathematical Software 17:1, pp 98-111.

Most users won't need the sophisticated capabilities of this package, and will desire a single generator. This single generator (which will have a non-repeating length of 2.3 X 10^18 numbers) is the default. In order to accommodate this use, the concept of the current generator is added to those of the cited paper; references to a generator are always to the current generator. The current generator is initially generator number 1; it can be changed by 'setcgn', and the ordinal number of the current generator can be obtained from 'getcgn'.

The user of the default can set the initial values of the two integer seeds with 'setall'. If the user does not set the seeds, the random number generation will use the default values, 1234567890 and 123456789. The values of the current seeds can be achieved by a call to 'getsd'. Random number may be obtained as integers ranging from 1 to a large integer by reference to option 'lgi' or as a floating point number between 0 and 1 by a reference to option 'def'. These are the only routines needed by a user desiring a single stream of random numbers.


CONCEPTS :

A stream of pseudo-random numbers is a sequence, each member of which can be obtained either as an integer in the range 1..2,147,483,563 or as a floating point number in the range [0..1]. The user is in charge of which representation is desired.

The method contains an algorithm for generating a stream with a very long period, 2.3 X 10^18. This stream in partitioned into G (=32) virtual generators. Each virtual generator contains 2^20 (=1,048,576) blocks of non-overlapping random numbers. Each block is 2^30 (=1,073,741,824) in length.

The state of a generator is determined by two integers called seeds. The seeds can be initialized by the user; the initial values of the first must lie between 1 and 2,147,483,562, that of the second between 1 and 2,147,483,398. Each time a number is generated, the values of the seeds change. Three values of seeds are remembered by the generators at all times: the value with which the generator was initialized, the value at the beginning of the current block, and the value at the beginning of the next block. The seeds of any generator can be set to any of these three values at any time.

Of the 32 virtual generators, exactly one will be the current generator, i.e., that one will be used to generate values for 'lgi' and 'def'. Initially, the current generator is set to number one. The current generator may be changed by calling 'setcgn', and the number of the current generator can be obtained using 'getcgn'.


TEST EXAMPLE :

An example of the need for these capabilities is as follows. Two statistical techniques are being compared on data of different sizes. The first technique uses bootstrapping and is thought to be as accurate using less data than the second method which employs only brute force.

For the first method, a data set of size uniformly distributed between 25 and 50 will be generated. Then the data set of the specified size will be generated and alalyzed. The second method will choose a data set size between 100 and 200, generate the data and alalyze it. This process will be repeated 1000 times.

For variance reduction, we want the random numbers used in the two methods to be the same for each of the 1000 comparisons. But method two will use more random numbers than method one and without this package, synchronization might be difficult.

With the package, it is a snap. Use generator 1 to obtain the sample size for method one and generator 2 to obtain the data. Then reset the state to the beginning of the current block and do the same for the second method. This assures that the initial data for method two is that used by method one. When both have concluded, advance the block for both generators.


INTERFACE  :

A random number is obtained either as a random integer between 1 and 2,147,483,562 by using option 'lgi' (large integer) or as a random floating point number between 0 and 1 by using option 'def'.

The seed of the first generator can be set by using option 'setall'; the values of the seeds of the other 31 generators are calculated from this value.

The number of the current generator can be set by using option 'setcgn' The number of the current generator can be obtained by using option 'getcgn'.


Previous Next Contents