LINGO allows both independent and joint parametric probability distributions, as well as continuous and discrete distributions.  The functions used to declare these distributions are of the form @SPDIST<TYPE>, where <TYPE> represents the type of distribution being declared.  In addition, there are the @SPSAMPSIZE and @SPCORR<METHOD> functions for, respectively, setting sample sizes and inducing correlations, where <METHOD> refers to the particular method used to induce correlation.

@SPDIST<TYPE>( PARAM_1[, ... , PARAM_N], RANDOM_VAR)

This function is used to apply both continuous and discrete parametric probability distributions to random variables. At least one distribution parameter argument will always be required.  Additional parameters may be required depending on the particular distribution.  Parameter values are always numeric.  The random variable must be declared beforehand via @SPSTGRNDV.

Below is a list of supported continuous distributions.

Distribution

Syntax

Parameter(s)

Beta

@SPDISTBETA( A, B, RNDVAR)

A = alpha > 0

B = beta > 0

Cauchy

@SPDISTCACY( LOC, SCALE, RNDVAR)

LOC = location

SCALE = scale > 0

Chi-Square

@SPDISTCHIS( DF, RNDVAR)

DF = degrees of freedom = a positive integer

Exponential

@SPDISTEXPO( LAMDA, RNDVAR)

LAMDA = rate parameter > 0

F

@SPDISTFDST( DF1, DF2, RNDVAR)

DF1 = degrees of freedom 1 = a positive integer

DF2 = degrees of freedom 2 = a positive integer

Gamma

@SPDISTGAMM( SCALE, SHAPE, RNDVAR)

SCALE = scale parameter > 0

SHAPE = shape parameter > 0

Gumbel

@SPDISTGMBL( LOC, SCALE, RNDVAR)

LOC = location

SCALE = scale > 0

Laplace

@SPDISTLAPL( LOC, SCALE, RNDVAR)

LOC = location

SCALE = scale > 0

Logistic

@SPDISTLGST( LOC, SCALE, RNDVAR)

LOC = location

SCALE = scale > 0

Lognormal

@SPDISTLOGN( MU, SIGMA, RNDVAR)

MU = mu parameter

SIGMA = sigma parameter > 0

Normal

@SPDISTNORM( MU, SIGMA, RNDVAR)

MU = mean

SIGMA = standard deviation > 0

Pareto

@SPDISTPRTO( SCALE, SHAPE, RNDVAR)

SCALE = scale parameter > 0

SHAPE = shape parameter > 0

Student's t

@SPDISTSTUT(  DF, RNDVAR)

DF = degrees of freedom = a positive integer

Symettric Stable

@SPDISTSMST( A, RNDVAR)

A = alpha [.02,2.0]

Triangular

@SPDISTTRIA( L, U, M, RNDVAR)

L = lowest point

H = high point

M = modal point

Uniform

@SPDISTUNIF( L, U, RNDVAR)

L = lower point

U = upper point

Weibull

@SPDISTWEIB( SCALE, SHAPE, RNDVAR)

SCALE = scale parameter > 0

SHAPE = shape parameter > 0

Example:        @SPDISTNORM( 82.3, 18.1, RND_TEMP);

In this example, we apply a normal distribution to the random variable RND_TEMP, with a mean of 82.3 inches and a standard deviation of 18.1.

Here's the list of  discrete distributions currently supported:

Distribution

Syntax

Parameter(s)

Beta Binomial

@SPDISTBTBN( N, A, B, RNDVAR)

N = trials = a positive integer 0

A = alpha > 0

B = beta > 0

Binomial

@SPDISTBINO( N, P, RNDVAR)

N = trials = a positive integer 1

P = probability of success, 0 P 1

Geometric

@SPDISTGEOM( P, RNDVAR)

P = probability of success, 0 < P 1

Hypergeometric

@SPDISTHYPG( N, D, K, RNDVAR)

N = population = a positive integer 1

D = number defective {0,1,...,N}

K = sample size {1,2,...,N}

Logarithmic

@SPDISTLOGR( P, RNDVAR)

P = P-factor, 0 < P < 1

Negative Binomial

@SPDISTNEGB( R, P, RNDVAR)

R = R-factor > 0

P = probability of success, 0 < P < 1

Poisson

@SPDISTPOIS( LAMDA, RNDVAR)

LAMDA = arrival rate > 0

Example:        @SPDISTPOIS( 33, CUSTOMERS);

In this example, we apply a Poisson distribution with an arrival rate of 33 to the random variable CUSTOMERS.

@SPSAMPSIZE( STAGE, SAMPLE_SIZE)

This function is used to set the sample size for probability distributions by stage.  Most instances of the parametric distributions listed in this section have a large, if not an infinite, number of outcomes.  Trying to incorporate all possible outcomes into the model would be impossible,  therefore, LINGO must sample from the parametric distributions.  If a specific sample size is not set using @SPSAMPSIZE, then LINGO defaults to a sample size equal to the Default Sample Size/Stage parameter, which is typically set to 2.  However, in some models you may wish to have different sample sizes across stages, typically having larger samples in the more critical early stages, and less sampling in the latter stages. @SPSAMPSIZE can enforce this type of sampling strategy.

Example 1:        @SPSAMPSIZE( 1, 8);

Here we set the sample size to 8 outcomes in stage 1.

Example 2:        @FOR( PERIODS( P) | P #GT# @INDEX( P0):

@SPSAMPSIZE( P - 1, SAMP_SZ( P))

 );

In this example, we set the sample size equal to SAMP_SZ( P) in periods 1 through N-1.  Note that by adding the conditional expression P #GT# @INDEX( P0) to the @FOR loop, the loop starts with P0=2, and we avoid setting the sample size in stage 0.  We do this because stage 0 never contains random variables.  Random variables first occur in stage 1, with stage 0 being reserved for the initial decision variables.  In this example, we have also not assigned a sample size to the final stage, because we either want the final stage to use the default sample size, or the final stage does not have random variables.

@SPCORR<METHOD>( RANDOM_VAR_1, RANDOM_VAR_2, RHO)

This function causes the sampling code to induce correlations between two random variables.  The ordering of the two variables is not significant. The correlation coefficient, RHO, must lie in the interval [-1,1].  You must also choose between three methods available for inducing correlations: Pearson, Kendall or Spearman.  Only one correlation method is allowed per model.  Some examples follow:

Example 1:        @SPCORRPEARSON( X, Y, .9);

Here we set the correlation between random variables X and Y to be .9 using the Pearson method.

Example 2:        @FOR( CORR_RNDM_PLANTS( P1, P2):

@SPCORRKENDALL( CAPACITY( P1), CAPACITY( P2), RHO( P1, P2));

);

In this example, we have a derived, two-dimensional set. CORR_RNDM_PLANTS, that contains the pairs of electrical plants whose output capacities are correlated.  We loop over these pairs, setting each pair's correlation to RHO( P1, P2) using the Kendall method.