Difference between revisions of "DetermTable"

Line 30: Line 30:
  
 
The expression syntax for a [[DetermTable]] is identical to that of [[Table]].  Thus, one quick and easy way to convert an existing [[Table]] is to view the definition in expression view and change the first word from [[Table]] to [[DetermTable]].
 
The expression syntax for a [[DetermTable]] is identical to that of [[Table]].  Thus, one quick and easy way to convert an existing [[Table]] is to view the definition in expression view and change the first word from [[Table]] to [[DetermTable]].
 +
''Before:'' Table(Scenario)('Rosy','Rosy','Mild','Bad')
 +
''After:'' DetermTable(Scenario)('Rosy','Rosy','Mild','Bad')
  
 
If you are converting a huge table (where the expression view contains more than 32000 characters), then Analytica will not allow you to edit the definition in expression view, so the above technique cannot be used.   
 
If you are converting a huge table (where the expression view contains more than 32000 characters), then Analytica will not allow you to edit the definition in expression view, so the above technique cannot be used.   

Revision as of 17:39, 11 September 2008


A DetermTable provides an input view like that of an edit table, allowing you to specify values or expressions in each cell for all index combinations; however, unlike a table, the evaluation of a determtable conditionally returns only selected values from the table. It is called a determtable because it acts as a deterministic function of one or more discrete-valued variables. You can conceptualize a determtable as a multi-dimensional generalization of a select-case statement found in many programming languages, or as a value that varies with the path down a decision tree.

To use a DetermTable, one or more of its table indexes should be dsicrete variables. These discrete variables must contain a domain attribute with a list of possible values. The domain can be either a List, List of Labels, or Index domain (in the case of an index domain, the possible values are taken from an index elsewhere in the model). These domain values serve as the index for the DetermTable's input view.

The value of the discrete variable specifies which slice of the DetermTable should be selected in the result. Only that row is returned. This can be contrasted to a normal edit table, in which the entire table (based on the discrete variable's domain) would be returned.

Example

Here Scenario is a discrete variable. Its domain specifies the possible values, while its actual value is just one of those possible values:

Scenario object window.png

Because of the discrete domain, scenario can serve as both an index and value (its IndexValue is [1,2,3,4], while its value is 3). We can use it as an index for a DetermTable:

DetermTable example.png

When viewed in input mode, the DetermTable Economic Outlook appears as above, and you can change the values in each cell. When evaluated, only the row selected by Scenario is returned:

DetermTable result.png

Creating a DetermTable

Converting an existing Table to a DetermTable

The expression syntax for a DetermTable is identical to that of Table. Thus, one quick and easy way to convert an existing Table is to view the definition in expression view and change the first word from Table to DetermTable.

Before: Table(Scenario)('Rosy','Rosy','Mild','Bad')
After: DetermTable(Scenario)('Rosy','Rosy','Mild','Bad')

If you are converting a huge table (where the expression view contains more than 32000 characters), then Analytica will not allow you to edit the definition in expression view, so the above technique cannot be used.

A second method is to change the definition using the Object Finder. From the object window or attribute pane of the node currently defined as an edit table, view the definition attribute. Using the definition type pulldown, select "Other...". You'll be asked if you want to replace the current definition, which you do so press OK. The object finder appears, from you you should locate and select DetermTable from within the Array library. Press OK and your Table is converted to a DetermTable.

Uses

Discrete Probabilistic Models

Selective Parametric Analysis

Subscript Equivalence

The functionality of a DetermTable can be implemented using two variables, the first containing a normal edit table, and the second containing a subscript function to select out the indicated row.

For example, to simulate the Economic Outlook DetermTable in the earlier example, we could use instead a normal Table with the values:

Normal table example.png

We could then define Economic Outlook as:

Economic_outlook_table[Scenario=Scenario]

At first blush you might think the subscript operation is not doing anything. It looks a lot like re-indexing an array by replacing index Scenario with index Scenario. However, that is not the case. Remember that the discrete variable Scenario can serve as either an index or a value, depending on context. In a subscript operation, A[I=x] , I is interpreted as an index, and x as a value. Hence, A[Scenario=Scenario] is saying to select the slice along the Scenario index specified by the value of Scenario. That is exactly what a DetermTable does.

Using a DetermTable has the convenience of saving you an extra node, since a separate node to perform the subscripting is not necessary. Perhaps more importantly, it is very easy to convert an existing table into a DetermTable without having to introduce a new node between the table and all its existing children.

If you ever need access to the full input table from your expressions (rather than just to the selected value), then you need to use a normal table with a subscript operator as just shown here.

See Also

Comments


You are not allowed to post comments.