<< Click to Display Table of Contents >> Navigation: Using SMILE Wrappers > 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 Network.setIntervals:
Java:
net.setIntervals(nodeHandle, new double[] { 0, 2.78, 3.14, 77, Double.POSITIVE_INFINITY }, true);
Python:
net.set_intervals(nodeHandle, [ 0, 2.78, 3.14, 77, math.inf ], True)
R:
net$setIntervals(nodeHandle, c({ 0, 2.78, 3.14, 77, Inf }), TRUE)
C#:
net.setIntervals(nodeHandle, new double[] { 0, 2.78, 3.14, 77, Double.PositiveInfinity }, true);
The example above passes five numeric interval boundaries , and defines four intervals: 0 to 2.78, 2.78 to 3.14, 3.14 to 77, and 77 to infinity. Using negative infinity 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 second parameter in the Network.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 Network.addOutcome or Network.insertOutcome new interval will be created by splitting the existing interval at the appropriate index. Network.deleteOutcome will remove the interval at the specified index. At any time it is possible to call Network.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 for working with intervals are Network.hasIntervals, Network.getIntervals, and Network.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 Network.getNodeMean or Network.getNodeStdDev respectively on the node value object.
Intervals allow for continuous evidence in discrete nodes. To set continuous evidence, call Network.setContEvidence 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. When discrete node with intervals has continuous evidence, and the child node is continuous, the exact value of continuous evidence in the parent will be used to evaluate the child during sampling.