Outcome intervals

<< Click to Display Table of Contents >>

Navigation:  Using SMILE > Discrete Bayesian networks > Discrete nodes and numeric domains >

Outcome intervals

Discrete nodes by default do not have any numeric information associated with their outcomes. To add outcome intervals, call DSL_discDef::SetIntervals.

int handle = …

auto discDef = net.GetNode(handle)->Def<DSL_discDef>();

discDef->SetIntervals({ 0, 2.78, 3.14, 77, DSL_inf() }, true);

The example above passes five numeric interval boundaries in std::initializer_list (overloads with DSL_doubleArray and std::vector are also available) as its first parameter, and defines four intervals: 0 to 2.78, 2.78 to 3.14, 3.14 to 77, and 77 to infinity. We used the DSL_inf() function to return a floating point value representing the positive infinity. DSL_inf() is just a convenient way to call std::numeric_limits<double>::infinity(). Using -DSL_inf() as first element in the intervals definition creates open first interval. The list of interval boundaries has to be sorted from lowest to highest. It is possible to specify a point interval by means of two identical numbers as its boundaries.

The number of outcomes will change to reflect the number of intervals passed to SetIntervals. It is not necessary to call SetNumberOfOutcomes before SetIntervals.

The second parameter in the SetIntervals call is set to true to indicate that existing outcome identifiers should be discarded. The use of outcome identifiers with outcome intervals is optional. If the identifiers were discarded, the outcome identifier array will have empty string for each outcome id.

It is possible to call the outcome modifying methods when node has intervals. After AddOutcome or InsertOutcome new interval will be created by splitting the existing interval at the appropriate index. DeleteOutcome will remove the interval at the specified index. At any time it is possible to call SetIntervals again with a new list of interval boundaries. In such case, the list of new interval boundaries may have different size than the existing list.

Other methods in the DSL_discDef for working with intervals are HasIntervals, GetIntervals, and RemoveIntervals. The last function removes the interval boundaries from the node definition, and in case there were no outcome identifiers, creates the default set of identifiers. The number of outcomes does not change.

With intervals defined, it is possible to calculate the mean and standard deviation for the node given the marginal probability distribution over its outcomes. In calculating the moments of the distribution, SMILE treats it as a continuous distribution, assuming that it is uniform within each of the intervals. Open intervals are an exception; the distribution over these is assumed to be half-normal scaled to ensure the normal PDF height is equal to the neighboring closed interval's uniform distribution. To retrieve the mean or the standard deviation, call GetMean or GetStdDev respectively on the node value object.

Intervals allow for continuous evidence in discrete nodes. To set continuous evidence, call DSL_nodeValue::SetEvidence(double). The evidence will be stored and will be internally converted into an outcome index during inference in a discrete Bayesian network or an influence diagram. However, hybrid models can take advantage of continuous evidence in a discrete node.