Operators and functions

Laura Uusitalo, May 2006
laura.uusitalo@iki.fi

Back to main page

Valid HTML 4.01 Transitional

Valid CSS!

Operators and functions in Hugin

The basic operators and functions available for composing expressions are list below.

Contents

Binary numeric operators

The following binary (infix) operators can be applied to numeric expressions.

Examples:
  • C1 + C2
  • C1 ^ 3

where C1 and C2 are numeric nodes (i.e., numbered nodes and/or interval nodes).

Unary numeric operators

An numeric expression can be negated using the unary negation operator:

Binary comparison operators

The following binary (infix) operators can be used for comparing labels (i.e., strings), numbers, and Booleans (both operands must be of the same type). Only the equality operators (i.e., = and !=) may be applied to labels and Boolean expressions. Each of the operators returns a Boolean value.

Examples:
  • C1 == C2
  • C1 > 5

where C1 and C2 are numeric nodes (i.e., numbered nodes and/or interval nodes).

Min and max functions

The following functions compute the minimum or maximum of a list of numeric expressions.

Examples:
  • min(C1, C2, 10)
  • max(min(C1, C2, 10), max(C3, C4))

where C1, ..., C4 are numeric nodes (i.e., numbered nodes and/or interval nodes).

Standard mathematical functions

The following list contains standard mathematical functions, which can be applied to a single numeric expression.

Examples:
  • log(C1)
  • abs(sin(C1))

where C1 is a numeric node (i.e., a numbered node or an interval node).

Floor and ceiling functions

The floor and ceiling functions round the result of real numeric expressions to integers.

Examples:
  • floor(C1 * C2)
  • ceil(C1 ^ 2)

where C1 and C2 are numeric nodes (i.e., numbered nodes and/or interval nodes).

Modulo function

The modulo function gives the remainder of a division of two numeric expressions. Of course, the divisor expression must be non-zero.

where x and y can be arbitrary real numbers with y != 0.

Example:
  • mod(C1, C2 ^ 2)

where C1 and C2 are numeric nodes (i.e., numbered nodes and/or interval nodes).

If-Then-Else

Conditional expression (with three arguments) can be specified:

where px must be a Boolean expression, and the second and third arguments must have the same type. If px evaluates to 'true', the value of expression tx is returned; otherwise, the value of expression fx is returned. The type of the if-expression is the type of tx and fx.

Examples:
  • if(FakeDie,Binomial(n,1/2),Binomial(n,1/6))
  • if(C1 == C2, Distribution(1, 2), Distribution(1, 3))

where FakeDie is a Boolean node, n is a numeric node, and C1 and C2 are nodes of arbitrary (but identical) type.

Logical operators

The following standard logical operators are available. They all take Boolean expressions as arguments.

The evaluation of the argument expressions of 'and' is done sequentially, and the evaluation terminates whenever an argument evaluates to 'false'. Similarly, the evaluation of the argument expressions of 'or' terminates whenever an argument evaluates to 'true'.

Example:
  • and(C1, or(C2, not(C3)))
where C1, C2 and C3 are Boolean nodes.

Continuous statistical distributions

Discrete statistical distributions