Discrete Univariate#
Binomial Distribution#
Generates a vector of random variates from a Binomial distribution with probability, \(f (X)\), defined by:
C Generate 100 values from the Binomial distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
INTEGER M
DOUBLE PRECISION P
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) M,P
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Generate N variates from the Binomial distribution
CALL DRANDBINOMIAL(N,M,P,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)
Geometric Distribution#
Generates a vector of random variates from a Geometric distribution with probability, \(f (X)\), defined by:
C Generate 100 values from the Geometric distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
DOUBLE PRECISION P
INTEGER X(N)
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) P
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Generate N variates from the Geometric distribution
CALL DRANDGEOMETRIC(N,P,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)
Hypergeometric Distribution#
Generates a vector of random variates from a Hypergeometric distribution with probability, \(f (X)\), defined by:
if X = max(0, m + s – p),…, min(l, m), otherwise f (X) = 0. Here p is the size of the population, (NP), s is the size of the sample taken from the population, (NS) and m is the number of labeled, or specified, items in the population, (M ).
C Generate 100 values from the Hypergeometric distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
INTEGER NP,NS,M
INTEGER X(N)
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) NP,NS,M
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Generate N variates from the Hypergeometric distribution
CALL DRANDHYPERGEOMETRIC(N,NP,NS,M,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)
Negative Binomial Distribution#
Generates a vector of random variates from a Negative Binomial distribution with probability \(f (X)\) defined by:
C Generate 100 values from the Negative Binomial distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
INTEGER M
DOUBLE PRECISION P
INTEGER X(N)
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) M,P
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Generate N variates from the Negative Binomial distribution
CALL DRANDNEGATIVEBINOMIAL(N,M,P,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)
Poisson Distribution#
Generates a vector of random variates from a Poisson distribution with probability \(f (X)\) defined by:
where λ is the mean of the distribution, LAMBDA.
C Generate 100 values from the Poisson distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
DOUBLE PRECISION LAMBDA
INTEGER X(N)
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) LAMBDA
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Generate N variates from the Poisson distribution
CALL DRANDPOISSON(N,LAMBDA,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)
Discrete Uniform Distribution#
Generates a vector of random variates from a Uniform distribution with probability \(f (X)\) defined by:
C Generate 100 values from the Uniform distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
INTEGER A,B
INTEGER X(N)
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) A,B
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Generate N variates from the Uniform distribution
CALL DRANDDISCRETEUNIFORM(N,A,B,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)
General Discrete Distribution#
Takes a reference vector initialized via one of DRANDBINOMIALREFERENCE, DRANDGEOMETRICREFERENCE, DRANDHYPERGEOMETRICREFERENCE, DRANDNEGATIVEBINOMIALREFERENCE, DRANDPOISSONREFERENCE, and generates a vector of random variates from it.
C Generate 100 values from the Binomial distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
INTEGER M
DOUBLE PRECISION P
INTEGER X(N)
INTEGER LREF
DOUBLE PRECISION REF(1000)
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) M,P
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Initialize the reference vector
LREF = 1000
CALL DRANDBINOMIALREFERENCE(M,P,REF,LREF,INFO)
C Generate N variates from the Binomial distribution
CALL DRANDGENERALDISCRETE(N,REF,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)
Binomial Reference#
Initializes a reference vector for use with DRANDGENERALDISCRETE. Reference vector is for a Binomial distribution with probability, \(f (X)\), defined by:
C Generate 100 values from the Binomial distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
INTEGER M
DOUBLE PRECISION P
INTEGER X(N)
INTEGER LREF
DOUBLE PRECISION REF(1000)
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) M,P
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Initialize the reference vector
LREF = 1000
CALL DRANDBINOMIALREFERENCE(M,P,REF,LREF,INFO)
C Generate N variates from the Binomial distribution
CALL DRANDGENERALDISCRETE(N,REF,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)
Geometric Reference#
Initializes a reference vector for use with DRANDGENERALDISCRETE. Reference vector is for a Geometric distribution with probability, \(f (X)\), defined by:
C Generate 100 values from the Geometric distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
DOUBLE PRECISION P
INTEGER X(N)
INTEGER LREF
DOUBLE PRECISION REF(1000)
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) P
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Initialize the reference vector
LREF = 1000
CALL DRANDGEOMETRICREFERENCE(P,REF,LREF,INFO)
C Generate N variates from the Geometric distribution
CALL DRANDGENERALDISCRETE(N,REF,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)
Hypergeometric Reference#
Initializes a reference vector for use with DRANDGENERALDISCRETE. Reference vector is for a Hypergeometric distribution with probability, \(f (X)\), defined by:
if X = max(0, m + s – p),…, min(l, m), otherwise f (X) = 0. Here p is the size of the population, (NP), s is the size of the sample taken from the population, (NS) and m is the number of labeled, or specified, items in the population, (M ).
C Generate 100 values from the Hypergeometric distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
INTEGER NP, NS,M
INTEGER X(N)
INTEGER LREF
DOUBLE PRECISION REF(1000)
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) NP, NS,M
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Initialize the reference vector
LREF = 1000
CALL DRANDHYPERGEOMETRICREFERENCE(NP, NS,M,REF,LREF,INFO)
C Generate N variates from the Hypergeometric distribution
CALL DRANDGENERALDISCRETE(N,REF,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)
Negative Binomial Reference#
Initializes a reference vector for use with DRANDGENERALDISCRETE. Reference vector is for a Negative Binomial distribution with probability \(f (X)\), defined by:
C Generate 100 values from the Hypergeometric distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
INTEGER M
DOUBLE PRECISION P
INTEGER X(N)
INTEGER LREF
DOUBLE PRECISION REF(1000)
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) M,P
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Initialize the reference vector
LREF = 1000
CALL DRANDNEGATIVEBINOMIALREFERENCE(M,P,REF,LREF,INFO)
C Generate N variates from the Hypergeometric distribution
CALL DRANDGENERALDISCRETE(N,REF,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)
Poisson Reference#
Initializes a reference vector for use with DRANDGENERALDISCRETE. Reference vector is for a Poisson distribution with probability \(f (X)\) defined by:
where λ is the mean of the distribution, LAMBDA.
C Generate 100 values from the Poisson distribution
INTEGER LSTATE,N
PARAMETER (LSTATE=16,N=100)
INTEGER I,INFO,SEED(1),STATE(LSTATE)
DOUBLE PRECISION LAMBDA
INTEGER X(N)
INTEGER LREF
DOUBLE PRECISION REF(1000)
C Set the seed
SEED(1) = 1234
C Read in the distributional parameters
READ(5,*) LAMBDA
C Initialize the STATE vector
CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)
C Initialize the reference vector
LREF = 1000
CALL DRANDPOISSONREFERENCE(LAMBDA,REF,LREF,INFO)
C Generate N variates from the Poisson distribution
CALL DRANDGENERALDISCRETE(N,REF,STATE,X,INFO)
C Print the results
WRITE(6,*) (X(I),I=1,N)