Multidimensional arrays

<< Click to Display Table of Contents >>

Navigation:  Using SMILE Wrappers >

Multidimensional arrays

Conditional probability table (CPT) describes the interaction between a node and its immediate predecessors. The number of dimensions and the total size of a conditional probability table are determined by the number of parents, the number of states of each of these parents, and the number of states of the child node. Essentially, there is a probability for every state of the child node for every combination of the states of the parents. Nodes that have no predecessors are specified by a prior probability distribution table, which specifies the prior probability of every state (outcome) of the node.

The conditional probability tables are stored as vectors of doubles that are a flattened version of multidimensional tables with as many dimensions as there are parents plus one for the node itself. The order of the coordinates reflects the order in which the arcs to the node were created. The most significant (leftmost) coordinate will represent the state of the first parent. The state of the node itself corresponds to the least significant (rightmost) coordinate.

The image below is an annotated screenshot of GeNIe’s node properties window open for the Forecast node in the model created in Tutorial 1. Forecast has three outcomes and two parents: Success of the venture and State of the economy, with two and three outcomes, respectively. Therefore, the total size of the CPT is 2 x 3 x 3 = 18. The annotation arrows in the image (not part of the actual GeNIe window) show the ordering of the entries in the linear buffer used internally. The first (or rather, the zero-th, because all indexes in SMILE are zero-based) element, the one with the value of 0.7 and yellow background, represents P(Forecast=Good | Success of the venture=Success & State of the economy=Up). It is followed by the probabilties for Moderate and Poor outcomes given the same parent configuration. The next parent configuration is Success of the venture=Success & State of the economy=Flat, and so on.

multidimensional_array

The node definition returned by Network.getNodeDefinition is a single-dimensional array. If your program needs to convert between linear and multidimensional coordinates, see Tutorial 3. The code in this tutorial includes the conversion function.

Note that multidimensional arrays are not used exclusively for CPTs. Other uses include expected utility tables and marginal probability distributions.