Formula
Context
- Conditional Probability Tables (CPT) can be defined efficiently using BayesiaLab's Formula Editor
- The formula you specify in the Formula Editor generates the values of all cells in a CPT.
- Within each of the CPTs, the results are automatically normalized.
Prior to BayesiaLab 10, the Formula tab was named Equation.
Usage
- Select a node.
- To open the Formula tab in the Node Editor take any of the following steps:
- Go to
Node Contextual Menu > Edit > Probability Distribution > Formula
. - Or, double-click on the node and then go to the
Probability Equation > Formula
tab.

Formula Editor
- The Formula Editor is available under the Formula tab in the Node Editor.
- It contains 7 elements through which you can specify and edit a formula.
-
Return Type specifies what the formula returns upon evaluation:
- Deterministic: The formula returns node values.
- Probabilistic: The formula returns numerical values, which are normalized automatically to get probabilities.
-
The main Editor Panel depends on the Return Type specified.
-
The description language of the equations is strongly typed. The syntax uses functions and infix notation. Strongly typed is a concept used to refer to a programming language that enforces strict restrictions on intermixing of values with differing data types.
Infix notation is the notation commonly used in arithmetical and logical formulae and statements. It is characterized by the placement of operators between operands—"infixed operators"—such as the plus sign in 2 + 2.

The Equation Editor panel consists of 7 parts:
- Part 1: The Equation Type specifies whether the equation returns node values (Equation Type: Deterministic) or numerical values that will be considered, after normalization, as probabilities (Equation Type: Probabilistic).
- The heading of the Equation Editor window (part 2) reflects the choice. Note that the variable appears in the probabilistic equation to indicate the corresponding column in the probability table.

-
Part 2: The Equation Editor window allows you to directly enter equation formulas.
-
Part 3: The Message Panel display any errors in the formula. If a continuous node is associated with a deterministic equation, it can happen that some computed values are outside the domain of the variable. In this case, a dialog box will suggest to automatically extend the range of the variable in order to accomodate all values.
-
Part 4: Here, you can specify the number of random samples to be used for generating the probability tables. These samples are drawn from each interval of the discretized continuous variables in the equation. You can also specify a smoothing parameter that initializes the occurrence number of each table cell. Setting this parameter to a value greater than 0 implies not only the smoothing of the probability distribution but implies also that all the states have a nonzero associated probability. This smoothing parameter is unavailable for deterministic equations.
-
Part 5: List of the probability distributions, functions and operators that are available to write an equation:
- Discrete probability distributions
- Continuous probability distributions
- Special functions
- Arithmetic functions
- Transformation functions
- Trigonometric functions
- Relational operators
- Boolean operators
- Arithmetic operators
- User functions
By double-clicking on their name, you can insert any of the listed distributions, functions or operators into the equation.
-
Part 6 lists the variables that are available to be included in the equation. By default, this includes the node currently being edited in the Node Editor and its parents, if applicable. If the Time parameter is defined for the network, it will also be available in each equation. Double-clicking its name inserts the variable into the equation. As shown in the screenshot, the variable names are enclosed by question marks once they are part of the equation. If any constants are defined in the network, "Constants" will be displayed in the list among the other variables.
-
Part 7 shows the values of the currently highlighted variable. If "Constants" is selected, the available constants will be displayed. Double-clicking a value or constant inserts them into the equation.
Equation (8.0) Context
Function Node Editor | Equation

New Feature: Inference Functions - Overall Utility()
This function returns the Overall Utility defined by the Utility Nodes (i.e. the sum of all the Utilities).
The Function Node does not have to be connected with any node for utilizing this function.
New Feature: Inference Functions - Utility(u)
This function returns the Utility of the Utility Node u.

Whereas Utility() will return 10, Overall Utility() will return 5.
Equation (7.0)
Context
Node Editor | Probability Distribution | Equation

New Feature: Special Functions - StateCount(v)
This function returns the numbers of states of the variable v.
New Feature: Special Functions - StateValueAt(v, s)
This function returns the value (Node Editor | Values) associated with the state s of the variable v.
New Feature: Special Functions - Cost(v)
This function returns the cost (Node Editor | Properties) associated with the variable v.
Updated Feature: Inference Functions - Entropy(v, [n])
When called with the first parameter only, or with "No" or "False", this functions returns the Entropy of the variable v. Otherwise, when called with "Yes" or "True", it returns the Normalized Entropy.
New Feature: Inference Functions - JointProb()
This function returns the joint probability of the current set of evidence.
Equation (6.0)Context
Node Editor | Probability Distribution | Equation | Arithmetic Functions | Mean(x1, xn)

With the new Mean function, BayesiaLab offers now 5 n-ary arithmetic functions:
- Max(x1, xn). Returns the largest value from the n variables.
- Min(x1, xn). Returns the smallest value from the n variables.
- Mult(x1, xn). Returns the product of the n variables.
- Sum(x1, xn). Returns the sum of the n variables.
- Mean(x1, xn). Returns the mean of the n variables.
Equations (5.0.7)
Min and Max
The Min and Max Arithmetic Functions are now n-ary and not only binary. They can accept an unlimited number of arguments.


StateValue
The Special Function StateValue() allows using the numerical values associated with the states of the nodes.


