Class NodeDistributions

  • All Implemented Interfaces:
    Map<NodeDistributionKey,​Distribution>

    public final class NodeDistributions
    extends AbstractMap<NodeDistributionKey,​Distribution>
    Represents the distributions assigned to a Node. Temporal nodes and noisy nodes may require more than one distribution to be fully specified. In a Dynamic Bayesian Network (DBN) a node may require more than one distribution to be specified. This occurs when a temporal node has incoming links of order greater than zero. I.e. Has links from past time slices. For example, if a temporal node has an incoming link of order 1, then it will require a distribution at time t=0, and an additional distribution at t=1. This is because at time t=0 there is no previous time slice, but at time t=1 there is. For times greater than 1, in this example the distribution specified at time t=1 is still valid. However, if a new incoming link of order 12 was added, then an additional distribution would need to be specified at time t=12, valid for times t>=12.
    • Method Detail

      • getExpressions

        public NodeDistributionExpressions getExpressions()
        Gets any expressions associated with a node, that are used to generate distributions.
      • findForTimeWithOrder

        public NodeDistributions.DistributionOrder findForTimeWithOrder​(int time)
        Finds the temporal distribution that is suitable for the time specified.
        Parameters:
        time - The time.
        Returns:
        The distribution and order that is appropriate for the given time. Can return a null distribution, if the appropriate distribution has not yet been assigned to the node.
        Throws:
        IllegalStateException - Raised when an appropriate distribution could not be found.
      • findForTime

        public Distribution findForTime​(int time,
                                        NodeDistributionKind kind)
        Finds the temporal distribution that is suitable for the time specified.
        Parameters:
        time - The time.
        kind - The kind of distribution to retrieve.
        Returns:
        The distribution and order that is appropriate for the given time. Can return a null distribution, if the appropriate distribution has not yet been assigned to the node.
        Throws:
        IllegalStateException - Raised when an appropriate distribution could not be found.
      • findForTime

        public Distribution findForTime​(int time)
        Finds the temporal distribution that is suitable for the time specified.
        Parameters:
        time - The time.
        Returns:
        The distribution that is appropriate for the given time. Can return a null distribution, if the appropriate distribution has not yet been assigned to the node.
        Throws:
        IllegalStateException - Raised when an appropriate distribution could not be found.
      • findForTimeWithOrder

        public NodeDistributions.DistributionOrder findForTimeWithOrder​(int time,
                                                                        NodeDistributionKind kind)
        Finds the temporal distribution that is suitable for the time specified.
        Parameters:
        time - The time.
        kind - The kind of distribution to retrieve.
        Returns:
        The distribution that is appropriate for the given time. Can return a null distribution, if the appropriate distribution has not yet been assigned to the node.
        Throws:
        IllegalStateException - Raised when an appropriate distribution could not be found.
      • getNode

        public Node getNode()
        Gets the node that this instance belongs to.
      • getMaxTemporalOrder

        public int getMaxTemporalOrder()
        Gets the current maximum temporal order.
      • canUpdate

        public boolean canUpdate​(NodeDistributionKey key)
        Determines whether the distribution at the specified temporal order can be updated.
        Parameters:
        key - Properties identifying the distribution to check, such as temporal order/related node.
        Returns:
        true if the distribution can be updated, false otherwise.
      • canUpdate

        public boolean canUpdate​(NodeDistributionKey key,
                                 NodeDistributionKind kind)
        Determines whether the distribution at the specified temporal order can be updated.
        Parameters:
        key - Properties identifying the distribution to check, such as temporal order/related node.
        kind - The kind of distribution to check.
        Returns:
        true if the distribution can be updated, false otherwise.
      • validateDistribution

        public void validateDistribution​(Distribution value,
                                         NodeDistributionKey key)
        Checks that a distribution is correctly specified for a particular temporal order.
        Parameters:
        value - The distribution to test.
        key - The properties that identify a particular distribution such as temporal order/related node.
      • validateDistribution

        public void validateDistribution​(Distribution value,
                                         NodeDistributionKey key,
                                         NodeDistributionKind kind)
        Checks that a distribution is correctly specified for a particular temporal order.
        Parameters:
        value - The distribution to test.
        key - The properties that identify a particular distribution such as temporal order/related node.
        kind - The kind of distribution to validate.
      • get

        public Distribution get​(int temporalOrder)
        Gets a distribution at a particular temporal order. When specifying temporal distributions, variables which belong to temporal nodes must have times associated. Each time must be specified relative to the current point in time which is defined as zero. E.g. to specify a distribution at time>=1 we would include variables at time -1 and 0.
        Parameters:
        temporalOrder - The required temporal order.
        Returns:
        The requested distribution, which can be null if the node does not support the requested temporal order, or if a distribution has not yet been assigned to that order.
        Throws:
        IllegalArgumentException - [temporalOrder] must be non negative.
      • set

        public void set​(int temporalOrder,
                        Distribution value)
        Sets a distribution at a particular temporal order. When specifying temporal distributions, variables which belong to temporal nodes must have times associated. Each time must be specified relative to the current point in time which is defined as zero. E.g. to specify a distribution at time>=1 we would include variables at time -1 and 0.
        Parameters:
        temporalOrder - The required temporal order.
        Throws:
        IllegalArgumentException - [temporalOrder] must be non negative.
      • get

        public Distribution get​(NodeDistributionKey key)
        Gets a distribution with particular properties, such as temporal order.

        When specifying temporal distributions, variables which belong to temporal nodes must have times associated. Each time must be specified relative to the current point in time which is defined as zero. E.g. to specify a distribution at time>=1 we would include variables at time -1 and 0.

        For noisy nodes, multiple distributions are required, one for each parent and a leak distribution.

        Parameters:
        key - The properties of the required distribution, such as temporal order.
        Returns:
        The requested distribution, which can be null if the node does not support the requested temporal order, or if a distribution has not yet been assigned to that order.
        Throws:
        IllegalArgumentException - Temporal order must be non negative.
      • set

        public void set​(NodeDistributionKey key,
                        Distribution value)
        Sets a distribution with particular properties, such as temporal order.

        When specifying temporal distributions, variables which belong to temporal nodes must have times associated. Each time must be specified relative to the current point in time which is defined as zero. E.g. to specify a distribution at time>=1 we would include variables at time -1 and 0.

        For noisy nodes, multiple distributions are required, one for each parent and a leak distribution.

        Parameters:
        key - The properties of the required distribution, such as temporal order.
        Throws:
        IllegalArgumentException - Temporal order must be non negative.
      • get

        public Distribution get​(NodeDistributionKind kind)
        Gets a particular kind of distribution on the node.

        For temporal or noisy nodes, use the overload which accepts both a key and kind.

      • set

        public void set​(NodeDistributionKind kind,
                        Distribution value)
        Sets a particular kind of distribution on the node.

        For temporal or noisy nodes, use the overload which accepts both a key and kind.

      • get

        public Distribution get​(NodeDistributionKey key,
                                NodeDistributionKind kind)
        Gets a distribution with particular properties, such as temporal order.

        When specifying temporal distributions, variables which belong to temporal nodes must have times associated. Each time must be specified relative to the current point in time which is defined as zero. E.g. to specify a distribution at time>=1 we would include variables at time -1 and 0.

        For noisy nodes, multiple distributions are required, one for each parent and a leak distribution.

        Parameters:
        key - The properties of the required distribution, such as temporal order.
        kind - The kind of distribution we are getting or setting. This allows setting other distribution types than Probability, such as Experience
        Returns:
        The requested distribution, which can be null if the node does not support the requested temporal order, or if a distribution has not yet been assigned to that order.
        Throws:
        IllegalArgumentException - Temporal order must be non negative.
      • set

        public void set​(NodeDistributionKey key,
                        NodeDistributionKind kind,
                        Distribution value)
        Sets a distribution with particular properties, such as temporal order.

        When specifying temporal distributions, variables which belong to temporal nodes must have times associated. Each time must be specified relative to the current point in time which is defined as zero. E.g. to specify a distribution at time>=1 we would include variables at time -1 and 0.

        For noisy nodes, multiple distributions are required, one for each parent and a leak distribution.

        Parameters:
        key - The properties of the required distribution, such as temporal order.
        kind - The kind of distribution we are getting or setting. This allows setting other distribution types than Probability, such as Experience
        Throws:
        IllegalArgumentException - Temporal order must be non negative.