|
<< 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 define a continuous distribution over numeric node outcomes, use Network.set_intervals:
Python
net.set_intervals(nodeHandle, [ 0, 2.78, 3.14, 77, math.inf ], True)
Java
net.setIntervals(nodeHandle, new double[] { 0, 2.78, 3.14, 77, Double.POSITIVE_INFINITY }, true);
C#
net.setIntervals(nodeHandle, new double[] { 0, 2.78, 3.14, 77, Double.PositiveInfinity }, true);
R
net$setIntervals(nodeHandle, c({ 0, 2.78, 3.14, 77, Inf }), TRUE)
The example defines five numeric boundaries, creating four intervals: 0–2.78, 2.78–3.14, 3.14–77, and 77–infinity. Using negative infinity as the first element creates an open first interval. Interval boundaries must be sorted from lowest to highest. A point interval can be defined by using identical numbers as its boundaries.
The second parameter of Network.set_intervals indicates whether existing outcome identifiers should be discarded. Using true discards identifiers, leaving an empty string for each outcome. Using identifiers with intervals is optional.
Outcome-modifying methods such as Network.add_outcome, Network.insert_outcome, and Network.delete_outcome work normally with intervals. Adding or inserting outcomes splits an existing interval; deleting removes the corresponding interval. At any time, you can redefine all intervals with Network.set_intervals. The new list may have a different size than the previous one.
Other interval-related methods include Network.has_intervals, Network.get_intervals, and Network.remove_intervals. Removing intervals restores default outcome identifiers if they were previously empty. The number of outcomes does not change.
After inference, the node value contains the marginal probability distribution over its outcomes. With intervals defined, you can calculate the mean and standard deviation of the distribution. SMILE treats the distribution as continuous and uniform within each closed interval. Open intervals are assumed to follow a half-normal distribution, scaled to match the neighboring interval’s uniform height. Retrieve the mean or standard deviation via Network.get_node_mean and Network.get_node_std_dev once is_value_valid returns true.
Numeric intervals allow continuous evidence in discrete nodes. Set continuous evidence using Network.set_cont_evidence. The evidence is internally converted to an outcome index during inference. If a discrete parent with intervals has continuous evidence and a continuous child, the exact evidence value is used during sampling to evaluate the child.
Here are the methods for managing numeric intervals in discrete nodes:
Python
has_intervals(node: int | str) -> bool
set_intervals(node: int | str, boundaries: List[float], discard_ids: bool) -> None
get_intervals(node: int | str) -> list[float]
remove_intervals(node: int | str) -> None
Java
boolean hasIntervals(int nodeHandle);
boolean hasIntervals(String nodeId);
void setIntervals(int nodeHandle, double[] boundaries, boolean removeIds);
void setIntervals(String nodeId, double[] boundaries, boolean removeIds);
double[] getIntervals(int nodehandle);
double[] getIntervals(String nodeId);
void removeIntervals(int nodeHandle);
void removeIntervals(String nodeId);
C#
bool HasIntervals(int nodeHandle);
bool HasIntervals(string nodeId);
void SetIntervals(int nodeHandle, double[] boundaries, bool discardIds);
void SetIntervals(string nodeId, double[] boundaries, bool discardIds);
double[] GetIntervals(int nodeHandle);
double[] GetIntervals(string nodeId);
void RemoveIntervals(int nodeHandle);
void RemoveIntervals(string nodeId);
R
hasIntervals <- has_intervals(nodeIdOrHandle)
setIntervals(nodeIdOrHandle, boundaries, discardIds)
intervals <- get_intervals(nodeIdOrHandle)
remove_intervals(nodeIdOrHandle)