When a node equation contains a discrete variable which has state numbers defined, the numeric quantities which that variable supplies to the equation could be the state indexes of the variable, or those state numbers. Usually it is the state numbers that will be used, but in a few cases, it will use the state indexes, for instance if it is an argument to a function or operator that has state indexes for the other arguments.
For example, consider the equality operator (i.e. equals sign =), and a discrete variable Color, which has state numbers and state names (such as blue) defined. When Color appears in the equation, it could refer to a state index of Color, or to the number associated with that state index.
Uses state index: Color == blue Color == #1 #Color1 == #Color2
Uses state number: Color == 3.2 Color == 1 Color1 == Color2
The above is for the evaluation of equation expressions. When it comes to assigning the result of the equation to its LHS (left-hand side) variable, if the variable is discrete with state numbers defined, the same issue arises. Has the equation calculated a state index for the variable, or a state number? The purpose of the AsState function is to indicate that the result is a state index.
Continuing with the example above:
Assigns by numeric: Color() = 3 Color1 (Color2) = Color2
Assigns by index: Color() = #3 Color1 (Color2) = AsState (Color2)
Color1 (X, Y) = AsState (integer (X / Y))
You may want to verify that
Netica is doing as you expect by having it calculate a few values and
checking (for example, by using Table
→ Equation
to Table). Or you can examine the internal
representation of the equation by choosing Report
→ Horizontal
Format from the menu and then
Report →
Equation. Check for places
where Netica has inserted the function "_levels"
(maps state index →
real number), "_find0"
(maps real number →
state index of a discrete variable),
or "_discretize" (maps real
number → state
index of a continuous variable).