Operators and functions in Hugin
The basic operators and functions available for composing expressions are list below.
Contents
- Binary numeric operators
- Unary numeric operators
- Binary comparison operators
- Min and max functions
- Standard mathematical functions
- Floor and ceiling functions
- Modulo function
- If-Then-Else
- Logical operators
- Continuous statistical distributions
- Discrete statistical distributions
Binary numeric operators
The following binary (infix) operators can be applied to numeric expressions.
- + (addition)
- - (subtraction)
- * (multiplication)
- / (division)
- ^ (power)
- 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:
- - (negation)
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.
- = (equals)
- == (equals)
- != (not equals)
- <> (not equals)
- < (less than)
- > (greater than)
- <= (less than or equals)
- >= (greater than or equals)
- 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.
- min(x1, x2, ..., xn) returns the minimum of the argument expressions.
- max(x1, x2, ..., xn) returns the maximum of the argument expressions.
- 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.
- log(x) returns the natural (i.e., base e) logarithm to x.
- log2(x) returns the base 2 logarithm to x.
- log10(x) returns the base 10 logarithm to x.
- exp(x) returns the exponential to x (i.e., e^x).
- sin(x) returns the sine of x.
- cos(x) returns the cosine of x.
- tan(x) returns the tangent of x.
- sinh(x) returns the hyperbolic sine of x.
- cosh(x) returns the hyperbolic cosine of x.
- tanh(x) returns the hyperbolic tangent of x.
- sqrt(x) returns square root of x.
- abs(x) returns the absolute value of x.
- 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.
- floor(x) returns the greatest integer less than or equal to x.
- ceil(x) returns the smallest integer greater than or equal to x.
- 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.
- mod(x,y) returns x - y * floor(x / y)
where x and y can be arbitrary real numbers with y != 0.
- 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:
- if(px, tx, fx)
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.
- 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.
- and(x1, x2, ..., xn) returns 'true' if all argument expressions evaluate to 'true'.
- or(x1, x2, ..., xn) returns 'true' if at least one of the argument expressions evaluate to 'true'.
- not(x) returns 'true' if x evaluates to 'false'; otherwise, returns 'false'.
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'.
- and(C1, or(C2, not(C3)))
Continuous statistical distributions
- Normal
- Beta
- Gamma
- Exponential
- Weibull
- Uniform
Discrete statistical distributions
- Binomial
- Poisson
- Negative Binomial
- Geometric
- Distribution
- Noisy OR