Self-Indexed Arrays

In Analytica, an object may have separate values for each of the following:

  • Mid value
  • Sample value
  • Index value

When you use an identifier in an expression, Analytica knows which type of value to retrieve or compute based on context -- a combination of where the identifier is used in the syntax, and the current evaluation mode.

Syntactically, Analytica expressions appear in value contexts and index contexts. For example, in the expression

Sum(A,I)

the identifier A appears in a value context, and I appears in an index context. From this context, Analytica knows whether it is accessing the computed value, or the index value.

In a value context, the evaluation mode determines whether the Mid value or Sample value is being computed or retrieved. See Evaluation Modes for more details.

Many objects in an Analytica model, if not most objects, do not have index values different from their main (mid/sample) values. However, there are several ways in which a variable might end up with an index value different from its main value:

  • Self-Index tables: If you select "Self" as an index for a table, the row-headers become the index value, the body cell expressions determine the main value.
  • List definition containing identifiers or expressions: If you define a variable or index as a list of identifiers, for example [I,J,K], then the index value is a list of varTerms, while the evaluated value is a 3-D array indexed by I, J, and K.
  • List-domain: When a variable contains a list-domain or index-domain, its computed value may be different from its domain. In this case, the domain serves as the index value. Domains as indexes often serve as indexes for DetermTables and Probability Tables.


Occassions may arise when you wish to access a different value of an object than the one implied by the expression context. Each type value can be accessed using:

  • IndexValue(X) : returns the index value of X
  • Sample(X) : Evaluates and returns the sample value of X
  • Mid(X) : Evaluates and returns the mid value of X
  • domain of X : Returns the domain of X.

Note About Future Changes

Currently, when an object has a list-valued or index-valued domain, that domain becomes the variable's index value. This is a functionality we expect to change in future Analytica releases, so we encourage you to avoid relying too heavily on this.

We will ensure that in the future, ProbTables and DetermTables that are indexed by domains continue to function as such.

However, we intend for the index value to be determined ultimately by the definition of the variable, and possibly different from the [[domain]. In the future, (domain of X) can serve as an index, and in the future may be different from IndexValue(X). A multi-select Choice list will be a future example.

This future change is mentioned here, now, since it could impact backward compatibility later.

Comments


You are not allowed to post comments.