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 :
- P,Q,X,Y,A,B
: five real vectors of the same size.
- P,Q (Q=1-P)
: The integral from 0 to X of the beta distribution (Input range: [0, 1].)
- Q
: 1-P
- X,Y (Y=1-X)
: Upper limit of integration of beta density (Input range: [0,1],
Search range: [0,1])
A,B
: The two parameters of the beta density (input range: (0,
+infinity), Search range: [1D-300,1D300] )
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 :
- P,Q,S,Xn,Pr,Ompr
: six real vectors of the same size.
- P,Q (Q=1-P)
: The cumulation from 0 to S of the binomial distribution.
(Probablility of S or fewer successes in XN trials each
with probability of success PR.) Input range: [0,1].
- S
: The number of successes observed.
Input range: [0, XN]
Search range: [0, XN]
- Xn
: The number of binomial trials.
Input range: (0, +infinity).
Search range: [1E-300, 1E300]
- Pr,Ompr (Ompr=1-Pr)
: The probability of success in each binomial trial.
Input range: [0,1].
Search range: [0,1]
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 :
- P,Q,Xn,Df
: four real vectors of the same size.
- P,Q (Q=1-P)
: The integral from 0 to X of the chi-square
distribution.
Input range: [0, 1].
- X
: Upper limit of integration of the non-central
chi-square distribution.
Input range: [0, +infinity).
Search range: [0,1E300]
- Df
: Degrees of freedom of the chi-square distribution.
Input range: (0, +infinity).
Search range: [ 1E-300, 1E300]
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 :
- P,Q,X,Df,Pnonc
: five real vectors of the same size.
- P,Q (Q=1-P)
: The integral from 0 to X of the non-central chi-square
distribution.
Input range: [0, 1-1E-16).
- X
: Upper limit of integration of the non-central chi-square distribution.
Input range: [0, +infinity).
Search range: [0,1E300]
- Df
: Degrees of freedom of the non-central
chi-square distribution.
Input range: (0, +infinity).
Search range: [ 1E-300, 1E300]
- Pnonc
: Non-centrality parameter of the non-central
chi-square distribution.
Input range: [0, +infinity).
Search range: [0,1E4]
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 :
- P,Q,F,Dfn,Dfd
: five real vectors of the same size.
- P,Q (Q=1-P)
: The integral from 0 to F of the f-density.
Input range: [0,1].
- F
: Upper limit of integration of the f-density.
Input range: [0, +infinity).
Search range: [0,1E300]
- Dfn
: Degrees of freedom of the numerator sum of squares.
Input range: (0, +infinity).
Search range: [ 1E-300, 1E300]
- Dfd
: Degrees of freedom of the denominator sum of squares.
Input range: (0, +infinity).
Search range: [ 1E-300, 1E300]
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 :
- P,Q,F,Dfn,Dfd,Pnonc
: six real vectors of the same size.
- P,Q (Q=1-P)
The integral from 0 to F of the non-central f-density.
Input range: [0,1-1E-16).
- F
: Upper limit of integration of the non-central f-density.
Input range: [0, +infinity).
Search range: [0,1E300]
- Dfn
: Degrees of freedom of the numerator sum of squares.
Input range: (0, +infinity).
Search range: [ 1E-300, 1E300]
- Dfd
: Degrees of freedom of the denominator sum of squares.
Must be in range: (0, +infinity).
Input range: (0, +infinity).
Search range: [ 1E-300, 1E300]
- Pnonc
: The non-centrality parameter
Input range: [0,infinity)
Search range: [0,1E4]
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 :
- P,Q,X,Shape,Scale
: five real vectors of the same size.
- P,Q (Q=1-P)
The integral from 0 to X of the gamma density.
Input range: [0,1].
- X
: The upper limit of integration of the gamma density.
Input range: [0, +infinity).
Search range: [0,1E300]
- Shape
: The shape parameter of the gamma density.
Input range: (0, +infinity).
Search range: [1E-300,1E300]
- Scale
: The scale parameter of the gamma density.
Input range: (0, +infinity).
Search range: (1E-300,1E300]
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 :
- P,Q,S,Xn,Pr,Ompr
: six real vectors of the same size.
- P,Q (Q=1-P)
: The cumulation from 0 to S of the negative
binomial distribution.
Input range: [0,1].
- S
: The upper limit of cumulation of the binomial distribution.
There are F or fewer failures before the XNth success.
Input range: [0, +infinity).
Search range: [0, 1E300]
- Xn
: The number of successes.
Input range: [0, +infinity).
Search range: [0, 1E300]
- Pr
: The probability of success in each binomial trial.
Input range: [0,1].
Search range: [0,1].
- Ompr
: 1-PR
Input range: [0,1].
Search range: [0,1]
PR + OMPR = 1.0
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 :
- P,Q,X,Mean,Std
: six real vectors of the same size.
- P,Q (Q=1-P)
: The integral from -infinity to X of the normal density.
Input range: (0,1].
- X
:Upper limit of integration of the normal-density.
Input range: ( -infinity, +infinity)
- Mean
: The mean of the normal density.
Input range: (-infinity, +infinity)
- Sd
: Standard Deviation of the normal density.
Input range: (0, +infinity).
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 :
- P,Q,S,Xlam
: four real vectors of the same size.
- P,Q (Q=1-P)
: The cumulation from 0 to S of the poisson density.
Input range: [0,1].
- S
:Upper limit of cumulation of the Poisson.
Input range: [0, +infinity).
Search range: [0,1E300]
- Xlam
: Mean of the Poisson distribution.
Input range: [0, +infinity).
Search range: [0,1E300]
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 :
- P,Q,T,Df
: six real vectors of the same size.
- P,Q (Q=1-P)
: The integral from -infinity to t of the t-density. Input range: (0,1].
- T
: Upper limit of integration of the t-density.
Input range: ( -infinity, +infinity).
Search range: [ -1E150, 1E150 ]
- DF:
Degrees of freedom of the t-distribution.
Input range: (0 , +infinity).
Search range: [1e-300, 1E10]
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 :
- grand('advnst',K)
: Advances the state of the current generator by 2^K values and
resets the initial seed to that value.
- Y=grand(m,n,'bet',A,B), Y=grand(x,'bet',A,B)
: Returns random deviates from the beta distribution with
parameters A and B. The density of the beta is
x^(a-1) * (1-x)^(b-1) / B(a,b) for 0 < x < 1 Method: R. C. H. Cheng
Generating Beta Variables with Nonintegral Shape Parameters
Communications of the ACM, 21:317-322 (1978)
(Algorithms BB and BC)
- Y=grand(m,n,'bin',N,P), Y=grand(x,'bin',N,P)
: Generates random deviates from a binomial distribution whose number of
trials is N and whose probability of an event in each trial is P.
N is the number of trials in the binomial distribution
from which a random deviate is to be generated.
P is the probability of an event in each trial of the
binomial distribution from which a random deviate is to be generated.
(0.0 <= P <= 1.0)
Method: This is algorithm BTPE from: Kachitvichyanukul, V. and Schmeiser, B. W. Binomial Random Variate Generation. Communications of the ACM, 31, 2
(February, 1988) 216.
- Y=grand(m,n,'chi',Df), Y=grand(x,'chi',Df)
: Generates random deviates from the distribution of a chisquare
with DF degrees of freedom random variable.
Uses relation between chisquare and gamma.
- Y=grand(m,n,'def'), Y=grand(x,'def')
:
Returns random floating point numbers from a uniform distribution
over 0 - 1 (endpoints of this interval are not returned) using the
current generator
- Y=grand(m,n,'exp',Av), Y=grand(x,'exp',Av)
: Generates random deviates from an exponential
distribution with mean AV. For details see:
Ahrens, J.H. and Dieter, U.
Computer Methods for Sampling From the
Exponential and Normal Distributions.
Comm. ACM, 15,10 (Oct. 1972), 873 - 882.
- Y=grand(m,n,'f',Dfn,Dfd), Y=grand(x,'f',Dfn,Dfd)
: Generates random deviates from the F (variance ratio)
distribution with DFN degrees of freedom in the numerator
and DFD degrees of freedom in the denominator.
Method: Directly generates ratio of chisquare variates
- Y=grand(m,n,'gam',Shape,Scale), Y=grand(x,'gam',Shape,Scale)
: Generates random deviates from the gamma distribution whose
density is (Scale**Shape)/Gamma(Shape) * X**(Shape-1) * Exp(-Scale*X)
For details see:
1
- (Case R >= 1.0)
: Ahrens, J.H. and Dieter, U.
Generating Gamma Variates by a
Modified Rejection Technique.
Comm. ACM, 25,1 (Jan. 1982), 47 - 54.
Algorithm GD
- (Case 0.0 < R < 1.0)
: Ahrens, J.H. and Dieter, U.
Computer Methods for Sampling from Gamma,
Beta, Poisson and Binomial Distributions.
Computing, 12 (1974), 223-246/
Adapted algorithm GS.
0
- G=grand('getcgn')
: Returns in G the number of the current random number generator (1..32)
- Sd=grand('getsd')
: Returns the value of two integer seeds of the current generator
Sd=[sd1,sd2]
- grand('initgn',I)
: Reinitializes the state of the current generator
1
- I = -1
: sets the state to its initial seed
- I = 0
: sets the state to its last (previous) seed
- I = 1
: sets the state to a new seed 2^w values from its last seed
0
- Y=grand(m,n,'lgi'),Y=grand(x,'lgi')
: Returns random integers following a uniform distribution over
(1, 2147483562) using the current generator.
- Y=grand(M,'mn',Mean,Cov)
:Generate M Multivariate Normal random deviates
Mean must be a Nx1 matrix and Cov a NxN positive definite matrix
Y is a NxM matrix
- Y=grand(n,'markov',P,x0)
Generates n successive states of a Markov chain described
by the transition matrix P. Initial state is given by x0
- Y=grand(M,'mul',N,P)
Generate M observation from the Multinomial distribution.
N is the Number of events that will be classified into one of
the categories 1..NCAT
P is the vector of probabilities. P(i) is the probability that
an event will be classified into category i. Thus, P(i)
must be [0,1]. P(i) is of size NCAT-1
( P(NCAT) is 1.0 minus the sum of the first NCAT-1 P(i).
Y(:,i) is an observation from multinomial distribution. All Y(:,i)
will be nonnegative and their sum will be N. Y is of size NcatxM
Algorithm from page 559 of Devroye, Luc. Non-Uniform Random Variate
Generation. Springer-Verlag, New York, 1986.
- Y=grand(m,n,'nbn',N,P),Y=grand(x,'nbn',N,P)
: Generates random deviates from a negative binomial
distribution.
N is the required number of events (N > 0). P is The probability of an event during a Bernoulli trial (0.0 < P < 1.0).
Method: Algorithm from page 480 of Devroye, Luc. Non-Uniform Random Variate Generation. Springer-Verlag, New York, 1986.
- Y=grand(m,n,'nch',Df,Xnon), Y=grand(x,'nch',Df,Xnon)
: Generates random deviates from the distribution of a noncentral
chisquare with DF degrees of freedom and noncentrality parameter XNONC.
DF is he degrees of freedom of the chisquare (Must be >= 1.0)
XNON the Noncentrality parameter of the chisquare (Must be >= 0.0)
Uses fact that noncentral chisquare is the sum of a chisquare
deviate with DF-1 degrees of freedom plus the square of a normal
deviate with mean XNONand standard deviation 1.
- Y=grand(m,n,'nf',Dfn,Dfd,Xnon), Y=grand(x,'nf',Dfn,Dfd,Xnon)
: Generates random deviates from the noncentral F (variance ratio)
distribution with DFN degrees of freedom in the numerator, and DFD
degrees of freedom in the denominator, and noncentrality parameter XNONC.
DFN is the numerator degrees of freedom (Must be >= 1.0)
DFD is the Denominator degrees of freedom (Must be positive)
XNON is the Noncentrality parameter (Must be nonnegative)
Method: Directly generates ratio of noncentral numerator chisquare variate
to central denominator chisquare variate.
- Y=grand(m,n,'nor',Av,Sd), Y=grand(x,'nor',Av,Sd)
: Generates random deviates from a normal distribution
with mean, AV, and standard deviation, SD.
AV is the mean of the normal distribution.
SD is the standard deviation of the normal distribution.
For details see:
Ahrens, J.H. and Dieter, U. Extensions of Forsythe's Method for Random
Sampling from the Normal Distribution. Math. Comput., 27,124
(Oct. 1973), 927 - 937.
- Sd=grand('phr2sd','string')
: Uses a phrase (character string) to generate two seeds for the RGN
random number generator. Sd is an integer vector of size 2 Sd=[Sd1,Sd2]
- Y=grand(m,n,'poi',mu), Y=grand(x,'poi',mu)
: Generates random deviates from a Poisson distribution with mean MU.
MU is the mean of the Poisson distribution from which random deviates are
to be generated (MU >= 0.0).
For details see: Ahrens, J.H. and Dieter, U.
Computer Generation of Poisson Deviates
From Modified Normal Distributions.
ACM Trans. Math. Software, 8, 2
(June 1982),163-179
- Mat=grand(M,'prm',vect)
: Generate M random permutation of column vector vect. Mat is of
size (size(vect)xM)
- grand('setall',ISEED1,ISEED2)
:
Sets the initial seed of generator 1 to ISEED1 and ISEED2. The
initial seeds of the other generators are set accordingly, and
all generators states are set to these seeds.
- grand('setcgn',G)
: Sets the current generator to G. All references to a generator
are to the current generator.
- grand('setsd',ISEED1,ISEED2)
: Resets the initial seed and state of generator g to ISEED1 and
ISEED2. The seeds and states of the other generators remain
unchanged.
- Y=grand(m,n,'uin',Low,High), Y=grand(x,'uin',Low,High)
: Generates integers uniformly distributed between LOW and HIGH.
Low is the low bound (inclusive) on integer value to be generated.
High is the high bound (inclusive) on integer value to be generated.
If (HIGH-LOW) > 2,147,483,561 prints error message
- Y=grand(m,n,'unf',Low,High),Y=grand(x,'unf',Low,High)
: Generates reals uniformly distributed between LOW and HIGH.
Low is the low bound (exclusive) on real value to be generated
High is the high bound (exclusive) on real value to be generated
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'.