Coninuous Univariate#

BETA Distribution#

Generates a vector of random variates from a beta distribution with probability density function, \(f (X)\), where:

\[f (X) = \frac{\Gamma(A+B)}{\Gamma(A)\Gamma(B)}X^{A-1}(1-X)^{B-1}\]

if \(0 \le X \le 1 \ and \ A, B > 0.0\), otherwise \(f (X) = 0\).

C Generate 100 values from the Beta distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    DOUBLE PRECISION A,B
    DOUBLE PRECISION 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 Beta distribution
    CALL DRANDBETA(N,A,B,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

Cauchy Distribution#

Generates a vector of random variates from a Cauchy distribution with probability density function, \(f (X)\), where:

\[f (X) = \frac{1}{\Pi B(1+(\frac{X-A}{B})^2)}\]
C Generate 100 values from the Cauchy distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    DOUBLE PRECISION A,B
    DOUBLE PRECISION 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 Cauchy distribution
    CALL DRANDCAUCHY(N,A,B,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

Chi-Squared Distribution#

Generates a vector of random variates from a χ2 distribution with probability density function, \(f (X)\), where:

\[f (X) = \frac{X^{\frac{v}{2}-1} e^{-\frac{X}{2}}}{2^{\frac{v}{2}}(\frac{v}{2}-1)!}\]

if \(X > 0\), otherwise \(f (X) = 0\). Here ν is the degrees of freedom, DF.

C Generate 100 values from the Chi-squared distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE) INTEGER DF
    DOUBLE PRECISION X(N)

C Set the seed
    SEED(1) = 1234

C Read in the distributional parameters
    READ(5,*) DF

C Initialize the STATE vector
    CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)

C Generate N variates from the Chi-squared distribution
    CALL DRANDCHISQUARED(N,DF,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

Exponential Distribution#

Generates a vector of random variates from an exponential distribution with probability density function, \(f (X)\), where:

\[f (X) = \frac{e^{\frac{-X}{A}}}{A}\]

if \(X > 0\), otherwise \(f (X) = 0\).

C Generate 100 values from the Exponential distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    DOUBLE PRECISION A
    DOUBLE PRECISION X(N)

C Set the seed
    SEED(1) = 1234

C Read in the distributional parameters
    READ(5,*) A

C Initialize the STATE vector
    CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)

C Generate N variates from the Exponential distribution
    CALL DRANDEXPONENTIAL(N,A,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

F Distribution#

Generates a vector of random variates from an F distribution, also called the Fisher’s variance ratio distribution, with probability density function, \(f (X)\), where:

\[f(X) = \frac{\left(\frac{\mu + v - 2}{2}\right)! \, X^{\left(\frac{\mu}{2} - 1\right)} \, \mu^{\frac{\mu}{2}}} {\left(\frac{\mu}{2} - 1\right)! \, \left(\frac{v}{2} - 1\right)! \, \left(1 + \frac{\mu X}{v}\right)^{\frac{\mu + v}{2}} \, v^{\frac{\mu}{2}}}\]

if \(X > 0\), otherwise \(f (X) = 0\). Here μ is the first degrees of freedom, (DF1) and ν is the second degrees of freedom, (DF2).

C Generate 100 values from the F distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    INTEGER DF1,DF2
    DOUBLE PRECISION X(N)

C Set the seed
    SEED(1) = 1234

C Read in the distributional parameters
    READ(5,*) DF1,DF2

C Initialize the STATE vector
    CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)

