Show 
Equation Syntax

Netica equations follow most of the usual standards for mathematical equations, and are similar to programming in Java, C or C++.  The usual mathematical operators (+, -, *, /, etc.), and the usual functions (min, abs, sin, etc.) can be used, parenthesis are used for grouping, and numeric constants are in their usual form (e.g. 3, -4.2, 5.3e-12).

Left-Hand Side:  The part of an equation to the left-hand side of the equals symbol for a deterministic node consists of the name of the node, an open parenthesis, a list of the names of the parents separated by commas, and a close parenthesis (if you have defined link names, you must use those instead of parent names).  For instance, if the equation is for node X, and the parents of X are Vel, dt and sigma, the left-hand side could be:

X (Vel, dt, sigma) = ...

Note that spaces are not required, and there may be more spaces if desired.

For probabilistic nodes (i.e. "chance nodes"), the left-hand side consists of a lower case "p", an open parenthesis, the name of the node, a vertical bar, a list of the names of the parents (or link names) separated by commas, and a close parenthesis.  If the node mentioned above had been a probabilistic node, the left hand side of its equation could be:

P (X | Vel, dt, sigma) = ...

Right-Hand Side:  The right-hand side of an equation may consist of numbers, adjustable parameters, state names, conditionals, references to the variables (i.e. parent nodes), and built-in constants, functions or operators.  The syntax is very similar to that of Java/C/C++ (comparison).

Nodes Allowed:  The only nodes which may be mentioned in an equation are: the node the equation describes, its parents, and any constant node.

Errors:  If there is a mistake in the syntax of the equation, Netica will pop up an alert box with an error message.  If necessary, move the alert box so that the equation is unobscured, and then click on the title bar of the Node Properties Dialog box.  That will cause the Node Properties to become the active window, and a flashing cursor will appear in the equation text close to where the error is located.

Comments:  Comments can be embedded in equations, and they will be ignored by Netica.  Everything between /* and */ will be interpreted as a comment, as will everything between // and the end of the line.  As many spaces or line breaks as desired may be placed between any two symbols.

All Values:  If the equation is for a probabilistic node, its right-hand side must provide a probability for all the node’s possible values (so the name of the node must appear there at least once).  For example, if node Color (with states red, orange, yellow) has parent Temp (with states low, med, high), its equation could be:

p (Color | Temp) =

Temp == high ? (Color==yellow ? 1.0 : 0.0) :

Temp == med ? (Color==orange ? 1.0 : 0.0) :

Temp == low ? (Color==orange ? 0.2 :

Color==red ? 0.8 : 0.0) : 0

 

If you use the built-in distributions (such as NormalDist), the above is automatically taken care of.  One exception to the above is if a node is boolean.  Then only the probability for the true state need be given.  For example, if node It_Falls is boolean, its equation could be:

p (It_Falls | Weight, Size) =

Weight/Size > 10 ? 0.10 :

Weight/Size > 5 ? 0.03 :

0.01

 

Examples:  Here are some examples of equations:

X (Vel, dt, X0) = X0 + Vel * dt

 

p (X | Vel, dt, spread) = NormalDist (X, Vel*dt, spread)

 

Color (Taste) =

Taste==sour? blue: Taste==sweet? red:

Taste==salty? green: gray

 

p (Color | Taste) =

(Color==red && Taste==sweet) ? 0.7 : 0.1

More Examples

 

Home > Equations > Syntax