The fundamental component of any SP model is its set of random variables.  The random variables are the stochastic component of the model.  Their values are not known with certainty beforehand, however, their uncertainty can be expressed with known probability distributions.  LINGO requires each random variable to be explicitly identified.  When we identify each random variable, we must also provide the stage in the scenario tree where each variable's value is revealed.  The @SPSTGRNDV function is used for this purpose:

@SPSTGRNDV( STAGE, VARIABLE_NAME)

This function takes two arguments: the random variable's name and the integer valued stage at which the random variable's value is revealed.  Note that this function merely flags a variable as being random, and does not communicate any information regarding the actual distribution of the variable.  A distribution is associated with the random variable in the Binding random variables to distribution instances, discussed below.  Some examples follow:

Example 1:        @SPSTGRNDV( 1, DEMAND);

Flags variable DEMAND as being a random variable in stage 1.

Example 2:        @FOR( TIME_ASSET( T, A) | T #GT# 1:

@SPSTGRNDV( T - 1, RETURN( T, A)));

Flags RETURN( T, A) as being a random variable in stage T-1.  Note that by using @SPSTGRNDV in an @FOR loop, we are  able to identify multiple variables as being random.