C Generate N variates from the F distribution
    CALL DRANDF(N,DF1,DF2,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

Gamma Distribution#

Generates a vector of random variates from a Gamma distribution with probability density function, \(f (X)\), where:

\[f(X) = \frac{X^{A - 1} e^{- \frac{X}{B}}} {B^{A} \Gamma(A)}\]

if \(X > 0\) and \(A, B > 0.0\), otherwise \(f (X) = 0\).

C Generate 100 values from the Gamma distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    DOUBLE PRECISION A,B
    DOUBLE PRECISION 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 Gamma distribution
    CALL DRANDGAMMA(N,A,B,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

Gaussian Distribution#

Generates a vector of random variates from a Gaussian distribution with probability density function, \(f (X)\), where:

\[f(X) = \frac{e^{-\frac{(X - \mu)^2}{2\sigma^2}}} {\sigma \sqrt{2\pi}}\]

Here μ is the mean, (XMU ) and \(\sigma 2\) the variance, (VAR) of the distribution.

C Generate 100 values from the Gaussian distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    DOUBLE PRECISION XMU,VAR
    DOUBLE PRECISION X(N)

C Set the seed
    SEED(1) = 1234

C Read in the distributional parameters
    READ(5,*) XMU,VAR

C Initialize the STATE vector
    CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)

C Generate N variates from the Gaussian distribution
    CALL DRANDGAUSSIAN(N,XMU,VAR,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

Logistic Distribution#

Generates a vector of random variates from a logistic distribution with probability density function, \(f (X)\), where:

\[f(X) = \frac{e^{\frac{X - A}{B}}} {B \left(1 + e^{\frac{X - A}{B}}\right)^2}\]
C Generate 100 values from the Logistic distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    DOUBLE PRECISION A,B
    DOUBLE PRECISION X(N)

C Set the seed
    SEED(1) = 1234

C Read in the distributional parameters
    READ(5,*) XMU,VAR

C Initialize the STATE vector
    CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)

C Generate N variates from the Logistic distribution
    CALL DRANDLOGISTIC(N,A,B,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

Lognormal Distribution#

Generates a vector of random variates from a lognormal distribution with probability density function, \(f (X)\), where:

\[f(X) = \frac{e^{-\frac{(\log X - \mu)^2}{2\sigma^2}}}{X \sigma \sqrt{2\pi}}\]

if X > 0, otherwise \(f (X) = 0\). Here μ is the mean, (XMU ) and \(\sigma 2\) the variance, (VAR) of the underlying Gaussian distribution.

C Generate 100 values from the Lognormal distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    DOUBLE PRECISION XMU,VAR
    DOUBLE PRECISION X(N)

C Set the seed
    SEED(1) = 1234

C Read in the distributional parameters
    READ(5,*) XMU,VAR

C Initialize the STATE vector
    CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)

C Generate N variates from the Lognormal distribution
    CALL DRANDLOGNORMAL(N,XMU,VAR,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

Students T Distribution#

Generates a vector of random variates from a Students T distribution with probability density function, \(f (X)\), where:

\[f(X) = \frac{\left(\frac{\nu - 1}{2}\right)!} {\sqrt{\nu \pi} \left(\frac{\nu}{2}\right)! \left(1 + \frac{X^2}{\nu}\right)^{\frac{\nu + 1}{2}}}\]

Here ν is the degrees of freedom, DF.

C Generate 100 values from the Students T distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    INTEGER DF
    DOUBLE PRECISION X(N)

C Set the seed
    SEED(1) = 1234

C Read in the distributional parameters
    READ(5,*) DF

C Initialize the STATE vector
    CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)

C Generate N variates from the Students T distribution
    CALL DRANDSTUDENTST(N,DF,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

Triangular Distribution#

Generates a vector of random variates from a Triangular distribution with probability density function, \(f (X)\), where:

\[f(X) = \frac{2(X - X_{\text{MIN}})}{(X_{\text{MAX}} - X_{\text{MIN}})(X_{\text{MED}} - X_{\text{MIN}})}\]

if XMIN < X < XMED, else

\[f(X) = \frac{2(X_{\text{MAX}} - X)}{(X_{\text{MAX}} - X_{\text{MIN}})(X_{\text{MAX}} - X_{\text{MED}})}\]

if XMED < X < XMAX, otherwise \(f (X) = 0\).

C Generate 100 values from the Students Triangular distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    DOUBLE PRECISION XMIN,XMED,XMAX
    DOUBLE PRECISION X(N)

C Set the seed
    SEED(1) = 1234

C Read in the distributional parameters
    READ(5,*) XMIN,XMED,XMAX

C Initialize the STATE vector
    CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)

C Generate N variates from the Triangular distribution
    CALL DRANDTRIANGULAR(N,XMIN,XMED,XMAX,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

Uniform Distribution#

Generates a vector of random variates from a Uniform distribution with probability density function, \(f (X)\), where:

\[f (X) = \frac{1}{B-A}\]
C Generate 100 values from the Uniform distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    DOUBLE PRECISION A,B
    DOUBLE PRECISION 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 DRANDUNIFORM(N,A,B,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

VonMises Distribution#

Generates a vector of random variates from a Von Mises distribution with probability density function, \(f (X)\), where:

\[f (X) = \frac{e ^{k\ cos\ X}}{2\pi I_0(K)}\]

where X is reduced modulo \(2\pi\) so that it lies between \(\pm \pi\), and κ is the concentration parameter VK.

C Generate 100 values from the Von Mises distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    DOUBLE PRECISION VK
    DOUBLE PRECISION X(N)

C Set the seed
    SEED(1) = 1234

C Read in the distributional parameters
    READ(5,*) VK

C Initialize the STATE vector
    CALL DRANDINITIALIZE(1,1,SEED,1,STATE,LSTATE,INFO)

C Generate N variates from the Von Mises distribution
    CALL DRANDVONMISES(N,VK,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)

Weibull Distribution#

Generates a vector of random variates from a Weibull distribution with probability density function, \(f (X)\), where:

\[f(X) = \frac{A X^{A-1} e^{-(X^A / B)}}{B}\]

if X > 0, otherwise \(f (X) = 0\).

C Generate 100 values from the Weibull distribution
    INTEGER LSTATE,N
    PARAMETER (LSTATE=16,N=100)
    INTEGER I,INFO,SEED(1),STATE(LSTATE)
    DOUBLE PRECISION A,B
    DOUBLE PRECISION 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 Weibull distribution
    CALL DRANDWEIBULL(N,A,B,STATE,X,INFO)

C Print the results
    WRITE(6,*) (X(I),I=1,N)